CSC148 Exam Study Questions with
Complete solutions (A Graded)
Non-empty tree - ANSWER Has a root value that is not none connected to 0 or
more subtrees
Leaf - ANSWER Value with no subtrees
Height - ANSWER The longest path between a root and a leaf
Children - ANSWER Nodes that are directly connected to the node above
Descendant - ANSWER All of the subtrees and the subtrees of subtrees of a node
Parent - ANSWER The node directly above
Binary Search Tree - ANSWER A binary tree with the property that for all parent
nodes, the left subtree contains only values less than the parent, and the right
subtree contains only values greater than the parent.
Expression trees - ANSWER A tree which is used for evaluating expressions in
python
, Expr class - ANSWER An abstract superclass for all expression tree expressions
Num class - ANSWER An expression for a numeric constant
BinOp class - ANSWER An expression for a binary operation such as + or *
Uses left, operator, right
Quick Sort - ANSWER Sorts based on a pivot. Anything smaller goes to one list
and anything bigger goes to the other list. It does this recursively
Parameter - ANSWER Variables in a functions parentheses
Argument - ANSWER What we put in the parentheses when we are calling
a function
Local Variable - ANSWER Variables defined within a function
Method - ANSWER A function within a class
Function - ANSWER Not within a class
Type contract - ANSWER The expected type for a variable
precondition - ANSWER Any property that the function must satisfy to ensure that
the function works as described
Complete solutions (A Graded)
Non-empty tree - ANSWER Has a root value that is not none connected to 0 or
more subtrees
Leaf - ANSWER Value with no subtrees
Height - ANSWER The longest path between a root and a leaf
Children - ANSWER Nodes that are directly connected to the node above
Descendant - ANSWER All of the subtrees and the subtrees of subtrees of a node
Parent - ANSWER The node directly above
Binary Search Tree - ANSWER A binary tree with the property that for all parent
nodes, the left subtree contains only values less than the parent, and the right
subtree contains only values greater than the parent.
Expression trees - ANSWER A tree which is used for evaluating expressions in
python
, Expr class - ANSWER An abstract superclass for all expression tree expressions
Num class - ANSWER An expression for a numeric constant
BinOp class - ANSWER An expression for a binary operation such as + or *
Uses left, operator, right
Quick Sort - ANSWER Sorts based on a pivot. Anything smaller goes to one list
and anything bigger goes to the other list. It does this recursively
Parameter - ANSWER Variables in a functions parentheses
Argument - ANSWER What we put in the parentheses when we are calling
a function
Local Variable - ANSWER Variables defined within a function
Method - ANSWER A function within a class
Function - ANSWER Not within a class
Type contract - ANSWER The expected type for a variable
precondition - ANSWER Any property that the function must satisfy to ensure that
the function works as described