Data Structure Algorithm is to simply place and store data in an organized manner.
For example: Array
We can store data in Data Array, Stack, Queue are type of data structure where we can store data so that we can use it for particular purpose.
Primitive- int, flow
Non-Primitive- Array, Stack, Queue
• To organize data
• Storage of data
• Retrieval of data
• Manipulation of data
• DS allow into storage on hard disk
• It manages large data
• It is necessary for designing of efficient algorithm
Algorithm is a set of instructions which leads to a step procedure for solving a given problem.
- Input: Whatever instructions are entered by the programmers.
- Output: Atleast one outcome will be produced.
- Definiteness: Each instruction should be clear and unambiguous.
- Finiteness: Every algorithm with terminate after a certain number of steps and it is called finiteness.
- Effectiveness: Every instruction must be sufficiently basic that it can in principle be carried out by a person using pencil and paper.
we can compare the performanece of algorithms by using following factors
. space complexity
. time complexity
- space complexity
the term space complexity represents the mount of memory space needed the algorithm in its life cycle
- time complexity
the term time complexity represents of a program is the amount of computer time it needs to run a program to completion
. we can divide the time complexity on three catogories
1. best case
2. worst case
3. average case
- Linear Data Structure
- Non-linear Data Structure
In the linear data structures data can be processed one by one i.e sequentially
The linear data structures are
- array
- linked list
- stack
- queue
• arrays
array is a collectiona of homogeneous data elements i.e it can store same type of data value
advantages :-
* random access
* very fast access if it index known
dis-advantages :-
* fixed size
* store same type of data
types of arrays
- one dimensional array
- two dimensional array
- multi dimensional array
• linked list
linked list is a linear data structure
the linked list is a linear collections of data items called as nodes
the node is divided into two fields
> data field
> link field (link to another node)
types of linked list
- single linked list
- doubly linked list
- circular linked list
in non-linear data strcture the elements do not form a sequence
we cant access the data on sequentially
the non-linear data structures are :-
- trees
- graphs
• trees
tree is a finite set of nodes, that is specially designated node is called root and remaining nodes are collections of sub trees
• graphs
graphs is a collection of non-empty nonlinear set of nodes and set of edges
- Insertion : adding the new elements to existing data strcture
- Deletion : deleting the element from a data structure
- Traversing : access the each elements
- Searching : searching a particular element on a particuar data structure
- Sorting : arramging the elements either ascending or descending order
- Merging : combine two different program element into single sorted file
- Learning from books is always a good practice. You will get the big picture of programming concepts in the book which you may not find elsewhere.
- Introduction to Algorithms, Thomas H. Cormen - it is one of the best books in algorithms and covers a broad range of algorithms in-depth
- Algorithms, Robert Sedgewick - it is the leading textbook on algorithms and is widely used in colleges and universities
- The Art of Computer Programming, Donald E. Knuth - this book is considered best if you know the subject and are looking for deeper understanding
- Once you have some idea about data structure and algorithms, there is a great resource at Data Structure Visualizations that lets you learn through animation.