IbrahimHassan

Untitled

Oct 15th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. https://www.youtube.com/watch?v=9SgLBjXqwd4&index=7&list=PLDN4rrl48XKpZkf03iYFl-O29szjTrs_O
  2.  
  3. //: Playground - noun: a place where people can play
  4.  
  5. import Cocoa
  6.  
  7. var str = "Hello, playground"
  8. print (str)
  9.  
  10. //Software development Life Cycle - Design -> make Perfect Design to develop understanding of the thing to be developed. (Trial and Error Should be Avoided). Software Engineer can retiterate. At the design time, we write the psudo code of the program on paper. These are algoritm. They are made at design time. Programs are written at implementation time. The person wrirting the algorithm should have the domain knowledge.
  11.  
  12.  
  13. // Priori Analysis and Posteriori Testing - Done on the algorithm studying it in greater details (Language + Hardware Environment).
  14. // Space and time complexity. Testing is done on the programs.
  15.  
  16. //Characteristics of An Algorithm -
  17. // 1) Can take input 0 or more
  18. // 2) Must generate at least one output.
  19. // 3) Definiteness - Every statement must be unambigious. Known steps.
  20. // 4) Finiteness - It must stop.
  21. // 5) Effectiveness -
  22.  
  23. // Algorithm to Swap Two Numbers
  24. // Alogorithm Swapper
  25.  
  26. // Time Analysis
  27. // temp, num1, num2
  28. // temp = num1 (1)
  29. // num1 = num2 (1)
  30. // num2 = temp (1)
  31. // ========================
  32. // totalTimeFunction -> (3)
  33.  
  34. // Caveat
  35. // x = 5 * a + 6 * b (1) -> m1, m1, s1, a1
  36. // Not analysed in deep detail
  37.  
  38. // Space Analysis
  39. // temp = num1 (1 word)
  40. // num1 = num2 (1 word)
  41. // num2 = temp (1 word)
  42. // ===============================
  43. // totalSpaceFunction -> (3 words)
  44.  
  45.  
  46. // Ananlyzing an Algorithm
  47.  
  48. // 1. Time - Every simple step in a algorithm takes one unit of time. Each statement takes one unit of time
  49. // 2. Space
  50. // 3. Network Consumption <How Much data is sent>
  51. // 4. Power Consumption <Handheld devices>
  52. // 5. CPU registers <Device Driver / System Level Programming>
  53.  
  54. // Frequency Count Method <Finding Sum of An Array>
  55. /* Time Complexity
  56. C Code
  57.  
  58. Algorithm sum(A, n) {
  59. s = 0; 1
  60. for (i = 0; i < n; i++) { - n+1
  61. [1], [n + 1], n = 2n + 2
  62. s = s + a[i]; n
  63. }
  64. return s; 1
  65. }
  66. =====================================
  67. 2n + 3 -> degree (1) <Order of n>
  68. */
  69.  
  70.  
  71. /* Space Complexity
  72. C Code
  73.  
  74. Algorithm sum(A, n) {
  75. a - n words
  76. s - 1 word
  77. i - 1 word
  78. n - 1 word
  79. =====================================
  80. n + 3 -> degree (1) <Order of n>
  81. */
  82.  
  83. /*
  84. Root N Loop
  85. p = 0
  86. for (i = 1; p <= n; i++) {
  87. p = p + i;
  88. }
  89.  
  90. p = k(k+1)/ 2 > n
  91. k^2 + k / 2 > n
  92. k^2 > n
  93. k > n ^ 0.5
  94. O (n ^ 0.5)
  95. */
  96.  
  97. /*
  98.  
  99. Log N time Complexity
  100. p = 0
  101. for (i = 1; i < n; i++) {
  102. statement
  103. }
  104.  
  105. 2^k = n
  106. k = log2(n)
  107. */
  108.  
  109.  
  110. //
Add Comment
Please, Sign In to add comment