Unit 1 Introduction
Unit 1 Introduction
int
LINEAR NON LINEAR
float
Arrays
Queues
Linked
List
1) Traversing
2) Insertion
3) Deletion
4) Searching
5) Sorting
6) Merging
Step 1: BEGIN
Step 2: Set avg=0.0 and sum=0
Step 3: for i = 1 to 15 do
Step 4: read (a)
Step 5: sum = sum + a
Step 6: end – for step 3
Step 7: avg = sum / 15
Step 8: write avg
Step 9: END
102 6.6 102 6.6 * 102 104 106 1.3 * 1030 9.3 * 10157
2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
2 3 5 7 9
11 13 15 17 19
21 23 25 27 29
31 33 35 37 39
41 43 45 47 49
2 3 5 7
11 13 17 19
23 25 29
31 35 37
41 43 47 49
2 3 5 7
11 13 17 19
23 29
31 37
41 43 47 49
2 3 5 7
11 13 17 19
23 29
31 37
41 43 47
282,589,933 − 1
found by Patrick Laroche of Great Internet Mersenne
Prime Search (GIMPS)
102 6.6 102 6.6 * 102 104 106 1.3 * 1030 9.3 * 10157
2 3 n
1 < log n < n < n log n < n < n < 2 < n!
1) Best Case
2) Worst Case
3) Average Case
Assumptions :
f(n) algorithms running time
c(n) basic operation count
g(n) some simple function to compare with
If f(n) <= C g(n) for all n >= n0, C > 0 and n0 >= 1.
Solution:
6*2n + n2 ≤ 7 * 2n for n ≥ 4
f(n) = Ω g(n)
Solution:
ANSWER:
10n3 + 5 ≥ 10 * n3 for n ≥ 0
f(n) = ϴ g(n)
ANSWER:
10 * n3 ≤ 10 * n3 + 5 ≤ 11 * n3 for n ≥ 2
ANSWER:
6 * 2n ≤ 6 * 2n + n2 ≤ 7 * 2n for n ≥ 4