Introduction to Programming Using Python, Y. Daniel Liang

This quiz is for students to practice. A large number of additional quiz is available for instructors from the Instructor's Resource Website.

Chapter 19 Binary Search Trees


Section 19.2 Binary Trees
19.1  A __________ (with no duplicate elements) has the property that for every node in the tree the value of any node in its left subtree is less than the value of the node and the value of any node in its right subtree is greater than the value of the node.
A. binary tree
B. binary search tree
C. list
D. linked list

19.2  The ________ of a path is the number of the edges in the path.
A. length
B. depth
C. height
D. degree

19.3  The _______ of a node is the length of the path from the root to the node.
A. length
B. depth
C. height
D. degree

19.4  The _______ of a nonempty tree is the length of the path from the root node to its furthest leaf + 1.
A. length
B. depth
C. height
D. degree

19.5  The ________ is to visit the left subtree of the current node first, then the current node itself, and finally the right subtree of the current node.
A. inorder traversal
B. preorder traversal
C. postorder traversal
D. breadth-first traversal

19.6  The _________ is to visit the left subtree of the current node first, then the right subtree of the current node, and finally the current node itself.
A. inorder traversal
B. preorder traversal
C. postorder traversal
D. breadth-first traversal

19.7  The _________ is to visit the current node first, then the left subtree of the current node, and finally the right subtree of the current node.
A. inorder traversal
B. preorder traversal
C. postorder traversal
D. breadth-first traversal

19.8  The _________ is to visit the nodes level by level. First visit the root, then all children of the root from left to right, then grandchildren of the root from left to right, and so on.
A. inorder traversal
B. preorder traversal
C. postorder traversal
D. breadth-first traversal

19.9  True or False? A new element is always inserted into a leaf node.
A. True
B. False

Section 19.3 Deleting Elements from a BST
19.10  The time complexity for searching an element in a binary search tree is _______.
A. O(n)
B. O(logn)
C. O(nlogn)
D. O(n^2)

19.11  The time complexity for inserting an element into a binary search tree is _______.
A. O(n)
B. O(logn)
C. O(nlogn)
D. O(n^2)

19.12  The time complexity for deleing an element into a binary search tree is _______.
A. O(n)
B. O(logn)
C. O(nlogn)
D. O(n^2)