You are on page 1of 8

Abstract data types : 

a collection of data and a set of operations on that data 


---------------------------------------------------------------------------------------------------------------------
----------
 Uses Last In, First Out (LIFO) principle – the first item added, will be the last to be removed  
 Items can be added to the stack (push) 
 Items can be removed from the stack (pop) 
 
Examples :  
 Memory management  
 Expression evaluation  
 Backtracking in recursion  
 
A stack uses two pointers :  
 A base pointer – points to the first item in the stack  
 A top pointer – points to the last item in the stack 
 
When the base and the top pointer are equal, there is only one item in the stack 
 
 
Stack Operations : 
 The value of basePointer always remains same during the stack operation 
 
 To set up a stack : 
 

 
 To push an item : 
 

 
 To pop an item : 
 

 
 As an array, stacks have a finite size and can be full (this condition must be allowed) 
---------------------------------------------------------------------------------------------------------------------
----------
 Follows the First In, First Out (FIFO) principle – the first item to be added is the first to be
removed  
 Items can be added to the queue (enqueue) 
 Items can be removed from the queue (dequeue) 
 
Examples : 
 Management of files sent to a printer  
 Buffers used with keyboards 
 Scheduling  
 
A queue uses two pointers :  
 A front pointer – that points to the first item in the queue  
 A rear pointer – that points to the last item in the queue 
 

 
Queue operations : 
 Value of frontPointer changes after dequeue 
 Value of rearPointer changes after enqueue 
 

 
 As an array, queues have a finite size and can be full (this condition must be allowed) 
 The items are removed from the front and added to the back 
 QUEUE IS MANAGED AS A CIRCULAR QUEUE 
 Both pointers, frontPointer and rearPointer are at the first element in the array (lower
bound) 
 
To set up a queue : 
 

 
To add item onto queue : 
 
 
To remove item from queue :  
 

 
---------------------------------------------------------------------------------------------------------------------
----------
 A list containing several items in which each item in the list points to the next item in the
list  
 A new item is always added to the start of the list  
 
 A linked list uses a start pointer that points to the first item in the linked list 
 Every item is stored together with a pointer to the next item. This is called a node 
 The last item in the linked list has a null pointer 
 
What is called a node?  
 

 A linked list can be implemented using two 1d arrays 


 One for items in the list, another for pointers to the next item in the list  
 Linked list can become full and this condition must be allowed 
 As items can be removed from the array, empty positions in the array must be managed as
empty linked list, usually called heap 
 
To set up linked list : 
 
 
Identifier table : 
 

 
Explain linked list  

You might also like