You are on page 1of 24

Question 1

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the following chain of method calls:

f() -> f1() -> f2() -> f3() -> f()

What is this kind of recursion?

a.Indirect recursion

b.None of the others

c.Nontail recursion

d.Tail recursion

Question 2

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Select true / false statement in regarding to Deleting by copying:

a. This algorithm always increase the height of the tree.

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.

a. a and b are true

b. a and b are false

c.a is true and b is false

d.a is false and b is true


Question 3

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the following pseudocode:

declare a stack of characters

while(there are more characters in the word to read)

{read a character

if a character is '*' then

pop and write the popped character to the screen

else

push the character into the stack

What is written to the screen for the input " Go**odMorn**in***g" ?

a.oGnrnid

b.oGnrndo

c.oGnrniM

d.oGnrnio

Question 4

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following operations always take O( 1)time:


a.Deleting one node from the begin of doubly linked list

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.

d.Deleting one any node in a doubly linked list.

Question 5

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following statements is true?

a.If all of its leaves are at the same level, then the binary tree is full.

b.A binary tree cannot have more than 2d nodes at level d.

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

Not yet answered


Marked out of 1.00

Not flaggedFlag question

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:

a.The balance is restored by one right rotation.

b.The balance is restored by one left rotation.

c.The balance is restored by one right rotation and one left rotation.

Question 8

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Select true / false statement:

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.

a. a and b are true

b.a is true and b is false

c.a is false and b is true

d.a and b are false

Question 9

Not yet answered

Marked out of 1.00


Not flaggedFlag question

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).

b.The root node value cannot be “32”.

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Select the best choice.

A stack can be implemented using .....

a.A singly linked list

b.A circular linked list

c.A double linked list

d.All of the others.

e.An array

Question 11

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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.

b. No rotation is needed for any of the encountered nodes.

a.a and b are incorrect.

b.a and b are correct.

c.a is correct and b is incorrect.

d.a is incorrect and b is correct.

Question 12

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following statements is (are) not disadvantage of AVL tree?

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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()

{if (isEmpty()) return;

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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)

{ Node p = new Node(x);

p.next = head;

head=p;

b.

void push(Object x)

{ Node p = new Node(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)

{ Node p = new Node(x);

p.next = null;

head=p;

Question 16

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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 …

a.Any one reference. Depending on the node that is accessed.

b.Nothing. We need a doubly linked list.

c.The tail reference of the singly linked list.

d.The head reference of the singly linked list.

Question 17

Not yet answered

Marked out of 1.00


Not flaggedFlag question

Question text

Select correct statement(s) about Doubly Linked List:

a.Methods for processing doubly linked list are simpler than those of singly linked list.

b.Deleting a node at the end of the list takes constant time O ( 1 ).

c.Inserting a new node at the end of the list requires O ( n ) steps.

d.The node which is deleted from the list will be claimed by the garbage collector.

Question 18

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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:

a. This insertion results in an unbalanced tree.

b. b. The balance is restored by one left rotation.

c. The balance is restored by one right rotation.

d. The balance is restored by one left rotation and one right rotation.

a.a and c are true

b.a and d are true

c.a and b are true

Question 21

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Precondition for both methods: n >= 0

public boolean even(int n) {


if (n==0) return true;

return odd(n-1);

public boolean odd(int n) {

if (n==0) return false;

return even(n-1);

Which assertions are correct?

a.even always stops, but odd may loop indefinitely

b.odd always stops, but even may loop indefinitely

c.both odd and even always stops

d.both odd and even may loop indefinitely

Question 22

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Select the best choice about a linked structure.

a.All of the others

b.Inserting a new element to it is efficiently.

c.It needs more memory spaces for linking elements.

d.Deleting an element from it is efficiently.

Question 23

Not yet answered


Marked out of 1.00

Not flaggedFlag question

Question text

Consider the statements related to deleteFromTail operation in the Singly Linked List:

a. There is only one special cases to consider: the list is empty.

b. Most time-consuming part of the operation is finding the next to last node.

a.a is false and b is true.

b.a is true and b is false.

c.a and b are true.

d.a and b are false

Question 24

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the heap:

100 90 80 30 60 50 70 20 10

What is position of the elements when dequeuing an element?

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

Not yet answered

Marked out of 1.00


Not flaggedFlag question

Question text

Which of the following statements is false?

a.The postorder traversal always visits the right-most node first.

b.The postorder traversal always visits the root last.

c.The preorder traversals always visit the root first.

d.The top-down level order traversals always visit the root first.

Question 26

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Recursion requires much memory because:

a.Recursive functions tend to declare many local variables.

b.It requires large data values.

c.Many copies of the function code are created.

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

b.All of the others

c.Inserting

d.Deleting

Question 28

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Select an incorrect statement.

a.Recursion is always more efficient than loops.

b.Recursion can make the conceptual design of an algorithm's implementation easier.

c.Recursion, gone wrong, can lead to an overflow stack error.

Question 29

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

The recursion statement indicates ...

a.the beginning of the recursion statement.

b.the rule of the recursion.

c.the starting value.

d.the ending of the recursion statement.

Question 31

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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 )

d.None of the others.

Question 32

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

When the compiler compiles your program, how is a recursive call treated differently than a non-
recursive method call?

a.Reference variables are all treated as primitive values.

b.Primitive values are all treated as reference variables.

c.There is no duplication of local variables.

d.None of the others

Question 34

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following is not correct about a recursive function?

a.A recursive function may call itself indirectly.

b.A recursive function is based on the recursion principle.

c.A recursive function may call itself directly.

d.A recursive function is based on the diversion principle.

Question 35
Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the following statements:

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.

a.a is false and b is true

b.a is true and b is false

c.a and b are false

d.a and b are true

Question 36

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following problems may use the recursion technique?

a.The Maze problem.

b.Perform symbolic differentiation.

c.All of the others.

d.The eight queens problem.

Question 37

Not yet answered


Marked out of 1.00

Not flaggedFlag question

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:

a. deleted node is leaf.

b. deleted node has only a child.

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

To implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left).


Suppose an AVL tree is created by inserting to the tree the following keys sequentially: 6, 4, 7, 3, 5, 2
What is the balance factor of the node 4? (please note that the tree is still AVL)

a. -1

b. 1

c.2

d.0

Question 39

Not yet answered


Marked out of 1.00

Not flaggedFlag question

Question text

Consider the heap:

120 110 100 50 80 70 90 40 30

What is position of the elements when dequeuing an element?

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the following statements about recursion:

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.

a.a is false, b is true

b.a and b are false

c.a and b are true

d.a is true, b is false

Question 41

Not yet answered


Marked out of 1.00

Not flaggedFlag question

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:

a. This insertion results in an unbalanced tree.

b. The balance is restored by one left rotation.

c. The balance is restored by one right rotation.

d. The balance is restored by one right rotation and one left rotation.

a.a and b are true

b.a and c are true

c.a and d are true

Question 42

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of sentences about singly linked list are true:

a.Deleting last node of the list always takes O ( lgn ) time.

b.There is no immediate access to the predecessor of any node in list.

c.Search operation takes O ( n ) time in the best case.

d.Deleting a node at the beginning of the list takes constant time O ( 1 ).

e.On the average, delete operation executes O ( n ) steps.

Question 43
Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following arrays is (are) heap?

a.82 70 51 43 55 37 10 43 63 30 34

b.82 70 51 63 34 37 10 43 27 30 55

c.All of the others

d.82 70 51 63 55 37 10 43 27 30 34

Question 44

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

c.Inserting and Searching

d.Searching and Deleting

Question 45

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Which of the following operation in the doubly linked circular list can be done in O(1) time?

a.Insertion of a node to any position.


b.Deletion of the tail node

c.Deletion of any node

d.Insertion of the tail node

Question 46

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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 )

b.None of the others

c.O ( lgn )

d.O ( 1 )

e.O ( n2 )

Question 47

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Show the contents of the array after we applied this algorithm.

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

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

Not yet answered

Marked out of 1.00

Not flaggedFlag question

Question text

Consider the following statements:

a. In the circular list, deletion of the tail node takes O ( n ) time.

b. The first node of the circular list has next field reference to the last node.

a. a is true and b is false.

b. a and b are true

c. a and b are false

d. a is fale and b is true

You might also like