Data structure
- How many ways we can organise the data elements in Computer memory.
- How many ways we can retrieve in the data elements (called retrieving )from computer memory.
- Data Structure is a way of collection and organising data in such a way that we can perform operations on this data in an efficient way .So ,that verious operations can be performed on it easily.
- Linear data structures
- Non-linear data structures
In this element formed in an organised sequence. i.e ,elements are organised in sequential order .
Ex:-Array,stock ,queue ,linked list
Arrays:-
An array is a data structure that contains a group of elements typically these elements are all of the same datatype . Such as an integer or string array are commonly used in computer programming to organise data. So, that related set of values can be easily sorted or searched.
Types of Arrays
1.Single dimensions Array
Ex:-int num[3];
char str[20];
2.Two dimensions Array
Ex:-int mat[2][3];
char str[10][20];
3.Multi dimensions Array
Ex:-int marks[10][20][5];
10->no.of section
20->no.of Stu's in each section
5->id|m1|m2|m3|sum|
Stack:-
stack is a linear data structure it is a data structure which is based on array concept and it it is called FILO (first in last out) i.e the data elements which are inserted first display last tour [OR] LIFO (last in first out )i.e the elements which inserted last display first.
⇒In stock insertion deletion will be healed in only one in called top of stock .
Ex:- int str[3];
push (11)
push (22)
push(33)
show ()
O/p
33
22
11
Ex:-keepting wishes,while washing time.
Queue :-
Queue is linear data structure . It is also static data structure which is based on array concept.
Q is called FIFO( first in first out) i.e the elements which are inserted first displays first (or) LILO(last in last out )i.e the elements which are inserted last display (or) deleted at last .
- In queue insertion, deletion will be held on both ends .
- Insertion held at one end called rear .
- deletion will be held at another in end called front .
- Example :-taking movie tickets in Q wise
Push(11)
Push(22)
Push(33)
Show():-
O/P
11
22
33
Linked list:-
It is linear Data Structure but it is a dynamic . Data Structure the i.e there is no limition of allocation data elements in a Computer memory .
In linked list data will be stored in form of node wise .
- Each node contains two partions
- When control reads address of next node as a 'null' it means end linked list.
11,22,33
Head (or) first
Head =100(Address )
Head->data=11(value)
Head->next=150(next node address)
- To create node in linked list we using nested structure .
structu node
|
---|
Node
Data | * next |
---|---|
10 | 150 |
---|---|
Tree |
Graph |
Cities->nodes or vertius
Roads->edges
Comments