CP 114 W07 Midterm Review
wluphi.org
Definitions
Auxiliary function
Recursive function called by parent function. Usually requiring more or different
parameters than the parent.
Sum(n) can have an auxiliary
function Sum(m,n)
which sums integers from 1 to
n recursively. Sum(n) itself cannot do going up recursion because it has a fixed
left limit
The recursive function Find(tree, element) would call
find_aux(tree.root,
element).
Find_aux(node, element) would then call find_aux(node.left/node.right,
element)
Call Tree
A call tree shows how function calls are generated. Descendents of a function call
are further recursive calls. Calls in the tree with no descendants involve
evaluations of a base case.
eg. Fibonacci: F(n)= F(n-1) + F(n-2); F(1)=F(0)=1
F(3)
/ \
F(2) F(1)
/ \
F(1) F(0)
Big- O Notation/ Complexity Classes
F(x)>=c*g(x)
FIFO
First in, First out. The first element into an ADT is the first element out.
The nature of Queues
LIFO
The last item inserted is the first item removed.
The nature of Stacks

** Subscribe** to view the full document.

Abstract Data type
A collection of data entities along with functions defined on those entities.
Example: stack ADT auxiliary function-a function which accompanies another
function and does a task for it. We often used it in the context of recursion.
Linked List
See Data Structures
→
Linked List
String of students in lab with names (data) and pointers to next node
(arm/hand/finger pointing)
Stack
See Data Structures
→
Stack
Can of Pringles chips
Queue
See Data Structures
→
Queue
Line-up at Time Horton’s.
Priority Queue
See Data Structures
→
Priority Queue
Hospital
emergency room waiting room in which the sickest patients are seen
first, i.e. patients of highest priority are those that are the sickest.
Binary Search Trees
See Data Structures
→
BST
Level (of a tree)
Level (of a tree)-(recursive definition) the root has level zero. The nodes at level i
are the children of the nodes at level i-1.
x Level 0
/ \
x x Level 1
Internal Node
A node that has children
e
/ \
z
w
/ \ / \
x y d a

/ \
b
c
In this example, w is an internal node.
A note on Data Abstraction
Consider ADTs to be similar to a bank machine. When you put money in, it takes
the money from you and tells you that you have more in your account. When you
take money out, it gives you cash, and tells you that you have less in your
account. When you use the machine, you ask it for $20, take the bill from the slot,
and put it in your pocket. What you don’t do is tell it to check your balance to see

** Subscribe** to view the full document.

- Fall '13
- sta