Module 8 – Data Structures
Data Structures are a specialised format for organising, retrieving and
storing data. They are used to perform DATA PROCESSING OPERATIONS.
These include:
1. Insert data
2. Delete data
3. Display data
4. Search data
5. Sort data
6. Traverse data
7. Edit data
Types of Data Structures:
1. Linear List (aka ArrayList)
2. Stack
3. Queue
4. Arrays (primitive Array(1-d, 2-d))
5. Linked List
6. Binary Tree
STACK
- Is a temporary memory store
- It works in the LIFO principle
- It uses a stack pointer to point to the last item entered on stack
- It uses the mnemonic PUSH & POP to insert data & delete
- Implements the PUSH & POP algorithm using an array
Uses of stack:
1. Calling of subroutines
2. RPN – Reverse Polish Notation
3. Interrupt handling
QUEUE
- Works on the FIFO principle
- It makes use of 2 pointers
o Stack pointer – points to the first item entered in queue
o Stop pointer – points to the last item entered on queue
- The term used to add an item on queue is INSERT
- The term used to remove an item on queue is DELETE
- Two different types of queues
o Linear queue
o Circular queue
- Implement the algorithms of INSERT & DELETE using an Array.
Insert Algorithm:
1. Linear Queue: start_ptr = 1
Stop_ptr = MAX
-Queue is full-
2. Circular queue: start_ptr + 1;
-Queue id full-