Back to marketplace

Algorithms for the main data structures

No description yet. This curated deck is ready for daily study.

Total cards: 14•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (14)

#1
Front (Question)

Are stacks FIFO or FILO?

Back (Answer)

FILO

#2
Front (Question)

Which function adds an item to a stack?

Back (Answer)

Push

#3
Front (Question)

Which function removes an element from a stack?

Back (Answer)

Pop

#4
Front (Question)

What is the significance of the back pointer in the array representation of a queue?

Back (Answer)

Holds the location of the next available space in the queue

#5
Front (Question)

Which function returns an item at the front of a queue without removing it?

Back (Answer)

Peek

#6
Front (Question)

What is the purpose of the front pointer in the array representation of a queue?

Back (Answer)

Points to the space containing the first item in the queue

#7
Front (Question)

What value is the top pointer initialised to in the array representation of a stack?

Back (Answer)

-1

#8
Front (Question)

Give pseudocode for the two functions which add new elements to stacks and queues

Back (Answer)

Stacks: push(element) top += 1 A[top] = element Queues: enqueue(element) A[back] = element back += 1

#9
Front (Question)

Which function returns the item at the top of a stack without removing it?

Back (Answer)

Peek

#10
Front (Question)

What is a linked list?

Back (Answer)

• Composed of nodes, each of which has a pointer to the next item in the list • First item in a list is referred to as the head and the last as the tail

#11
Front (Question)

What is a tree?

Back (Answer)

• Formed from nodes and edges • Cannot contain cycles and aren’t directed • Useful as a data structure because they can be traversed

#12
Front (Question)

What is meant by depth first (post-order) traversal?

Back (Answer)

• 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. • If there are no child nodes, the algorithm visits the current node, outputting the value of the node before backtracking to the next node on the stack and moving right

#13
Front (Question)

What is meany by breadth-first?

Back (Answer)

• 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 (uses a queue) • E.g. 5,3,8,2,4

#14
Front (Question)

What is meant by pre/post/in-order?

Back (Answer)

• Post-order: line passes to the right of the nodes • Pre-order: line passes to the left of the nodes • In-order: line passes under the nodes