Data Algo
Data Algo
STRUCTURES-------------------------------------------------------------------------
-----
DATA STRUCTURE :
Data structure is different way of organizing the data in an computer
More effective
PRIMITIVE : These are Basic Data types and that cannot be broken into small data
type.
* Int
* Float
* String
* Boolean
NON PRIMITIVE : These are Complex Data types and that can be broken into smaller
data type.
--> LINEAR :
* list {Built in Data type}
* Tuple {Build in Data type}
* Array
* Linked List
* Stack
* Queue
ALGORITHM :
Set of instruction perform a task.
TYPES OF ALGORITHM :
--> DYNAMIC PROGRAMMING : To solve the problem by breaking down into smaller sub-
problems.
EXAMPLE : Knapsack Problems etc..
--> DIVIDE AND CONQUER : To solve the problem by breaking down into smaller sub-
problems, solving them independently each and combining the results.
EXAMPLE : Merge sort or Quick sort etc..
--> RECURSIVE : To solve the problem by breaking down into smaller sub-problems,
same as in Nature.
BIG O :
Big O is a language and metric system , that use to describe the efficiency of
an Algorithm.
Big O would not consider the Time complexity, its based on NUMBER OF
OPERATIONs.
1 2 3 4 5 6 7 8
omega Theta O
|-------------|-------------|------------------------------------------|
| COMPLEXITY | NAME | SAMPLE |
|-------------|-------------|------------------------------------------|
| O(1) | Constant | Simple add numbers Functions |
|-------------|-------------|------------------------------------------|
| O(n) | Linear | Loop through numbers from 1 to n numbers |
|-------------|-------------|------------------------------------------|
| O(LogN) | Lograthmic | Find element in a sorted Array |
|-------------|-------------|------------------------------------------|
| O(N^2) | Quadratic | Nested loops |
|-------------|-------------|------------------------------------------|
| O(2N) | Exponential | Double recursion in Fibonacci |
|-------------|-------------|------------------------------------------|
mul(10)
In above Example i will run through n times and after
i j will runs for evry n times.totally its N^2
[1 | 2 | 3 | 4] [5 | 6 | 7 |8]
[1 | 2] [3 | 4]
[1] [2]
Log 2^3 = 8
ARRAY :
Array is collection of same Data types.Its same as list in python but in python
we can store diffrent data types towards an list.
TYPES OF ARRAY :
---> ONE DIMENSIONAL ARRAY :
An Array with bunch of values having been declared with single
index.
It consists of 1 Row and N columns.
EXAMPLE : [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... N]
EXAMPLE : [1 2 3 4 5 ]
[6 7 8 9 10]
[11 12 13 14 15]