26. 30 10 20
R = 5
F = 3 Insert Element at Front End
40 30 10 20
F = 2
R = 5
50 40 30 10 20
F = 1
R = 5
DOUBLE ENDED QUEUE
27. Insert Element at Front End
60 50 40 30 10 20
F = 0
R = 5
60 50 40 30 10 20 70
F = 9
R = 5
60 50 40 30 10 20 11 22 80 70
F = 6
R = 5 Queue is Full
DOUBLE ENDED QUEUE
29. DOUBLE ENDED QUEUE
10 20 30
R = 6
F = 4 Insert Element at Rear End
10 20 30 40
R = 7
F = 4
10 20 30 40 50 60
R = 9
F = 4
30. 70 10 20 30 40 50 60
R = 0
F = 4 Insert Element at Rear End
DOUBLE ENDED QUEUE
70 80 10 20 30 40 50 60
R = 1
F = 4
70 80 90 11 10 20 30 40 50 60
R = 3
F = 4
Queue is Full
31. Insertions and Deletions from both ends
I/P restricted
Input from only one end and Output from either end
O/P restricted
Input from either end and Output from only one end
DOUBLE ENDED QUEUE
33. struct Complex
{
int real;
int imaginary;
struct Complex * next
}
In main()
Complex *c;
c->next;
c->next->next;
SELF REFERENTIAL STRUCTURES
c 3+4i
next
-5+7i
next
2+5i
next
NULL
67. Double pointer
Pointer to previous Node
Pointer to Next Node
struct Node
{
int a;
struct Node * prev;
struct Node * next;
}
DOUBLY LINKED LIST
a
prev next
68. DOUBLY LINKED LIST
NULL 100 next
prev 200 next
prev 300 next
prev 400 next
prev 500 NULL
start
69. DOUBLY LINKED LIST (ADD AT
BEGINNING)
NULL 100 next
prev 200 next
prev 300 next
prev 400 next
prev 500 NULL
start
NULL 1000 NULL
nn
next
prev
s
start
s
71. DOUBLY LINKED LIST (ADD AT END)
NULL 100 next
prev 200 next
prev 300 next
prev 400 next
prev 500 NULL
start
NULL 1000 NULL
nn
s
t
t
t
t
t
next
prev
73. NULL 100 next
prev 200 next
prev 300 next
prev 400 NULL
start
NULL 1000 NULL
s
t
t
Position = 3
Count = 1
Count = 2
next
prev
DOUBLY LINKED LIST (ADD AT A
POSITION)
75. NULL 100 next
prev 200 next
prev 300 next
prev 400 NULL
start
NULL 1000 NULL
s
t
t
Before = 300
next
prev
DOUBLY LINKED LIST (ADD BEFORE)
t
pt=NULL
pt
pt
87. NULL 100 next
prev 200 next
prev 300 next
prev 400 NULL
start
s
DOUBLY LINKED LIST (DELETE AT A
POSITION)
t
pt=NULL
t
pt
t
pt
Position = 3
Count = 1
Count = 2
91. NULL 100 next
prev 200 next
prev 300 next
prev 400 NULL
start
s
DOUBLY LINKED LIST (DELETE BEFORE)
t
pt=NULL
t
pt
t
pt
Before = 400
ppt=NULL
ppt
pt
ppt
93. Array Linked List
Data elements are stored in contiguous
locations in memory.
New elements can be stored anywhere and a
reference is created for the new element
using pointers.
Array elements can be accessed randomly
using the array index.
Random accessing is not possible in linked
lists. The elements will have to be accessed
sequentially.
Insertion and Deletion operations are costlier
since the memory locations are consecutive
and fixed.
Insertion and Deletion operations are fast
and easy in a linked list.
Memory is allocated during the compile time
(Static memory allocation).
Memory is allocated during the run-time
(Dynamic memory allocation).