• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/120

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

120 Cards in this Set

  • Front
  • Back

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

7

Select the one FALSE statement about binary trees:

Every binary tree has at least one node.

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


Which statement is correct?

The tree is neither complete nor full.

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 5 and the second piece will have 7 through 11

Which statement is true for a B-tree?

All leaves are at the exact same depth.

Consider the tree at the following.  Which nodes are siblings with each other?

Consider the tree at the following. Which nodes are siblings with each other?

2 and 4; 3 and 5; 6 and 7.

Suppose that we have a tree where the left subtree contains 3000 nodes and the right subtree contains 100 nodes. For post-ordertraversal, how many nodes are processed before the root node?

3100

How many comparisons is needed to search for pear in the following search tree?

How many comparisons is needed to search for pear in the following search tree?

3

Which of the description of the erase_one function in section 10.5 is the most appropriate?

If target was in the bag, then one copy of target has been removed from the bag; otherwise the bag is unchanged. A true return value indicates that one copy was removed; false indicates that nothing was removed.

Here is an output from the tree-printing function for a tree of integers:

Here is an output from the tree-printing function for a tree of integers:

Consider the tree at the following. What is the depth of the tree?

Consider the tree at the following. What is the depth of the tree?

3

For the tree at the following, what additions will make the tree complete?

For the tree at the following, what additions will make the tree complete?

To make a complete tree, add a left and right child to node 3.

What is meant by loose insertion?

A loose insertion allows the top node of a subtree to temporarily hold one too many entries.

Add one entry, 15, to the following heap what will be the new heap?

Add one entry, 15, to the following heap what will be the new heap?

Which statement of the following is the most appropriate?

The STL includes a priority queue class as well as algorithms for building and manipulating heaps.

Which of the following description about B-tree (section 11.3) is the the most appropriate?

Each node in a B-tree may contain more than one entry.

Why is a stub useful?

It is useful for writing and testing functions one at a time.

Which of the following description about B-tree (section 11.3) is the the most appropriate?

The number of children for a nonleaf node in a B-tree is exactly one more than the number of entrie.

Start with an empty B-tree, with MINIMUM set to 1. Enter the integers 1 through 10. What would be the resulting tree?

what is the value of the following logarithm?log 10 100

2

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


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

15

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


What is the order of nodes visited using a pre-order traversal? (Ch10)

14 2 1 3 11 10 7 30 40

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40How many descendants does the root have?

8

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

Heaps are complete binary trees.

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

42

Look at the tree at the following, in what order are the letters printed for an in-order traversal?

Look at the tree at the following, in what order are the letters printed for an in-order traversal?

The in-order traversal prints O, L, R, A, G, T.

What is the depth of the node that contains me!?

What is the depth of the node that contains me!?

The node containing me! has a depth of two.

Suppose that we have a tree where the left subtree contains 3000 nodes and the right subtree contains 100 nodes. For in-order traversal, how many nodes are processed before the root node?

3000

What statement about the traversal methods for general trees where there is no limit to the number of children that a node may have is more accurate?

Pre-order and post-order make sense but in-order doesn’t for a general tree.

What is the depth of the tree at the following?

What is the depth of the tree at the following?

3

What would be the most appropriate description of the following declaration?private: Item data_field; tree_node *parent_ptr; tree_node *links[4];

It is a member variables for a node definition that could be used for a tree where each node has up to four children, and each node also has a pointer to its parent. The note stores the children pointers in an array of four pointers.

Why is it bad to insert nodes from smallest to largest in a binary search tree?

The nodes will be inserted into the bag from smallest to largest, resulting in a tree with a single path with only right children.

Which of the following is one of the heap storage rules?

The entry contained by a node is never less than the entries of the node’s children.

what is the value of the following logarithm?log 2 32

5

Which of the following description about B-tree (section 11.3) is the the most appropriate?

In a B-tree, the searcher must choose among more than just two possible children.

How are subtrees stored in the B-tree set implementation in the chapter 11?

Each subtree is stored as a set object. The parent of each subset stores pointers to the smaller set objects.

What are the worst-case time for adding, deleting, and searching in a B-tree?

All of them are O( log n ).

Why is a new entry to a heap initially placed at its location?

The reason is to maintain a complete binary tree

Suppose MINIMUM is 200 for a B-tree, what is the maximum number of children that a node may have?

The maximum number of children that a node may have is 401, although during an insertion, we may temporarily have a node with 402 children

Add 15 first, 11 second, 14 third, 12 fourth, and 13 fifth to the following heap what will be the new heap?

Add 15 first, 11 second, 14 third, 12 fourth, and 13 fifth to the following heap what will be the new heap?

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


How many children does the root have?

2

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40How many of the nodes have at least one sibling?

6

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

2

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

The depth of the tree.

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 tree at the following. Which nodes are leaves?

Consider the tree at the following. Which nodes are leaves?

3, 4, 6, and 7

Suppose that we have a tree where the left subtree contains 3000 nodes and the right subtree contains 100 nodes. For pre-order traversal, how many nodes are processed before the root node?

zero.

What is the base case for the recursive function tree_clear?

The base case is when the tree is empty (the root pointer is NULL).

Consider a complete binary tree with exactly 10,000 nodes, implemented with an array. Suppose that a node has its value stored in location 4999. Where is the value stored for this node’s parent?

The parent is stored at index 2499.

Consider the tree at the following, what is the order of the nodes processed in a post-order traversal?

Consider the tree at the following, what is the order of the nodes processed in a post-order traversal?

3, 6, 7, 5, 2, 4, 1

What statement of the following is the most appropriate?

Trees may be implemented with either fixed-sized arrays or dynamic data structures. An array is particularly appropriate for complete binary trees because of the conditions that require the nodes of a complete tree to occur in specific locations.

Consider a complete binary tree with exactly 10,000 nodes, implemented with an array. Suppose that a node has its value stored in location 4999. Where is the value stored for its left child?

The left child is stored at index 9999.

Suppose MINIMUM is 200 for a B-tree, what is the minimum number of children that a nonleaf, nonroot node may have?

The minimum number of children that a nonleaf, nonroot node may have is 201, although during a removal we may temporarily have a node with 200 children.

Which of the following description of the top function (section 11.2) is the the most appropriate?

Returns the highest priority item of the queue (without removing it). If there are several equally high priorities, the implementation may decide which one to return.

Which of the following is one of the heap storage rules?

The tree is a complete binary tree, so that every level except the deepest must contain as many nodes as possible; and at the deepest level, all the nodes are as far left as possible

Which statement of the following is the most appropriate?

The tree algorithms that we have seen for binary search trees, heaps, and B-trees all have worst-case time performance of O(d), where d is the depth of the tree.

How is a loose insertion eventually fixed?

The problem is fixed by splitting the node with too many entries. After the split, one new node contains the entries before the middle, another new node contains the entries after the middle, and the middle entry itself has been passed upward to a higher level.

Which of the following description of the pop function (section 11.2) is the the most appropriate?

Removes the highest priority item of the priority queue.

Which statement of the following is the most appropriate?

The depth of a heap or B-tree is never more than O(log n), where n is the number of nodes. Hence, the operations on these structures are also O(log n).

Suppose MINIMUM is 200 for a B-tree, what is the maximum number of entries that a node may contain?

The maximum number of entries that a node may contain is 400, although during an insertion we may temporarily have a node with 401 entries

Consider the binary_tree_node from page 486. Which expression indicates that t represents an empty tree?

(t == NULL)

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


What is the order of nodes visited using a post-order traversal?

1 3 2 7 10 40 30 11 14

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

8

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

log (base 2) of n

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

What statement of the following is the most appropriate?

Trees are a nonlinear structure, with many applications, including organizing information (such as taxonomy trees) and implementing an efficient version of the bag class (using binary search trees).

What statement is the most appropriate for the big square of the following tree?

The big square include all nodes that are descendants of Mom node.

Look at the tree at the following, in what order are the numbers printed for a post-order traversal?

Look at the tree at the following, in what order are the numbers printed for a post-order traversal?

The post-order traversal prints 13, 9, 53, 17, 19, 7, 4, 11, 14.

What statement is the most appropriate for the following tree?

What statement is the most appropriate for the following tree?

It is a full and complete binary taxonomy tree with 16 animals.

What statement of the following is the most appropriate?

Operations on trees are good candidates for recursive thinking. This is because many tree operations include a step to process one or more subtrees, and this step is “a smaller version of the same problem.”

What statement of the following is the most appropriate?

Binary search trees are one common application of trees, which permit us to store a bag of ordered items in a manner where adding, deleting, and searching for entries is potentially much faster than with a linear structure.

What would be the binary search tree with the following words (inserted in this order): blueberry, peach, apricot, pear, cherry, mango, and papaya?

what is the value of the following logarithm?log 3 81

4

what is the value of the following logarithm?log 16 256

2

Suppose MINIMUM is 200 for a B-tree, what is the minimum number of entries that a nonroot node may have?

The minimum number of entries that a nonroot node may have is 200, although during a removal we may temporarily have a node with 199 entries

Where is a new entry to a heap initially placed?

A new entry to a heap is initially placed in the leftmost available location in the deepest level.

Which of the following description of the size function (section 11.2) is the the most appropriate?

Returns the number of items in the queue.

Which statement of the following is the most appropriate?

A B-tree is a tree for storing entries in a manner that follows six rules. The first two rules specify the minimum and maximum number of entries for each node. The third rule requires each node’s entries to be sorted from smallest to largest. Rules 4 and 5 indicate how many subtrees a nonleaf node must have and impose an order on the elements of the subtrees. The last rule requires each leaf to be at the same depth.

Remove the number 8  and then 3 from the following B-tree, what is the resulting tree after the removal?

Remove the number 8 and then 3 from the following B-tree, what is the resulting tree after the removal?

In the description of reheapification upward, we specified that the out-of-place entry must be swapped with ________________________.

its parent with a less value, or when it reaches the root.

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40


What is the value stored in the parent node of the node containing 30?

11

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40What is the order of nodes visited using an in-order traversal?

1 2 3 14 7 10 11 40 30

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]

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

Select the true statement about the worst-case time for operations on heaps.

Both insertion and removal are better than linear.

What statement of the following is the most appropriate?

A parameter of a function may be a function itself.

What is the depth of a tree with no nodes?

The depth of an empty tree is –1.

What would be the most appropriate description  of the following tree?

What would be the most appropriate description of the following tree?

It is representation of a small binary tree with three nodes containing integers. The tree has 10 in the root, 20 in the left child of the root, and 30 in theright child of the root

How many comparisons is needed to search for blueberry in the following search tree?

How many comparisons is needed to search for blueberry in the following search tree?

1

What is the depth of a tree with only a root node?

The depth of a tree with only a root is zero.

Look at the tree at the following, in what order are the numbers printed for a pre-order traversal?

Look at the tree at the following, in what order are the numbers printed for a pre-order traversal?

The pre-order traversal prints 14, 17, 9, 13, 53, 11, 4, 19, 7.

Consider the tree at the following, what is the output from this tree with the tree-printing function fromsection 10.4?

Consider the tree at the following, what is the output from this tree with the tree-printing function fromsection 10.4?

Start with an empty heap of integers, and enter the 10 numbers 1 through 10. Draw the resulting heap.

Suppose MINIMUM is 1000 for a B-tree, the tree has a root and one level of 1000 nodes below that. What is the minimum number of entries that this tree might have?

The root has 999 entries, and each of the 1000 nodes at the next level has minimum of 1000 entries. Therefore, the total minimum number of entries in the tree is 1,000,999 entries.

Which of the following is one of the heap storage rules?

A heap is a binary tree where the entries of the nodes can be compared with the less-than operator of a strict weak ordering.

what is the value of the following logarithm?log 37 1

0



What are two factors to consider when using external B-trees?

The total number of accesses to the secondary memory devices should be minimized. Also, ensure that each node is stored in a contiguous area of the disk.

Which statement of the following is the most appropriate?

A heap is a complete binary tree that follows the rule that the entry at any node is never less than any of its children’s entries. Heaps provide an efficient implementation of priority queues.

Remove four entries from the following heap what will be the new heap?

Remove four entries from the following heap what will be the new heap?

Remove three entries from the following heap what will be the new heap?

Remove three entries from the following heap what will be the new heap?

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

3

Select the one true statement.

A binary tree could be neithercomplete nor full

14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40What is the depth of the tree?

3

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.

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 a complete binary tree with exactly 10,000 nodes, implemented with an array. Suppose that a node has its value stored in location 4999. Where is the value stored for its right child?

There is no right child.

What statement is the most appropriate for the following f1 function? template int f1(binary_tree_node node){ int answer = 0; if (node->left( )!= NULL) ++answer; if (node->right( )!= NULL) ++answer; eturn answer;}


The f1 function computes the number of children that a node has.

What statement is the most appropriate for the following tree?

What statement is the most appropriate for the following tree?

It is a neither complete nor full binary tree with 12 nodes. The root is circled, and each leaf has an asterisk. There are two nodes that are siblings, and they are connected with a wiggly line. All of the ancestors of one of the leaves are shaded.

How many comparisons is needed to search for orange in the following search tree?

How many comparisons is needed to search for orange in the following search tree?

5

Look at the tree at the following, in what order are the letters printed for a backward in-order traversal?

Look at the tree at the following, in what order are the letters printed for a backward in-order traversal?

The backward in-order traversal prints T, G, A, R, L, O.

What statement of the following is the most appropriate?

A tree traversal consists of processing a tree by applying some action to each node. Three common traversal methods—pre-order traversal, in-order traversal, and post-order traversal—differ only in the order in which the nodes are processed. A backward in-order traversal is a quick and convenient way to print the data from a tree in a readable format

What is the best statement about the following function, f1?


void f1 (int i){ int j; for (j = 0; j < i; ++j); cout << ‘*’; cout << endl;}

The f1 function prints a star.

What is a stub?

A stub is a function with a single line that simply prints the name of the function, indicating that it has been activated.

Which of the following description of the empty function (section 11.2) is the the most appropriate?

Returns true if the queue is empty (otherwise returns false).

what is the value of the following logarithm?log 5 125

3

Add 15 first, 11 second, and 14 third to the following heap what will be the new heap?

Add 15 first, 11 second, and 14 third to the following heap what will be the new heap?

Add 15 first, 11 second, 14 third, and 12 fourth to the following heap what will be the new heap?

Add 15 first, 11 second, 14 third, and 12 fourth to the following heap what will be the new heap?

Remove one entry from the following heap what will be the new heap?

Remove one entry from the following heap what will be the new heap?

Add 15 first and 11 second to the following heap what will be the new heap?

Add 15 first and 11 second to the following heap what will be the new heap?

After an item is removed from a heap, which item is placed in the root?

When an item is removed from a heap, the last entry of the deepest level is placed in the root.