Professional Documents
Culture Documents
Question text
a.Indirect recursion
c.Nontail recursion
d.Tail recursion
Question 2
Question text
b. If this algorithm always replacing the key being deleted with its immediate predecessor, possibly
reducing the height of the left subtree and leaving the right subtree unaffected.
Question text
{read a character
else
a.oGnrnid
b.oGnrndo
c.oGnrniM
d.oGnrnio
Question 4
Question text
b.Searching one node in singly linked list without tail in the best case.
c.Inserting one node to the end of the singly linked list that has no tail.
Question 5
Question text
How many activation records are allocated when calculating Fibonacci(5) by calling recursion method?
a.25
b.9
c.41
d.15
Question 6
Question text
a.If all of its leaves are at the same level, then the binary tree is full.
c.If every proper subtree of a binary tree is full, then the tree itself must also be full.
d.If the binary tree has n nodes and height h, then h <= lg ( n + 1 )
Question 7
Question text
Consider the below AVL tree. Values in nodes are balance factors. h is height of sub trees of P and Q.
Assume that a node is removed from the left subtree of P and height of this subtree decreases 1. Select
true / false statement:
c.The balance is restored by one right rotation and one left rotation.
Question 8
Question text
a. The height of a Binary Search tree can be extended after deleting by merging.
b. The height of a Binary Search tree can be reduced after deleting by merging.
Question 9
Question text
Which of the following is an appropriate description concerning a binary search tree whose node values
are 17, 6, 19, 3, 22, and 32?
a.Any binary tree containing these values has a maximum depth of three (3).
c.No matter which value is placed at the root node, “3” cannot have a left child.
d.No matter which value is placed at the root node, “3” is always at the deepest level.
Question 10
Question text
e.An array
Question 11
Question text
Consider one AVL tree has a path of all zero balance factors. Assume that a new node has been
appended to the end of this path. Select correct/ incorrect statements:
a. All of them have to be updated.
Question 12
Question text
If the values of A, B, C and D are 2, 3, 4 and 5, respectively. Using stack, manually calculate the value of
the following postfix expressions: A B C + * D -
a.11
b.7
c.6
d.9
Question 13
Question text
a. All data must be put in an array before the tree can be created.
b. Tree rebalancing can be performed locally if only a portion of the tree is affected when changes are
required after an element is inserted into or deleted from the tree
a.a and b
b.a
c.b
d.Neither a nor b
Question 14
Question text
Specify the correct implementation of dequeue() method of a queue. This queue uses
java.util.LinkedList, here is pool, for storing data and the head of the list is treated as the head of the
queue. (Choose the most suitable one)
a.
Object dequeue()
return(pool.remove(pool.size()-1));
b.
void dequeue(Object x)
{ if (isEmpty()) return(null);
pool.remove(pool.size()-1);
c.
Object dequeue()
{ if (isEmpty()) return(null);
return(pool.removeLast());
}
d.
Object dequeue()
{ if (isEmpty()) return(null);
return(pool.removeFirst();
Question 15
Question text
Suppose we are implementing a stack using a singly linked list where the head of the list is treated as the
top of the stack.
Specify the correct implementation of push() method of the stack. (Choose the most suitable one)
a.
void push(Object x)
p.next = head;
head=p;
b.
void push(Object x)
p.next = head;
c.
void push(Object x)
{ Node p = new Node(x);
p.next = head;
head=p.next;
d.
void push(Object x)
p.next = null;
head=p;
Question 16
Question text
We implement the stack as a singly linked list and use AddtoHead() method of the linked list to
implement push() method. A top pointer of the stack is …
Question 17
Question text
a.Methods for processing doubly linked list are simpler than those of singly linked list.
d.The node which is deleted from the list will be claimed by the garbage collector.
Question 18
Question text
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): 6, 7, 3, 1, 2, 5, 8
a.6, 3, 7, 1, 5, 2, 8
b.6, 3, 7, 1, 5, 8, 2
c.6, 3, 1, 2, 5, 7, 8
d.6, 3, 7, 1, 2, 5, 8
Question 19
Question text
Linked lists allow easy insertion and deletion of information because such operations have a local impact
on the list.
a.False
b.True
Question 20
Question text
Consider the below AVL tree. Values in nodes are balance factors.
Assume that one new node is inserted into right sub tree of node Q. Select true / false statements:
d. The balance is restored by one left rotation and one right rotation.
Question 21
Question text
return odd(n-1);
return even(n-1);
Question 22
Question text
Question 23
Question text
Consider the statements related to deleteFromTail operation in the Singly Linked List:
b. Most time-consuming part of the operation is finding the next to last node.
Question 24
Question text
100 90 80 30 60 50 70 20 10
a.90 60 80 30 20 50 70 10
b.90 60 80 30 10 50 70 20
c.90 10 80 30 60 50 70 20
Question 25
Question text
d.The top-down level order traversals always visit the root first.
Question 26
Question text
d.Previous function calls are still open when the function calls itself and the activation records of these
previous calls still occupy space on the call stack.
Question 27
Question text
Priority queues can be implemented by using unordered linked list. In this case, which of the following
operations of the linked list is (are) used to enqueue an element?
a.Searching
c.Inserting
d.Deleting
Question 28
Question text
Question 29
Question text
In a binary search tree, certain null entries are replaced by special pointers which point to nodes higher
in the tree for traversal. These special pointers are called ……
a.Arc
b.Leaf
c.Non-terminal
d.Root
e.Thread
Question 30
Question text
Question 31
Question text
What is the complexity of inserting a node in a perfectly balanced tree for worst case?
a.O(nlgn)
b.O(lgn)
c.O( n )
Question 32
Question text
What is the complexity of reversing the order of the elements on a stack using two additional stacks?
a.O ( lgn )
b.O ( 1 )
c.O ( n2 )
d.O ( n )
Question 33
Question text
When the compiler compiles your program, how is a recursive call treated differently than a non-
recursive method call?
Question 34
Question text
Question 35
Not yet answered
Question text
a. Every node of a Singly Linked List has two reference fields, one to the predecessor and one to the
successor.
b. Every node of a Doubly Linked List has two reference fields, one to the predecessor and one to the
first node of the list.
Question 36
Question text
Question 37
Question text
In AVL tree, after a node has been deleted from the tree, case in which balance factors may be updated
from the parent of the deleted node up to the root:
c. deleted node has two children and deleteByCopying method is applied to delete this node.
d. deleted node has two children and deleteByMerging method is applied to delete this node.
a. a and b
b. a, b and d
c. a, b, c and d
d. c and d
Question 38
Question text
a. -1
b. 1
c.2
d.0
Question 39
Question text
a.110 80 100 50 30 70 90 40
b.110 30 100 50 80 70 90 40
c.110 80 100 50 40 70 90 30
Question 40
Question text
a) A recursive approach may be inefficient in many cases. If so, it can be replaced with a simple loop or a
stack-based approach.
b) Some value of its arguments causes a recursive method to return without calling itself. This is called
the ground case.
Question 41
Question text
Consider the below tree. Values in nodes are balance factors. h is height of sub trees of P and Q.
Assume that a new node is inserted into in the left subtree of Q and height of this subtree increases 1.
Select true / false statement:
d. The balance is restored by one right rotation and one left rotation.
Question 42
Question text
Question 43
Not yet answered
Question text
a.82 70 51 43 55 37 10 43 63 30 34
b.82 70 51 63 34 37 10 43 27 30 55
d.82 70 51 63 55 37 10 43 27 30 34
Question 44
Question text
Priority queues can be implemented by using unordered linkedlist. Which of the following operations is
(are) used to dequeue?
a.Deleting
b.Searching
Question 45
Question text
Which of the following operation in the doubly linked circular list can be done in O(1) time?
Question 46
Question text
Assume that in an array list implementation of a stack, pushing an element onto a full stack requires
allocating more memory. What is the complexity of pushing operation in this case?
a.O ( n )
c.O ( lgn )
d.O ( 1 )
e.O ( n2 )
Question 47
Question text
The top-down method of J. Williams is used to organize the following array as a heap.
8 14 12 7 16 21 9 18 17
a.21 18 16 17 8 12 9 7 14
b.21 18 12 17 16 8 9 7 14
c. 21 12 18 16 17 8 9 7 14
d. 21 12 16 9 8 16 17 14 7
Question 48
Question text
Suppose temp refers to a node in a linked list (using the SLLNode class with instance variables called info
and next). What boolean expression will be true when temp refers to the tail node of the list?
a. (temp == null)
b. (temp.info == null)
c. (temp.next != null)
d. (temp.next == null)
Question 49
Question text
b. The first node of the circular list has next field reference to the last node.