├── 01-Big0 ├── 1.exe ├── 10.exe ├── 2.exe ├── 3.exe ├── 4.exe ├── 5.exe ├── 6.exe ├── 7.exe ├── 9.exe ├── 12.cpp ├── 2.cpp ├── 4.cpp ├── 10.cpp ├── 5.cpp ├── 7.cpp ├── 3.cpp ├── 6.cpp ├── 9.cpp ├── 1.cpp ├── 8.cpp └── 11.cpp └── 00-Misc ├── helloWorld.exe └── helloWorld.cpp /01-Big0/1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/1.exe -------------------------------------------------------------------------------- /01-Big0/10.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/10.exe -------------------------------------------------------------------------------- /01-Big0/2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/2.exe -------------------------------------------------------------------------------- /01-Big0/3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/3.exe -------------------------------------------------------------------------------- /01-Big0/4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/4.exe -------------------------------------------------------------------------------- /01-Big0/5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/5.exe -------------------------------------------------------------------------------- /01-Big0/6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/6.exe -------------------------------------------------------------------------------- /01-Big0/7.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/7.exe -------------------------------------------------------------------------------- /01-Big0/9.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/01-Big0/9.exe -------------------------------------------------------------------------------- /00-Misc/helloWorld.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amulifts/dsa-basics/HEAD/00-Misc/helloWorld.exe -------------------------------------------------------------------------------- /00-Misc/helloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | cout<<"This is my first program"< loop within loop 5 | // o(n) --> Proportional 6 | // 0(log n) --> Divide and Conquer 7 | // 0(1) --> COnstant 8 | 9 | -------------------------------------------------------------------------------- /01-Big0/2.cpp: -------------------------------------------------------------------------------- 1 | // o(n) 2 | 3 | #include 4 | using namespace std; 5 | 6 | void printItems(int n){ 7 | for ( int i=0; i 0(n^2) 2 | 3 | #include 4 | using namespace std; 5 | 6 | void printItems(int n){ 7 | for (int i=0; i 3 | using namespace std; 4 | 5 | void printItems(int a, int b){ 6 | // 0 (a * b) 7 | for ( int i=0; i 0(n^2) 2 | 3 | #include 4 | using namespace std; 5 | 6 | void printItems(int n){ 7 | for (int i=0; i but we still call this 0(1) 15 | #include 16 | using namespace std; 17 | 18 | int addItems(int n){ 19 | return n + n + n ; 20 | } 21 | 22 | int main(){ 23 | addItems(10); 24 | } -------------------------------------------------------------------------------- /01-Big0/3.cpp: -------------------------------------------------------------------------------- 1 | // Drop Constant --> n + n = 2n so we might think we write it as 0(2n) but we write it as 0(n) 2 | 3 | #include 4 | using namespace std; 5 | 6 | void printItems(int n){ 7 | for ( int i=0; i 0(n^2) 2 | 3 | #include 4 | using namespace std; 5 | 6 | void printItems(int n){ 7 | // 0(n^2) 8 | for (int i=0; i 3 | using namespace std; 4 | 5 | void printItems(int a, int b){ 6 | // 0 (n) 7 | for ( int i=0; i 0(n) // wrong since a and b can't be always equal 16 | //0(a) + 0(b) = 0(a+b) 17 | } 18 | 19 | int main(){ 20 | printItems(10,20); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /01-Big0/1.cpp: -------------------------------------------------------------------------------- 1 | // way of comparing two sets of code mathematically about how efficiently it run 2 | // time complexity --> it is measured in number of operations that it takes to complete sth 3 | // space compexity --> preserving memory space is most important priority even it takes some time 4 | 5 | // in dealing with time and space complexity we will see 3 greek letter 6 | // --> omega , theta and omecron ( O ) 7 | 8 | // best case = omega 9 | // average case = theta 10 | // worse case = O 11 | 12 | #include 13 | using namespace std; 14 | 15 | int main(){ 16 | int x[] = {1,2,3,4,5,6,7}; 17 | for(int i=0; i<=6 ; i++){ 18 | cout< quickest way to get to 1 4 | // cut the array in half and see it is in 1st half or second half i.e {1,2,3,4} {5,6,7,8} 5 | // it is not in second half so we don't have to look at any of those numbers we have {1,2,3,4} 6 | // break it into 2 half again i.e {1,2} {3,4} 7 | // not in second half so we don't have to look at any of those numbers we have {1,2} 8 | // break it into 2 hald again i.e {1} {2} 9 | // not in second half so we don't have to look at any of those numbers we have {1} 10 | 11 | // 3 steps took to find number 1 --> we had 8 items in an array 12 | 13 | // 2^3 = 8 --> log(base 2)8 = 3 14 | 15 | // log(base 2)1,073,741,824 = 31 --> cut half 31 times to get number 1 16 | -------------------------------------------------------------------------------- /01-Big0/11.cpp: -------------------------------------------------------------------------------- 1 | // Vectors 2 | 3 | // array we have {11,3,23,7} --> 0,1,2,3 index 4 | 5 | //myVect.push_back(17); --> {11,3,23,7,17} --> 0,1,2,3,4 6 | //myVect.pop_back(); --> {11,3,23,7} --> 0,1,2,3 7 | 8 | /* adding and removing an item from a vector is 0(1) */ 9 | 10 | //myVect.erase(myVect.begin()); --> {3,23,7} --> {0,1,2} 11 | // index doesn't remain same 12 | //myVect.insert(myVect.begin(),11); --> {11,3,23,7} --> {0,1,2,3} 13 | // again back to same index 14 | 15 | /* it doesn't matter either you are removing or adding it's gonnabe 0(n) */ 16 | 17 | //myVect.insert(myVect.begin()+1,99); --> {11,99,3,23,7} --> {0,1,2,3,4} 18 | //0(1/2 n) --> drop constant --> 0(n) 19 | 20 | //find 7 {11,3,23,7} --> {0,1,2,3} 21 | 22 | /* 23 | looking by value is 0(n) 24 | looking by index is 0(1) 25 | */ 26 | 27 | 28 | --------------------------------------------------------------------------------