Algorithms for the Main Data Structures Flashcards
What is a Stack
A Data Strcuture that operates on a first in, last out bias
What are the Stack Operations
What is a Queue
A datastructure that opperates on a First in First out Bais
What are the Queue Operations
What is a Linked List
- A linked list is composed of nodes, each of which has a pointer to the next item in the list
- If a node is referred to as N, the next node can be accessed using N.next
- The first item in a list is referred to as the head and the last as the tail
What are the Two types of Tree Traverses
- Depth first (Same as Post Order)
- Breadth first
What is a Depth first Traversal
- Depth first search goes as far down into the tree as possible before backtracking
- The algorithm uses a stack and goes to the left child node of the current node when it can
- If there is no left child then the algorithm goes to the right child
What is a Breadth first Traversal
- Starting from the left, breadth-first visits all children of the start node
- The algorithm then visits all nodes directly connected to each of those nodes in turn, continuing until every node has been visited
Describe the pseudocode for a Queue Enqueue
if(isFull() = True then
Print “The queue is full”
Else
rear = (rear+1) % maxSize
arrQueue[rear] = newValue
size = size + 1
Endif
End function
Describe the pseudocode for a Queue Dequeue
int item
if(isEmpty()) then
Print “The queue is empty”
Else
item = arrQueue[front]
front = (front+1) % maxSize
size = size -1
Endif
End function