Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://www.youtube.com/watch?v=9SgLBjXqwd4&index=7&list=PLDN4rrl48XKpZkf03iYFl-O29szjTrs_O
- //: Playground - noun: a place where people can play
- import Cocoa
- var str = "Hello, playground"
- print (str)
- //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.
- // Priori Analysis and Posteriori Testing - Done on the algorithm studying it in greater details (Language + Hardware Environment).
- // Space and time complexity. Testing is done on the programs.
- //Characteristics of An Algorithm -
- // 1) Can take input 0 or more
- // 2) Must generate at least one output.
- // 3) Definiteness - Every statement must be unambigious. Known steps.
- // 4) Finiteness - It must stop.
- // 5) Effectiveness -
- // Algorithm to Swap Two Numbers
- // Alogorithm Swapper
- // Time Analysis
- // temp, num1, num2
- // temp = num1 (1)
- // num1 = num2 (1)
- // num2 = temp (1)
- // ========================
- // totalTimeFunction -> (3)
- // Caveat
- // x = 5 * a + 6 * b (1) -> m1, m1, s1, a1
- // Not analysed in deep detail
- // Space Analysis
- // temp = num1 (1 word)
- // num1 = num2 (1 word)
- // num2 = temp (1 word)
- // ===============================
- // totalSpaceFunction -> (3 words)
- // Ananlyzing an Algorithm
- // 1. Time - Every simple step in a algorithm takes one unit of time. Each statement takes one unit of time
- // 2. Space
- // 3. Network Consumption <How Much data is sent>
- // 4. Power Consumption <Handheld devices>
- // 5. CPU registers <Device Driver / System Level Programming>
- // Frequency Count Method <Finding Sum of An Array>
- /* Time Complexity
- C Code
- Algorithm sum(A, n) {
- s = 0; 1
- for (i = 0; i < n; i++) { - n+1
- [1], [n + 1], n = 2n + 2
- s = s + a[i]; n
- }
- return s; 1
- }
- =====================================
- 2n + 3 -> degree (1) <Order of n>
- */
- /* Space Complexity
- C Code
- Algorithm sum(A, n) {
- a - n words
- s - 1 word
- i - 1 word
- n - 1 word
- =====================================
- n + 3 -> degree (1) <Order of n>
- */
- /*
- Root N Loop
- p = 0
- for (i = 1; p <= n; i++) {
- p = p + i;
- }
- p = k(k+1)/ 2 > n
- k^2 + k / 2 > n
- k^2 > n
- k > n ^ 0.5
- O (n ^ 0.5)
- */
- /*
- Log N time Complexity
- p = 0
- for (i = 1; i < n; i++) {
- statement
- }
- 2^k = n
- k = log2(n)
- */
- //
Add Comment
Please, Sign In to add comment