What would be output using a breadth-first traversal on the following tree?
Italy, France, Spain, Austria, Germany, Norway
Outputs the root node first
What would be output using a depth-first traversal on the following tree?
Austria, Germany, France, Norway, Spain, Italy
Root node is always last in depth-first (post-order)
Describe the steps involved in a breadth-first traversal + state the data structure used
Uses a queue data structure to perform the traversal
Describe the steps involved in a depth-first traversal + state the data structure used
Uses a stack data structure to perform the traversal
In what situation would a depth-first traversal be chosen over a breadth-first traversal?
Depth
Breadth
Keywords to describe a binary (search) tree
Draw this Binary Search Tree
What is the purpose of the root and free pointers in a binary search tree?
Root Pointer - Points to where the tree starts (root node)
Free Pointer - Points to where the next piece of data would be added in the array
Key words to describe a tree (multi-branch)
Write the pseudocode to push an item to a stack
Write the pseudocode to pop an item to a stack
Keywords to describe a queue
Write the pseudocode to dequeue an item to a queue
Write the pseudocode to enqueue an item to a queue
Describe the purpose of pointers in this queue
headPointer - Where the data will be removed from (dequeued)
tailPointer - Where the data will be added to (enqueued)
Give examples of where stacks and queues are used in computers
Queues - Used in print queues – New print jobs are added to the end of the queue. Jobs are processed from the front of the queue
Stack - Internet History – When you visit a site the last site is pushed to the stack. When you click back the last item is popped from the stack, and then loaded.
Keywords to describe a linked list
What are the pros and cons of a linked list?
(+) You can store multiple pointers without reordering the linked list
(+) Using pointers means that the linked list does not need to be store contiguously in memory
(-) Inefficient for searching as you must go through each node one at a time following the pointers (WHILE loop until ‘null’ is reached).
What would the pointers be to output this linked list in alphabetical order?
Start Pointer = 2
What types of edges can be used in a graph?
Edges in a directed graph only go in one direction. Undirected edges can go in both directions.
How do you differentiate between a tree and a graph?
Keywords to describe a stack