Chapter 10 / 11

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Suppose that we have implemented a priority queue by storing the items in a heap (using an array for the heap items). We are now executing a reheapification upward and the out-of-place node is at data[i] with priority given by data[i]. Which of the following boolean expressions is TRUE to indicate that the reheapification IS NOT YET DONE.

(i > 0) && (data[(i-1)/2] < data[i])

Consider the binary_tree_node from Section 10.3. Which expression indicates that t represents an empty tree?

(t == NULL)

There is a tree in the box at the top of this section. What is the order of nodes visited using an in-order traversal? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

1 2 3 14 7 10 11 40 30

There is a tree in the box at the top of this section. What is the order of nodes visited using a post-order traversal? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

1 3 2 7 10 40 30 11 14

There is a tree in the box at the top of this section. What is the value stored in the parent node of the node containing 30? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

11

Suppose you run a O(log n) algorithm with an input size of 1000 and the algorithm requires 110 operations. When you double the input size to 2000, the algorithm now requires 120 operations. What is your best guess for the number of operations required when you again double the input size to 4000?

130

There is a tree in the box at the top of this section. What is the order of nodes visited using a pre-order traversal? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

14 2 1 3 11 10 7 30 40

What is the minimum number of nodes in a full binary tree with depth 3?

15

Consider this binary search tree: 14 / \ 2 16 / \ 1 5 / 4 Suppose we remove the root, replacing it with something from the left subtree. What will be the new root?

2

How many recursive calls usually occur in the implementation of the tree_clear function for a binary tree?

2

There is a tree in the box at the top of this section. How many children does the root have? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

2

Suppose T is a binary tree with 14 nodes. What is the minimum possible depth of T?

3

There is a tree in the box at the top of this section. What is the depth of the tree? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

3

There is a tree in the box at the top of this section. How many leaves does it have? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

4

Suppose that a non-leaf node in a B-tree has 41 entries. How many children will this node have?

42

There is a tree in the box at the top of this section. How many of the nodes have at least one sibling? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

6

Suppose that a binary taxonomy tree includes 8 animals. What is the minimum number of NONLEAF nodes in the tree?

7

There is a tree in the box at the top of this section. How many descendants does the root have? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40

8

What is the minimum number of nodes in a complete binary tree with depth 3?

8

Which statement is true for a B-tree?

All leaves are at the exact same depth.

Suppose that X is a B-tree leaf containing 41 entries and having at least one sibling. Which statement is true?

Any sibling of X is also a leaf.

Select the true statement about the worst-case time for operations on heaps. A. Niether insertion nor removal is better than linear. B. Insertion is better than linear, but removal is not. C. Removal is better than linear, but insertion is not. D. Both insertion and removal are better than linear.

Both insertion and removal are better than linear.

Select the one FALSE statement about binary trees: A. Every binary tree has at least one node. B. Every non-empty tree has exactly one root node. C. Every node has at most two children. D. Every non-root node has exactly one parent.

Every binary tree has at least one node.

Select the one true statement. A. Every binary tree is either complete or full. B. Every complete binary tree is also a full binary tree. C. Every full binary tree is also a complete binary tree. D. No binary tree is both complete and full.

Every full binary tree is also a complete binary tree.

What feature of heaps allows them to be efficiently implemented using a partially filled array?

Heaps are complete binary trees.

Tree algorithms typically run in time O(d) . What is d?

The depth of the tree.

Suppose that a B-tree has MAXIMUM of 10 and that a node already contains the integers 1 through 10. If a new value, 11, is added to this node, the node will split into two pieces. What values will be in these two pieces?

The first piece will have 1 through 6 and the second piece will have 7 through 11.

Suppose that we have implemented a priority queue by storing the items in a heap. We are now executing a reheapification downward and the out-of-place node has priority of 42. The node's parent has a priority of 72, the left child has priority 52 and the node's right child has priority 62. Which statement best describes the status of the reheapification.

The next step will swap the out-of-place node with its right child.

Consider the binary tree in the box at the top of this section. Which statement is correct? A. The tree is neither complete nor full. B. The tree is complete but not full. C. The tree is full but not complete. D. The tree is both full and complete.

The tree is neither complete nor full.

If a heap is implemented using a partially filled array called data, and the array contains n elements (n > 0), where is the entry with the greatest value?

data[0]

Consider the node of a complete binary tree whose value is stored in data[i] for an array implementation. If this node has a right child, where will the right child's value be stored?

data[2*i + 2]

Which formula is the best approximation for the depth of a heap with n nodes?

log (base 2) of n


Kaugnay na mga set ng pag-aaral

084 Social Studies (Secondary) - General 2.0

View Set

chpt 13 psychology test study guide

View Set

Chapter 13: Abstract Classes and Interfaces

View Set

Art from China's Bronze Age and Cultural Innovations

View Set

Cyber 3100 Principles of Info Security Chapter 1

View Set

Nutrition exam 3 and final quizzes

View Set

Biomedical Technology 1 Final Review

View Set

The Unfinished Nation Chapter 14

View Set

Business Law - Chapter 7 LearnSmart

View Set

Insurance Chapter 4 Dwelling Policy

View Set