Exam 17: Tree Structures

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Given the Node class (partially shown below), select an expression to complete the isLeaf method, which is designed to return true if the node is a leaf, false otherwise. Given the Node class (partially shown below), select an expression to complete the isLeaf method, which is designed to return true if the node is a leaf, false otherwise.

Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
Verified

A

What is the efficiency of locating an element in a red-black tree?

Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
Verified

D

Consider the following binary search tree diagram: Consider the following binary search tree diagram:   Consider the following addNode method for inserting a newNode into a binary search tree: public void addNode(Node newNode) { int comp = newnode.data.compareTo(data); if (comp < 0) { if (left == null) {left = newNode;} else { left.addNode(newNode); } } else { if (right == null) {right = newNode;} else { right.addNode(newNode); } } } Which of the following trees represents the correct result after inserting element T, calling addNode on the root of the tree?   Consider the following addNode method for inserting a newNode into a binary search tree: public void addNode(Node newNode) { int comp = newnode.data.compareTo(data); if (comp < 0) { if (left == null) {left = newNode;} else { left.addNode(newNode); } } else { if (right == null) {right = newNode;} else { right.addNode(newNode); } } } Which of the following trees represents the correct result after inserting element T, calling addNode on the root of the tree? Consider the following binary search tree diagram:   Consider the following addNode method for inserting a newNode into a binary search tree: public void addNode(Node newNode) { int comp = newnode.data.compareTo(data); if (comp < 0) { if (left == null) {left = newNode;} else { left.addNode(newNode); } } else { if (right == null) {right = newNode;} else { right.addNode(newNode); } } } Which of the following trees represents the correct result after inserting element T, calling addNode on the root of the tree?

Free
(Multiple Choice)
4.9/5
(32)
Correct Answer:
Verified

A

Consider the following tree diagrams: Consider the following tree diagrams:   Which are binary search trees? Which are binary search trees?

(Multiple Choice)
4.8/5
(39)

What are the differences between preorder, postorder, and inorder traversals?

(Multiple Choice)
4.9/5
(32)

What is the efficiency of the heapsort algorithm?

(Multiple Choice)
4.8/5
(29)

Consider the following binary search tree: Consider the following binary search tree:   Which of the following sequences correctly represents breadth-first traversal of this tree? Which of the following sequences correctly represents breadth-first traversal of this tree?

(Multiple Choice)
4.8/5
(46)

Consider the following tree diagram: Consider the following tree diagram:   Which of the following statements is NOT correct? Which of the following statements is NOT correct?

(Multiple Choice)
5.0/5
(43)

A binary tree of height h can have up to ____ nodes.

(Multiple Choice)
4.7/5
(40)

What is the efficiency of removing an element from a red-black tree?

(Multiple Choice)
4.8/5
(36)

Which of the following statements about a heap is NOT correct?

(Multiple Choice)
4.8/5
(31)

Consider the following tree diagram: Consider the following tree diagram:   What is the size of the subtree with root R? What is the size of the subtree with root R?

(Multiple Choice)
4.7/5
(42)

Removing an element from a balanced binary search tree takes ____ time.

(Multiple Choice)
4.8/5
(31)

Consider the following tree diagram: Consider the following tree diagram:   Which of the following nodes are interior nodes? Which of the following nodes are interior nodes?

(Multiple Choice)
4.9/5
(40)

The height of a tree can be obtained by recursively computing the heights of its subtrees, while keeping track of the height of the deepest subtree.Given the Node class (partially shown below), select an expression to complete the recursive method height, which is designed to return the height of the tree rooted at a node. The height of a tree can be obtained by recursively computing the heights of its subtrees, while keeping track of the height of the deepest subtree.Given the Node class (partially shown below), select an expression to complete the recursive method height, which is designed to return the height of the tree rooted at a node.

(Multiple Choice)
5.0/5
(43)

Adding an element to a balanced binary search tree takes ____ time.

(Multiple Choice)
4.9/5
(37)

You wish to traverse a binary search tree using postorder traversal.Arrange the following actions in the correct order to accomplish this. i.Print the right subtree recursively II.Print the root III.Print the left subtree recursively

(Multiple Choice)
4.9/5
(41)

Locating an element in an unbalanced binary search tree takes ____ time.

(Multiple Choice)
4.9/5
(42)

Consider the following tree diagram: Consider the following tree diagram:   Which of the following statements is NOT correct? Which of the following statements is NOT correct?

(Multiple Choice)
4.7/5
(38)

Which of the following is a correct statement about red-black trees?

(Multiple Choice)
4.7/5
(29)
Showing 1 - 20 of 102
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)