Question # 1 of 10 ( Start time: 07:36:03 PM ) Total Marks: 1

For a perfect binary tree of height h, having N nodes, the sum of heights of nodes is _____________.

Select correct option:**N – (h – 1)**

N – (h + 1)

N – 1

N – 1 + h

Question # 2 of 10 ( Start time: 07:36:32 PM ) Total Marks: 1

The expression if ( ! heap->isEmpty() ) checks

Select correct option:

Heap is empty

Heap is full**Heap is not empty**

Not a valid expression

Question # 3 of 10 ( Start time: 07:36:55 PM ) Total Marks: 1

Which one of the following is NOT the property of equivalence relation?

Select correct option:

Reflexive

Symmetric

Transitive**Associative**

Question # 4 of 10 ( Start time: 07:37:22 PM ) Total Marks: 1

If a tree has 20 edges/links, then the total number of nodes in the tree will be :

Select correct option:**19**

20

21

Can't be determined

Question # 5 of 10 ( Start time: 07:37:58 PM ) Total Marks: 1

We can build a heap in _____ time.

Select correct option:**Linear**

Exponential

Polynomial

None of the given options

Question # 5 of 10 ( Start time: 07:37:58 PM ) Total Marks: 1

We can build a heap in _____ time.

Select correct option:**Linear**

Exponential

Polynomial

None of the given options

Question # 6 of 10 ( Start time: 07:38:23 PM ) Total Marks: 1

given the values are the array representation of heap; 12 23 26 31 34 44 56 64 78 100 If we perform 4 deleteMin operations, the last element deleted is__________.

Select correct option:

31**34**

44

56

Question # 8 of 10 ( Start time: 07:39:48 PM ) Total Marks: 1

Suppose there are a set of fruits and a set of vegetables. Both sets are ______________ sets.

Select correct option:**Disjoint**

Subsets

Whole

Equal

Question # 10 of 10 ( Start time: 07:40:42 PM ) Total Marks: 1

The preculateDown procedure will move the smaller value____ and bigger value______.

Select correct option:

left,right

right,left**up,down**

down,up

**FINALTERM EXAMINATION**

**Question No: 1 ( Marks: 1 ) – Please choose one**

**► Stack**

**►**Queue

**►**Both of these

**►**None of these

**Question No: 2 ( Marks: 1 ) – Please choose one**

**►**Both x and y are still 0.

**►**x is now 1, but y is still 0.

**► x is still 0, but y is now 2.**

**►**x is now 1, and y is now 2.

**Question No: 3 ( Marks: 1 ) – Please choose one**

*FALSE*statement about binary trees:

**► Every binary tree has at least one node.**

**►**Every non-empty tree has exactly one root node.

**►**Every node has at most two children.

**►**Every non-root node has exactly one parent.

**Question No: 4 ( Marks: 1 ) – Please choose one**

**►**Binary Tree

**►**Complete Binary Tree

**►**None of these

**► Binary Search Tree**

**Question No: 5 ( Marks: 1 ) – Please choose one**

**►**Log

_{2}(n+1)

**►**Log

_{2}(n+1) -1

**► 1.44 Log**

_{2}n**►**1.66 Log

_{2}n

**Question No: 6 ( Marks: 1 ) – Please choose one**

*priority queue*by storing the items in a heap. We are now executing a reheapification downward and the out-of-place node has priority of 42. The node’s parent has a priority of 72, the left child has priority 52 and the node’s right child has priority 62. Which statement best describes the status of the reheapification.

**►**The reheapification is done.

**►**The next step will interchange the two children of the out-of-place node.

**►**The next step will swap the out-of-place node with its parent.

**►**The next step will swap the out-of-place node with its left child.

**Question No: 7 ( Marks: 1 ) – Please choose one**

*cannot*possibly be a heap:

**►**7 6 5 4 3 2 1

**►**7 3 6 2 1 4 5

**►**7 6 4 3 5 2 1

**► 7 3 6 4 2 5 1**

**Question No: 8 ( Marks: 1 ) – Please choose one**

**►**23

**►**24

**► 21**

*► 22*

**Lesson # 27(the number of internal nodes is N, the number of external nodes will be N+1.**

**)**

Question No: 9 ( Marks: 1 ) – Please choose one

Question No: 9 ( Marks: 1 ) – Please choose one

**► N -1**

**►**N+1

**►**N+2

**►**N

**Question No: 10 ( Marks: 1 ) – Please choose one**

**►**Reflexive

**►**Symmetric

**►**Transitive

**► Associative**

**(lesson no 34)**

**Question No: 11 ( Marks: 1 ) – Please choose one**

**►**For all element x member of S, x R x

**►**For all elements x and y, x R y if and only if y R x

**► For all elements x, y and z, if x R y and y R z then x R z**

**(lesson no 34)**

**►**For all elements w, x, y and z, if x R y and w R z then x R z

**Question No: 12 ( Marks: 1 ) – Please choose one**

**► Constant**

**( lesson # 35 page 11)**

**►**Polynomial

**►**Exponential

**►**None of the given option

**Question No: 13 ( Marks: 1 ) – Please choose one**

**►**In a table, the type of information in columns may be different. yes

**► A table consists of several columns, known as entities.**(Lesson # 38 page 1 )

**►**The row of a table is called a record.

**►**A major use of table is in databases where we build and use tables for keeping information.

**Question No: 14 ( Marks: 1 ) – Please choose one**

**►**Only one rotation

**►**Rotation at each non-leaf node

**►**Rotation at each leaf node

**► Rotations equal to log2 N (lesson # 23)**

**Question No: 15 ( Marks: 1 ) – Please choose on**

**► Sorted (lesson # 39)**

**►**Heterogeneous

**►**Random

**Question No: 16 ( Marks: 1 ) – Please choose on**

**►**A Threaded Binary Tree is a binary tree in which every node that does not have a left child has a THREAD (in actual sense, a link) to its INORDER successor.

**►**A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its PREOREDR successor.

**► A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its INORDER successor.**

**►**A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its POSTORDER successor.

**Question No: 17 ( Marks: 1 ) – Please choose one**

**►**Binary tree only

**►**

**Threaded binary tree**(lesson # 27 page 3)

**►**Heap data structure

**►**Huffman encoding

**Question No: 18 ( Marks: 1 ) – Please choose one**

**►**Right thread of the right-most node points to the

*dummy*node.

**►**Left thread of the left-most node points to the

*dummy*node.

**►**The left pointer of dummy node points to the root node of the tree.

**► Left thread of the right-most node points to the**

*dummy*node.**Question No: 19 ( Marks: 1 ) – Please choose one**

**► 11,22,33,44,55,66**

**►**11,22,33,44,66,55

**►**11,22,33,66,44,55

**►**11,22,66,33,44,55

**Question No: 20 ( Marks: 1 ) – Please choose one**

**►**4,6,7,5

**►**6,7,5,4

**►**

**4,5,6,7**

**►**4,6,5,7

**Question No: 21 ( Marks: 1 ) – Please choose one**

**► Linear (lecture # 30 page 8)**

**►**Exponential

**►**Polynomial

**►**None of the given options

**Question No: 22 ( Marks: 1 ) – Please choose one**

**► The pivot could be either the 7 or the 9.**

**► The pivot could be the 7, but it is not the 9.**

**►**The pivot is not the 7, but it could be the 9

**►**Neither the 7 nor the 9 is the pivot.

**Question No: 23 ( Marks: 1 ) – Please choose one**

**► log (base 2) of n**

**►**The number of digits in n (base 10), e.g., 145 has three digits

**►**The square root of n

**►**n

**Question No: 24 ( Marks: 1 ) – Please choose one**

*cannot*possibly be a heap:

**►**16, 18, 20, 22, 24, 28, 30

**►**16, 20, 18, 24, 22, 30, 28

**►**16, 24, 18, 28, 30, 20, 22

**► 16, 24, 20, 30, 28, 18, 22**

**Question No: 25 ( Marks: 1 ) – Please choose one**

**► Randomly**

**►**That occur first in the text message

**►**That are lexically smaller among others.

**►**That are lexically greater among others

**Question No: 26 ( Marks: 1 ) – Please choose one**

**►**(i) queue (ii) insertion (iii) removals (iv) top

**►**(i) stack (ii) insertion (iii) removals (iv) bottom

**► (i) stack (ii) insertion (iii) removals (iv) top**

**►**(i) tree (ii) insertion (iii) removals (iv) top

**Question No: 27 ( Marks: 1 ) – Please choose one**

**►**31

**► 32**

**(n-1 links to internal nodes)**

**►**33

**►**66 (2n links)

**Question No: 28 ( Marks: 1 ) – Please choose on**

**►**post-order

**►**level-order

**►**inorder

**► None of the given options**

**Question No: 29 ( Marks: 1 ) – Please choose one**

*binary search*may be used to locate an entry

**►**The array elements must form a heap.

**►**The array must have at least 2 entries.

**► The array must be sorted. (lecture # 38)**

**►**The array’s size must be a power of two.

**Question No: 30 ( Marks: 1 ) – Please choose one**

**►**Linked List

**►**Stack

**►**Queue

**► Tree**

# CS301 Solved Mid Term Papers

**Question No: 1 ( Marks: 1 ) – Please choose one**

**►**True

**► False**

**Question No: 2 ( Marks: 1 ) – Please choose one**

**►**ab+c*d-

**► abc*+d-**

**►**abc+*d-

**►**abcd+*-

**Question No: 3 ( Marks: 1 ) – Please choose one**

**►**None of the given options

**►**Call by passing the value of the argument

**►**Call by passing reference of the argument

**► Call by passing the address of the argument**

**Question No: 4 ( Marks: 1 ) – Please choose one**

**► int &x ;**

**►**int *x ;

**►**int x ;

**►**None of the given options

Question No: 5 ( Marks: 1 ) – Please choose one

**►**Any one node fulfills the AVL condition

**►**At least half of the nodes fulfill the AVL condition

**► All the nodes fulfill the AVL condition**

**►**None of the given options

**Question No: 6 ( Marks: 1 ) – Please choose one**

**Consider the following pseudo code**

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

{

read a character

push the character on the stack

}

while ( the stack is not empty )

{

pop a character off the stack

write the character to the screen

}

**What is written to the screen for the input “apples”?**

**►**selpa

**► selppa**

**►**apples

**►**aaappppplleess

**Question No: 7 ( Marks: 1 ) – Please choose one**

**int x, y, z;**

**x = 2;**

**y = 3 + x;**

**z = foobar(x,y);**

**►**1

**►**4

**►**7

**► 8**

**Question No: 8 ( Marks: 1 ) – Please choose one**

**► Front**

**►**Rear

**►**From Both Rare and Front

**►**None of these

**Question No: 9 ( Marks: 1 ) – Please choose one**

**►**8

**►**7

**►**5

**► 6**

**Question No: 10 ( Marks: 1 ) – Please choose one**

**►**5

**►**6

**►**7

**► 8**

**Question No: 11 ( Marks: 1 ) – Please choose one**

**►**50

**►**60

**► 70**

**►**80

**Question No: 12 ( Marks: 1 ) – Please choose one**

**►**Linear way only

**►**Non Linear way only

**►**Both linear and non linear ways

**►**None of the given options.

**Question No: 13 ( Marks: 1 ) – Please choose one**

**►**A binary tree can contain at least 2

^{L}Nodes at level L.

**►**A complete binary tree of depth d is a binary tree that contains 2

^{L}Nodes at each level L between 0 and d, both inclusive.

**►**The total number of nodes (Tn ) in a complete binary tree of depth d is 2

^{d+1}– 1 .

**►**

**The height of the complete binary tree can be written as h = log 2 (Tn+1)-1 where Tn is Total number of Nodes.**

**Question No: 14 ( Marks: 1 ) – Please choose one**

**► (iii) and (ii) only**

**►**(i), (ii) and (iv) only

**►**(ii) and (iv) only

**►**None of the given options

**Question No: 15 ( Marks: 1 ) – Please choose one**

**The________method of list data structure removes the element residing at the current**position.

**►**Add

**►**next

**►**

*remove***►**

*find*

**Question No: 16 ( Marks: 1 ) – Please choose one**

**it will**be efficient

**to place stack elements at the**start of the list

**because insertion and removal take _______time.**

**►**Variable

**► Constant**

**►**Inconsistent

**►**None of the above