Deck 6: Trees

Full screen (f)
exit full mode
Question
The node at the top of a tree is called its ____________________.
Use Space or
up arrow
down arrow
to flip the card.
Question
The links from a node to its successors care called ____________________.
Question
The predessor of a node is called its ____________________.
Question
Nodes that have the same parent are ____________________.
Question
You declare that an object is serializable by adding the declaration ____________________.
Question
Leaf nodes are also known as ____________________ nodes.
Question
The ____________________ is the number of nodes in the longest path from the root node to a leaf node.
Question
The ____________________ is used to implement a priority queue.
Question
A(n) ____________________ is a data structure in which only the highest-priority item is accessible.
Question
The ____________________ of a node is a measure of its distance from the root.
Question
Removal from a heap is always from the bottom.
Question
If node A is the parent of node B, which is the parent of node C, node A is node C's ancestor, and node C is node A's descendant.
Question
If node n is not the root of tree T, its level is 1 + the level of its parent.
Question
Parentheses are not stored in a binary tree, because the tree structure dictates the order of operator evaluation.
Question
Using Huffman codes to encode text files should give you files with more bits than you would get using other codes.
Question
A set of nodes T is a binary search tree ____.

A) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary search trees and the value in the root node of T is greater than all values in TL and is less than all values in TR.
B) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary trees.
C) if T is empty and its height is 0
D) if T is not empty, its height height is the maximum depth of its nodes.
Question
Searching a binary search tree is a(n) ____ process.

A) O(n)
B) O(log n)
C) O(1)
D) O(log2n)
Question
Which of the following is the preorder traversal of a binary tree?

A) Traverse TL, visit root node, traverse TR.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
Question
Which of the following is the postorder traversal of of a binary tree?

A) Traverse TL, visit root node, visit root node.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
Question
In a priority queue, the poll method first saves the item at the top of the heap.
Question
Complete the following algorithm which recursively inserts an item into a binary search tree.
If the root is null
Replace empty tree with a new tree with the item at the root and return true.
Else if the item is equal to root.data
____
Else if the item is less than root.data
Recursively insert the item in the left subtree.
Else
Recursively insert the item in the right subtree.

A) The item is not in the tree; return false.
B) The item is already in the tree; return false.
C) The item is not in the tree; return true.
D) The item is already in the tree; return true.
Question
Which of the following is the algorithm for insertion in a heap?

A) Insert the new item in the next position at the bottom of the heap.
while new item is not at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
B) Insert the new item in the next position at the top of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
C) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is larger that its parent
Swap the new item with its parent, moving the item up the heap.
D) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item down the heap.
Question
Insertion into and removal from a heap is ____.

A) O(n)
B) O(n2)
C) O(log n)
D) O(log2n)
Question
The following algorithm is a(n) ____ .
If the tree is empty
Return null (target is not found).
Else if the target matches the root node's data
Return the data stored at the root node.
Else if the target is less than the root node's data
Return the result of searching the left subtree of the root.
Else
Return the result of searching the right subtree of the root.

A) algorithm for removal from a heap
B) algorithm for insertion into a heap
C) algoithm for insertion intoa a binary tree
D) recursive algorithm for searching a binary tree
Question
Expanding and contracting arrays are ____ operations.

A) O(n).
B) O(log n)
C) O(n)
D) O(n2)
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Trees
1
The node at the top of a tree is called its ____________________.
root
2
The links from a node to its successors care called ____________________.
branches
3
The predessor of a node is called its ____________________.
parent
4
Nodes that have the same parent are ____________________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
You declare that an object is serializable by adding the declaration ____________________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
Leaf nodes are also known as ____________________ nodes.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
The ____________________ is the number of nodes in the longest path from the root node to a leaf node.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
The ____________________ is used to implement a priority queue.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
A(n) ____________________ is a data structure in which only the highest-priority item is accessible.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
The ____________________ of a node is a measure of its distance from the root.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
Removal from a heap is always from the bottom.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
If node A is the parent of node B, which is the parent of node C, node A is node C's ancestor, and node C is node A's descendant.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
If node n is not the root of tree T, its level is 1 + the level of its parent.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
Parentheses are not stored in a binary tree, because the tree structure dictates the order of operator evaluation.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
Using Huffman codes to encode text files should give you files with more bits than you would get using other codes.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
A set of nodes T is a binary search tree ____.

A) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary search trees and the value in the root node of T is greater than all values in TL and is less than all values in TR.
B) if T is not empty, its root node has two subtrees, TL and TR, such that TL and TR are binary trees.
C) if T is empty and its height is 0
D) if T is not empty, its height height is the maximum depth of its nodes.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
Searching a binary search tree is a(n) ____ process.

A) O(n)
B) O(log n)
C) O(1)
D) O(log2n)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following is the preorder traversal of a binary tree?

A) Traverse TL, visit root node, traverse TR.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is the postorder traversal of of a binary tree?

A) Traverse TL, visit root node, visit root node.
B) Visit root node, traverse TL, traverse TR.
C) Traverse TL, traverse TR, visit root node.
D) Visit root node, traverse TR, traverse TL.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
In a priority queue, the poll method first saves the item at the top of the heap.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
Complete the following algorithm which recursively inserts an item into a binary search tree.
If the root is null
Replace empty tree with a new tree with the item at the root and return true.
Else if the item is equal to root.data
____
Else if the item is less than root.data
Recursively insert the item in the left subtree.
Else
Recursively insert the item in the right subtree.

A) The item is not in the tree; return false.
B) The item is already in the tree; return false.
C) The item is not in the tree; return true.
D) The item is already in the tree; return true.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following is the algorithm for insertion in a heap?

A) Insert the new item in the next position at the bottom of the heap.
while new item is not at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
B) Insert the new item in the next position at the top of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item up the heap.
C) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is larger that its parent
Swap the new item with its parent, moving the item up the heap.
D) Insert the new item in the next position at the bottom of the heap.
while new item is at the root and new item is smaller that its parent
Swap the new item with its parent, moving the item down the heap.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
Insertion into and removal from a heap is ____.

A) O(n)
B) O(n2)
C) O(log n)
D) O(log2n)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
The following algorithm is a(n) ____ .
If the tree is empty
Return null (target is not found).
Else if the target matches the root node's data
Return the data stored at the root node.
Else if the target is less than the root node's data
Return the result of searching the left subtree of the root.
Else
Return the result of searching the right subtree of the root.

A) algorithm for removal from a heap
B) algorithm for insertion into a heap
C) algoithm for insertion intoa a binary tree
D) recursive algorithm for searching a binary tree
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
Expanding and contracting arrays are ____ operations.

A) O(n).
B) O(log n)
C) O(n)
D) O(n2)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.