Search Papers On This Blog. Just Write The Name Of The Course

Friday 24 December 2010

Solved Finalterm Paper of CS301- Data Structures 2010

FINALTERM  EXAMINATION
Spring 2010
CS301- Data Structures
Ref No:
Time: 90 min
Marks: 58

Student Info
Student ID:


Center:

Exam Date:





Question No: 1      ( Marks: 1 ) - Please choose one


Which one of the following operations returns top value of the stack?


       Push

       Pop

       Top

       First


Question No: 2      ( Marks: 1 ) - Please choose one


Compiler uses which one of the following in Function calls,


       Stack


       Queue


       Binary Search Tree


       AVL Tree



Question No: 3      ( Marks: 1 ) - Please choose one


Every AVL is _________________

       Binary Tree

       Complete Binary Tree

       None of these

       Binary Search Tree  


Question No: 4      ( Marks: 1 ) - Please choose one


If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?


       54

       55

       56

       57


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


If there are 23 external nodes in a binary tree then what will be the no. of internal nodes in this binary tree?


       23

       24

       21

       22


Question No: 6      ( Marks: 1 ) - Please choose one


Which one of the following is not an example of equivalence relation? 


       Electrical connectivity 

       Set of people

       <= relation 

       Set of pixels 


Question No: 7      ( Marks: 1 ) - Please choose one


Binary Search is an algorithm of searching, used with the ______ data.

       Sorted

       Unsorted

       Heterogeneous

       Random


Question No: 8      ( Marks: 1 ) - Please choose one


Which one of the following is NOT true regarding the skip list?

       Each list Si contains the special keys + infinity and - infinity.

       List S0 contains the keys of S in non-decreasing order. 

       Each list is a subsequence of the previous one.

       List Sh contains only the n special keys.


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


A simple sorting algorithm like selection sort or bubble sort has a worst-case of


       O(1) time because all lists take the same amount of time to sort

       O(n) time because it has to perform n swaps to order the list.

       O(n2) time because sorting 1 element takes O(n) time - After 1 pass through the list,
either of these algorithms can guarantee that 1 element is sorted.

       O(n3) time, because the worst case has really random input which takes longer to
sort.


Question No: 10      ( Marks: 1 ) - Please choose one


Which of the following is a property of binary tree?

       A binary tree of N external nodes has N internal node.

       A binary tree of N internal nodes has N+ 1 external node.

       A binary tree of N external nodes has N+ 1 internal node.

       A binary tree of N internal nodes has N- 1 external node.


Question No: 11      ( Marks: 1 ) - Please choose one


By using __________we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.

       Binary tree only

       Threaded binary tree

       Heap data structure

       Huffman encoding


Question No: 12      ( Marks: 1 ) - Please choose one


Which of the following statement is true about dummy node of threaded binary tree?

       This dummy node never has a value.

       This dummy node has always some dummy value.

       This dummy node has either no value or some dummy value.

       This dummy node has always some integer value.


Question No: 13      ( Marks: 1 ) - Please choose one


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


       N – (h – 1) 

       N – (h + 1) 

       N – 1 

       N – 1 + h 


Question No: 14      ( Marks: 1 ) - Please choose one


What is the best definition of a collision in a hash table?


       Two entries are identical except for their keys.


                   Two entries with different data have the exact same key

       Two entries with different keys have the same exact hash value.


                   Two entries with the exact same key have different hash values.


Question No: 15      ( Marks: 1 ) - Please choose one


Which formula is the best approximation for the depth of a heap with n nodes?


       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: 16      ( Marks: 1 ) - Please choose one


Which of the following statement is NOT correct about find operation: 


          It is not a requirement that a find operation returns any specific name, just that finds on two elements return the same answer if and only if they are in the same set. 

       One idea might be to use a tree to represent each set, since each element in a tree has the same root, thus the root can be used to name the set. 


        Initially each set contains one element. 

        Initially each set contains one element and it does not make sense to make a tree of one node only. 


Question No: 17      ( Marks: 1 ) - Please choose one


Which of the following is not true regarding the maze generation?

       Randomly remove walls until the entrance and exit cells are in the same set. 

       Removing a wall is the same as doing a union operation. 

       Remove a randomly chosen wall if the cells it separates are already in the same set. 

        Do not remove a randomly chosen wall if the cells it separates are already in the same set. 


Question No: 18      ( Marks: 1 ) - Please choose one


In threaded binary tree the NULL pointers are replaced by ,


       preorder successor or predecessor

       inorder successor or predecessor

       postorder successor or predecessor

       NULL pointers are not replaced


Question No: 19      ( Marks: 1 ) - Please choose one


Which of the given option is NOT a factor in Union by Size: 

       Maintain sizes (number of nodes) of all trees, and during union.

       Make smaller tree, the subtree of the larger one. 

        Make the larger tree, the subtree of the smaller one. 

       Implementation: for each root node i, instead of setting parent[i] to -1, set it to -k if tree rooted at i has k nodes.


Question No: 20      ( Marks: 1 ) - Please choose one


Suppose we had a hash table whose hash function is “n % 12”, if the number 35 is already in the hash table, which of the following numbers would cause a collision?


       144

       145

       143

       148


Question No: 21      ( Marks: 1 ) - Please choose one


What requirement is placed on an array, so that 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.

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


Question No: 22      ( Marks: 1 ) - Please choose one


A binary tree with 24 internal nodes has ______ external nodes.


       22

       23

       48

       25


Question No: 23      ( Marks: 1 ) - Please choose one


In case of deleting a node from AVL tree, rotation could be prolong to the root node.


       Yes

       No


Question No: 24      ( Marks: 1 ) - Please choose one


when we have declared the size of the array, it is not possible to increase or decrease it during the ________of the program.


       Declaration


       Execution


       Defining


       None of the above



Question No: 25      ( 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



Question No: 26      ( Marks: 1 ) - Please choose one


  _______ is the stack characteristic but _______was implemented because of the size limitation of the array.


       isFull(),isEmpty()


       pop(), push()


       isEmpty() , isFull()


       push(),pop()



Question No: 27      ( Marks: 2 )


Give the difference between strict and complete binary tree.

Ans:
A tree is a strictly binary tree if its each leaf node has non-empty left and right sub trees, and
If there are left and right sub-trees for each node in a binary tree is known as complete binary tree.


Question No: 28      ( Marks: 2 )


A complete binary tree can be stored in an array. While storing the tree in an array
we leave the first position (0th index )of the array empty. Why?

Ans
Because we need a pointer in an array to point a position of node of tree. parent node and the children nodes. In case of having  a  node with  left  and  right children, stored at position  i in the array, the left 2i and the right child will be at 2i+1 position. If the value of i  2, the parent will be at position 2 and the left child will be at position 2i i.e. 4 .The right child will be at position 2i+1 i.e. 5. we have not started  the 0th  position. It is simply due to the fact if the position is 0,  2i will also
become 0.  So we will start from the 1st  position, ignoring the 0th.
. 
Question No: 29      ( Marks: 2 )


Give the name of two Divide and Conquer algorithms.


Ans:


  1. Merge sort
  2. Quick sort
  3. Heap sort


Question No: 30      ( Marks: 2 )


Give the effect of sorted data on Binary Search.



Question No: 31      ( Marks: 3 )


Give any three characteristics of Union by Weight method.


Ans:
1.      This is also calles union by size.
  1. Maintain sizes (number of nodes) of all trees, and during union.
  2. Make smaller tree, the subtree of the larger one.
  3. for each root node i, instead of setting parent[i] to -1, set it
to -k if tree rooted at i has k nodes.


Question No: 32      ( Marks: 3 )


Here is an array of ten integers:
            5   3   8   9   1   7   0   2   6   4
Draw this array after the FIRST iteration of the large loop in an insertion sort (sorting from smallest to largest). This iteration has shifted at least one item in the array!



Question No: 33      ( Marks: 3 )


Give your comment on the statement that heap uses least memory in array representation of binary trees. Justify your answer in either case.


Question No: 34      ( Marks: 5 )


Suppose we have the following representation for a complete Binary Search Tree, tell the Left and Right child nodes and Parent node of the node D



A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20






Question No: 35      ( Marks: 5 )


Explain the following terms:
1.      Collision
2.      Linear Probing
3.      Quadratic Probing









Ans:
Collision:
it takes place when two or more keys (data items) produce the same index.



Linear Probing

when there is a collision, some other location in the array is found. This is known as linear probing. In linear probing, at the time of collisions, we add one to the index and check that location. If it is also not empty, we add 2 and check that position. Suppose we keep on incrementing the array index and reach at the end of the table. We were unable to find the space and reached the last location of  the array.


Quadratic Probing

In the quadratic probing when a collision happens we try to find the empty location at
index + 12. If it is filled then we add 22  and so on.
Quadratic probing uses different formula:
  1. Use F(i) = i2 (square of i) to resolve collisions
  2. If hash function resolves to H and a search in cell H is inconclusive, try
H + 12, H + 22, H + 32


Question No: 36      ( Marks: 5 )


Here is an array with exactly 15 elements:
                        1   2   3   4   5   6   7   8   9   10   11   12   13   14   15.
Suppose that we are doing a binary search for an element. Indicate any elements that will be found by examining two or fewer numbers from the array.


No comments:

Post a Comment