of 83
8/6/2019 siri1
1/83
8/6/2019 siri1
2/83
8/6/2019 siri1
3/83
8/6/2019 siri1
4/83
8/6/2019 siri1
5/83
8/6/2019 siri1
6/83
8/6/2019 siri1
7/83
8/6/2019 siri1
8/83
8/6/2019 siri1
9/83
8/6/2019 siri1
10/83
8/6/2019 siri1
11/83
8/6/2019 siri1
12/83
8/6/2019 siri1
13/83
Types of data structure
1. Linear V/S Non Linear
A data structure is said to be linearif its elements form a sequence like array or
linked list
And the data structure where there is no such sequence are called non linear like tree andgraph
2. Homogeneous V/S Non-Homogeneous
The data structure where we store similar type of data, is called homogeneous data
structure otherwise it is called non homogeneous
8/6/2019 siri1
14/83
8/6/2019 siri1
15/83
8/6/2019 siri1
16/83
Put some analogies
8/6/2019 siri1
17/83
8/6/2019 siri1
18/83
8/6/2019 siri1
19/83
Insertion of an element at the start of array: Consider the Array
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Insert new element 15 at start of array(i.e. at index 0)
Step 1: Shift all the values to next index to make space at index 0 for new element: Shift 6 from index 3 to index 4.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 7 from index 2 to index 3.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 10 from index 1 to index 2.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 3 from index 0 to index 1.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Now there is space for new element at index 0.
Step 2: Copy the new element at index 0.
15 3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
8/6/2019 siri1
20/83
8/6/2019 siri1
21/83
Deletion of an element from start of array:Consider the Array
15 3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Delete element 15 from start of array(i.e. from index 0)
Step 1: Move the deleted element(i.e. 15) from index 0 to any location like item.
15 Item
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Step2: Shift all the remaining values from current index location to immediate previous index location:Shift 3 from index 1 to index 0.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 10 from index 2 to index 1.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 7 from index 3 to index 2.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Shift 6 from index 4 to index 3.
3 10 7 6 Element Values
0 1 2 3 4 Index of Elements
Now this is final state of array after deletion.
8/6/2019 siri1
22/83
8/6/2019 siri1
23/83
8/6/2019 siri1
24/83
8/6/2019 siri1
25/83
Insertion of an element at starting of the list
Step 1: Create a new node with the element value 13 in information part
Step 2: Update the link value of new node with head value(address of node having
element 13).
Step 3: Update the head value with the address of new node.
Now recently inserted node will be First Node for new list.
8/6/2019 siri1
26/83
Insertion of an element at end of the list
Step 1: Create a new node with the element value 35 in information part.
Step 2: Update the link value of recently inserted node with the link value of previous last
node(which is NULL in this case).
Step 3: Update the link value of previous last node with the address of new node.
Now recently inserted node will be Last Node for new list.
8/6/2019 siri1
27/83
Insertion of an element in the middle of the list
Step 1: Create a new node with the element value 35 in information part.
Step 2: Update the link value of new node with the link value of node having element
value 25(which is address of 55 in this case).
Step 3: Update the link value of node having value 25 with the address of new node.
No modification in first and last node positions.
8/6/2019 siri1
28/83
8/6/2019 siri1
29/83
Deletion of an element from end of the list
Node to be deleted is having 32 value in this case.
Step 1: Update link value of the node having value 55 with link value of Last node(which
is NULL in this case).
Step 2: Remove the element 32 from the list.
Now node having value 55 will be last node of new list.
8/6/2019 siri1
30/83
8/6/2019 siri1
31/83
8/6/2019 siri1
32/83
8/6/2019 siri1
33/83
8/6/2019 siri1
34/83
8/6/2019 siri1
35/83
8/6/2019 siri1
36/83
8/6/2019 siri1
37/83
8/6/2019 siri1
38/83
8/6/2019 siri1
39/83
8/6/2019 siri1
40/83
8/6/2019 siri1
41/83
8/6/2019 siri1
42/83
8/6/2019 siri1
43/83
8/6/2019 siri1
44/83
8/6/2019 siri1
45/83
8/6/2019 siri1
46/83
8/6/2019 siri1
47/83
8/6/2019 siri1
48/8348
8/6/2019 siri1
49/83
8/6/2019 siri1
50/83
8/6/2019 siri1
51/83
8/6/2019 siri1
52/83
8/6/2019 siri1
53/83
8/6/2019 siri1
54/83
8/6/2019 siri1
55/83
8/6/2019 siri1
56/83
8/6/2019 siri1
57/83
8/6/2019 siri1
58/83
8/6/2019 siri1
59/83
8/6/2019 siri1
60/83
8/6/2019 siri1
61/83
8/6/2019 siri1
62/83
8/6/2019 siri1
63/83
8/6/2019 siri1
64/83
8/6/2019 siri1
65/83
8/6/2019 siri1
66/83
8/6/2019 siri1
67/83
8/6/2019 siri1
68/83
8/6/2019 siri1
69/83
8/6/2019 siri1
70/83
8/6/2019 siri1
71/83
8/6/2019 siri1
72/83
8/6/2019 siri1
73/83
8/6/2019 siri1
74/8374
8/6/2019 siri1
75/8375
8/6/2019 siri1
76/83
8/6/2019 siri1
77/83
8/6/2019 siri1
78/83
8/6/2019 siri1
79/8379
8/6/2019 siri1
80/8380
8/6/2019 siri1
81/8381
8/6/2019 siri1
82/8382
8/6/2019 siri1
83/83