Paper 2 ADT
Paper 2 ADT
9618
ABSTRACT DATATYPE
Abstract Datatype
STACK
Stacks
QUEUE
Queue
A list containing several items operating on
the first in first out principle (FIFO).
The first item added is the first item remove
from the queue
In queue the data is added from the rear end
by using the EndPointer and removed from
the front by using the StartPointer
Enqueue("Taha")
Enqueue("Ali")
Enqueue("Amjad")
Enqueue("Bano")
Dequeue()
Dequeue()
Enqueue("Qasim")
Linear Vs Circular
LINKED LIST
Ordered Linked List And Unordered Linked List
A 5 C 9
2 7
B 7 D -1
9
5
How To Insert A Node In A Linked List
Check for a free node in a linked list
Search for correct position
Assign the Value B to the first node in free list
Pointer from B will be changed to point towards C
Pointer from A will point towards B
Start Pointer in free list will move to point to next
free node
Linked List Deletion
S.P = 2
A 5 C 9
2 7
B 7 D -1
9
5
How To Delete A Node In Linked List
Search for the node that you want to delete by
incrementing the pointer and start from the first node
If the node that you want to delete is the first node
then point the start pointer to next node in list
if the node that you want to delete is in the middle
than you would change the pointer value of the
previous node and point it to next node and point the
free list pointer towards the node removed