Reading, Deleting and Sorting Files Algorithms
Stack – Insertion
Check to see if stack is full.
If the stack is full report an error and stop.
Increment the stack pointer.
Insert new data item into cell pointed to by the stack pointer and stop.
Stack – Deletion/ Reading
Check to see if the stack is empty.
If the stack is empty report an error and stop.
Copy data item in cell pointed to by the stack pointer.
Decrement the stack pointer and stop.
Queues – Insertion
Check to see if queue is full.
If the queue is full report an error and stop.
Insert new data item into cell pointed to by the head pointer.
Increment the head pointer and stop.
Queues – Deletion/ Reading
Check to see if the queue is empty.
If the queue is empty report error and stop.
Copy data item in cell pointed to by the tail pointer.
Increment tail pointer and stop.
Trees – Insertion
If tree is empty enter data item at root and stop.
Current node = root.
Repeat steps 4 and 5 until current node is null.
If new data item is less than value at current node go left else go right.
Current node = node reached (null if no node).
Create new node and enter data.
1. If n < 1 then report error, array is empty.
2. For i = 1 to n do
a. If DataArray[i] = X then return i and stop.
3. Report error, X is not in the array and stop.
1. While the list is not empty do
a. Find the mid-point cell in the current list.
b. If the value in this cell is the required value, return the cell position and stop.
c. If the value to be found is less than the value in the mid-point cell then
Make the search list the first half of the current search list
Else make the search list the second half of the current search list.
2. Report error, item not in the list.