computer_science:programming:algorithm
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
computer_science:programming:algorithm [2021/09/25 05:28] – [Pseudocode] mana | computer_science:programming:algorithm [2021/10/14 03:35] (current) – [Gauss Sum] mana | ||
---|---|---|---|
Line 83: | Line 83: | ||
* '' | * '' | ||
+ | |||
+ | ===== Sequential Search ===== | ||
+ | Data set of N elements: '' | ||
+ | Therefore the list will be L< | ||
+ | Target: 45 〇 130 × | ||
+ | This is easy for the brain because the brain is made pattern matching. | ||
+ | |||
+ | < | ||
+ | Step 1 get L1, L2, LN, N, Target | ||
+ | Step 2 Set Found = No | ||
+ | Step 3 Set i = 1 | ||
+ | Step 4 while (Foundo = No AND i ≤ N) do Step 5 to Step 6 | ||
+ | Step 5 if (Li = Target) then | ||
+ | set Found = Yes | ||
+ | Step 6 else | ||
+ | set i = i + 1 | ||
+ | Step 7 if (Found = Yes) then | ||
+ | print " | ||
+ | Step 8 else | ||
+ | print " | ||
+ | Step 9 stop | ||
+ | </ | ||
+ | |||
+ | ===== The Swap ===== | ||
+ | x y | ||
+ | 5 3 | ||
+ | Swap the content of both variable so that X=3 and Y=5 | ||
+ | < | ||
+ | Step 1 get x, y | ||
+ | Step 2 set temp = x | ||
+ | Step 3 x = y | ||
+ | Step 4 y = temp | ||
+ | Stop 5 Stop | ||
+ | </ | ||
+ | |||
+ | * For swapping in other algorithm '' | ||
+ | |||
+ | ===== Gauss Sum ===== | ||
+ | n ≥ 1 | ||
+ | 1+2+3+4+...+n | ||
+ | |||
+ | Formula: $\frac{(n+1)*n}{2}$ | ||
+ | FIXME (double check this information) | ||
+ | When talking about efficiency we say that the efficiency of n is $\Theta(n^2)$ | ||
+ |
computer_science/programming/algorithm.1632515324.txt.gz · Last modified: 2021/09/25 05:28 by mana