CSD_PT4_Tree
Search() method in binary search tree have the complexity is: A. O(n) B. O(n^2) C. O(log(n)) D. O(n log(n))
A
To implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left). An AVL tree is created using data :{10,90,5,1,8,0,2,9}. What is the balance factor of the node 10? Select one: A. -1 B. 2 C. 0 D. 1
A.
Following function: void f(int n) { if(n == -5) return; System.out.print(n%3); f(n-3); } What will happen if the statement f(9); is run? Select one: A. The operating system detects the infinite recursion because of the "repeated state". B. The run-time stack overflows, halting the program. C. The results are nondeterministic. D. The program keeps running until you press Ctrl-C.
B
Select the correct statement. Suppose T is a binary tree with 9 nodes. What is the minimum possible height of T? (Note: In a tree the height of root is 1) Select one: A. 3 B. 4 C. 5 D. 2
B
Specify the correct implementation of pre-order traverse algorithm for binary trees. Select one: A. void preOrder(Node p) { visit(p); preOrder(p.left); preOrder(p.right); } B. void preOrder(Node p) { if (p != null) { visit(p); preOrder(p.left); preOrder(p.right); } } C. void preOrder(Node p) { if (p == null) { visit(p); preOrder(p.left); preOrder(p.right); } } D. void preOrder(Node p) { if (p != null) { preOrder(p.left); visit(p); preOrder(p.right); } }
B
In a Heap tree Select one: A. Values in a node is greater than every value in left sub tree and smaller than right sub tree. B. Both of other conditions applies. C. Values in a node is greater than every value in children of it
C
Specify the correct implementation of in-order traverse algorithm for binary trees. Select one: A. void inOrder(Node p) { if (p == null) { inOrder(p.left); visit(p); inOrder(p.right); } } B. void inOrder(Node p) { inOrder(p.left); visit(p); inOrder(p.right); } C. void inOrder(Node p) { if (p != null) { inOrder(p.left); visit(p); inOrder(p.right); } } D. void inOrder(Node p) { if (p != null) { visit(p); inOrder(p.left); inOrder(p.right); } }
C
What is the breadth-first traversal of a tree below after deleting the node 6 by copying? Select one: A. 2, 1, 5, 4, 7, 9, 8 B. 5, 2, 7, 4, 1, 9, 8 C. 5, 2, 7, 1, 4, 9, 8 D. 2, 5, 7, 1, 4, 9, 8
C
What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially (suppose T is empty before insertion): 7, 8, 4, 0, 1, -1, 10, 24 Select one: A. 7, 4, 8, 0, 10, 1, -1, 24 B. -1, 0, 1, 4, 7, 8, 10, 24 C. 7, 4, 8, 0, 10, -1, 1, 24 D. 24, 10, 8, 7, 4, 1, 0, -1
C
Consider the binarySearch() function below: int binarySearch(int [] a, int x, int low, int high) { int t, k; if(low > high) return( -1); k = (low + high) / 2; if(a[k] == x) return(k); if(x<a[k]) return(binarySearch(a,x,low,high-1); else return(binarySearch(a,x,low+1,high); } Suppose the array a is given by the statement: int [] a = {2,4,6,8,10,12,14, 16}; For the call binarySearch(a,7,2, 5), how many calls to this function will be made, including the original call? Select one: A. 5 B. 2 C. 4 D. 3
D
Select the correct statement. (Note: full binary tree = proper binary tree = 2-tree) Select one: A. Every binary tree is either complete or full. B. Every full binary tree is also a complete binary tree. C. No binary tree is both complete and full. D. Every complete binary tree is also a full binary tree.
D
Specify the correct statement about a binary search tree(select the most suitable one). Select one: A. For better searching performance, a tree should be in back-bone shape. B. The main purpose of balancing a tree is to keep the tree in good shape. C. In a binary search tree, all the nodes that are left descendants of node A have key values greater than A; all the nodes that are A's right descendants have key values less than (or equal to) A. D. It is necessary to build a tree with optimized height to stimulate searching operation.
D
The height of a complete binary tree with n nodes is: A. nlog(n) B. nlog(n+1) C. log(n) D. log(n+1)
D
The in-order traverse of tree will yield a sorted listing of elements of tree in Select one: A. Binary trees B. None of others C. Heaps D. Binary search trees
D
In all binary trees, there are 2i nodes at level i. Select one: True False
F
State True or False: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa." Select one: False True
F
State True or False:"In a binary search tree, all the nodes that are left descendants of node A have key values greater than A; all the nodes that are A's right descendants have key values less than (or equal to) A." Select one: True False
F