2021 p1 Flashcards
358164
bubble sort this into first second and 3rd pass
first: 351648
second: 315468
third: 134568
define binary tree
a rooted tree where each node has at most two child nodes
state the output for in-order transversal for E, H, I, Y, Q, B, C.
EIHCYBQ
recursive subroutine
s subroutine that calls itself
two components of a stack frame
local variables and parameters
procedural decomposition
breaking a problem into smaller sub-problems
steps in adding a record to a hash table
- apply hash function to calculate the hash value for the key .
- use the hash value to find the index in the hash table so that the new record could be stored.
- check if there is a record at the index. if yes, use a collision resolution technique.
- insert the new record at the index in the hash table and update the number of records in the hash table.
two advantages of RPN
easier for a computer to analyse
don’t need brackets so you don’t have to keep track of parentheses
how can a single stack be used to evaluate an RPN expression
- initialize an empty stack
- push values onto a stack from left hand side.
3.for each number in the expression; push it onto a stack. for each operator; pop the top two numbers off the stack. - after both have been processed, the stack should contain only one value, which is the result of the expression.
base case for a recursive sub routine
a scenario where a recursive subroutine does’nt call itself