Consider the following algorithm mystery(root, x) { b = true if (root != null) { b = b && mystery (root.right, x) if (x.size()>0 && root.element > x.get(x.size() -1)) return false x.addLast(root.element) b = b && mystery (root.left, x) } return b } Which of the following statements is true? (Select all that apply) Question 8 options: If called with input a reference to the root of a BST and an empty list, after the execution of the method the list will contain all the element of the tree in descending order. If called with input a reference to the root of a binary tree and an empty list, the method returns whether or not this tree is a BST. If called with input a reference to the root of a binary tree and an empty list, the method returns whether or not this tree is a max heap. If called with input a reference to the root of a min heap and an empty list, after the execution of the method the list will contain all the elements of the tree in descending order.
Consider the following
mystery(root, x) {
b = true
if (root != null) {
b = b && mystery (root.right, x)
if (x.size()>0 && root.element > x.get(x.size() -1))
return false
x.addLast(root.element)
b = b && mystery (root.left, x)
}
return b
}
Which of the following statements is true? (Select all that apply)
Question 8 options:
|
If called with input a reference to the root of a BST and an empty list, after the execution of the method the list will contain all the element of the tree in descending order. |
|
If called with input a reference to the root of a binary tree and an empty list, the method returns whether or not this tree is a BST. |
|
If called with input a reference to the root of a binary tree and an empty list, the method returns whether or not this tree is a max heap. |
|
If called with input a reference to the root of a min heap and an empty list, after the execution of the method the list will contain all the elements of the tree in descending order. |
Step by step
Solved in 3 steps