-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdec3.txt
More file actions
100 lines (51 loc) · 2.61 KB
/
Copy pathdec3.txt
File metadata and controls
100 lines (51 loc) · 2.61 KB
1
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
data structure---
1.primitive data types--
int , char , bool, float
2.non-primitive data type--
data types: arrays, linked-list , stacks , queues, vector
staic data structure -- arrays,,,
dynamic data structure -- vectors
linear --- ek ke baad ke---- arrays, stacks
non-linear ---- trees , graphs , map
ALGORITHMS---
space complexicity---
program run ho gaya...uss runtime me usne kitni space li
space taken by the program while execution[excluding input size]
time complexicity---kitna time lag raha hai uss program ko execute karne me....
int x = 5; the time complexicity = 1; meaning constant--
while(n>0){
n/=2;
}
---------the time complexicity of this is log(n);
for(int i = 0; i<=n ; i++){
x+=5;
}
--the time complexicity of this is --- n
for(int i =0 ; i<m; i++){
while(n>0){
n/=2;
------O(log(n)) + O(m) ---- so time complexity ---- m
so if there is = then we need to choose the maximum--- ...so answer is m
}
}
for(int i = 0 ; i<m;i++){
for(int j =0 ; j<n ; j++){
x+=5;
-----iski time complexity == mn
}
}
for(int i = 0; i<2n ; i++){
x+=5;
}
time complexicity --- n --- here time complexicity does not depend on the inner part---
for(int i =0; i<x/2; i++){
x+=5;
}
for(int i =0 ; i <n ; i++){
}
---create an array of size m;
--take input of m integers;
---calculate sum of this array-----
space complexicity --- m
time complexicity --- nm
TIME COMPLEXICITY ---