Anda di halaman 1dari 9

THE TEST ON DSA

TimeLeft=1:29:45
1
Which of the following is a /are correct sorting
technique(s) in connection with the quick sort
algorithm? ?
sorting by selection 3Mark
sorting by insertion
sorting by exchange
sorting by removal
2
The running time for insertion sort the array is
already sorted in ascending order? ?
O(n^2) 3Mark
O(1)
O(n*log n)
O(n)
3
int hash(char *str, int table_size)
{
int sum=0;

if (str==NULL) return -1;

for( ; *str; str++) sum += *str;

return sum % table_size;
}
What is this function trying to do? Explain from
hashing point of view.
Assume that this function is invoked as hash("I hate
Page 1 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
you", 10) and then hash("I love you", 10). What
problem do you see in this scenario? ?

4Mark
4
Which of the following will produce a sorted output
from a BST ?
Postorder 4Mark
Preorder
None of these
Inorder
5
For any 2 stacks S1 and S2 what will be the output of
the following code: ?
stack_code1.txt
1 4 9 25 36 5Mark
49 36 25 16 9
7 6 5 4 3 2 1
36 25 16 9 1
6
Assuming that a link list with a head pointer is
available what will replace ____ in the code if it has
to count the number of elements in the list:
int count( list * head)
{
if ( head == NULL)
return 0;
else
return(____);
} ?
head->next 5Mark
count(head->next->next)
Page 2 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
count(head->next)
1+count(head->next)
7
Which data structure is used for fast searches in
extremely large dataset? ?
Doubly circular linked list 3Mark
Stack
Binary tree
Hash Table
8
Suppose a queue is implemented with a circular
array, keeping track of front, rear and count (the
number of items in the array). If front is zero, and
rear is one less than the current capacity then what
is count? ?
count is one less than the capacity 4Mark
None of these
count is equal to the capacity
count is 0
9
The following numbers are inserted into an empty
binary search tree in the given order: 10, 1, 3, 5, 15,
12, 16. What is the height of the binary search
tree? ?
2 7Mark
3
6
4
10
Which of the following is not a desirable property of
a collision detection technique? ?
Given the same input, it should always produce the same
output.
3Mark
Page 3 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
It should be easy to understand.
It should uniformly spread the keys over the available buckets.
It should be fast.
11
The following while loop is to remove duplicates
from an existing list having a head pointer pointing
to the first node.Which code will replace ____

current=head;
while(current->next!=NULL)
{
if (current->data == current->next->data)
{
____
}
else
{
current = current->next;
}
} ?
p=current->next->next;free(current);current->next = p; 5Mark
p= current->next->next;free(current->next);current->next = p;
p=current->next;free(current->next);current->next=p;
p=current->next;free(p);
12
A newspaper route has recently been computerized.
Information about each of the 100 customers is
stored in individual records containing first name,
last name, and payment due. In writing a computer
program to process the customer records, the
programmer is uncertain whether to add a
procedure to sort the records.If the records are first
sorted, what will be the maximum number of
Page 4 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
comparisons needed with a binary search to find a
particular customer's record? ?
100 5Mark
7
5
50
13
If a linked list with odd number of nodes exists, then
what will be q pointer pointing to after execution of
the function? Justify your answer.
void function( )
{
list * q,*p;
int i;
p=head;
for(i=1; head ! =NULL; head=head->next,i++)
{
if(i==1)
q=head;
else if ((i%2)==1)
q=q->next;
}
} ?

6Mark
14
Assume that there is a server that serves different
requests from clients. There are clients who have to
be given the service immediately. There are requests
which has to be served immediately. In general there
is a need of keeping an order also.
What all data structures would you use here?
Page 5 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
Reason your answer. ?

4Mark
15 To retrieve a value stored in a hash table: ?
Construct a binary search tree from the table and search the
tree.
3Mark
Do a binary search on the table
Hash the key and then locate the associated record.
Do a linear search on the table
16
for(i=0;i<5;i++)
insert(Q1,i);
for(i=0;i<5;i++)
{
if (!(j=delete(Q1)))
{
push(S,j);
}
}
k=0;
while(!isempty(S))
{
k=pop(S);
print k;
}
If Q is Queue and S is stack, what would be output of
the following? Explain. ?

4Mark
Page 6 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302
17
Which is the quickest sort algorithm for linked
lists? ?
Merge Sort 3Mark
Bubble Sort
Insertion Sort
Quick Sort
18
In selecting the pivot for quicksort, the best choice
for optimal partitioning is: ?
The first element of the array 3Mark
The median of the array.
The last element of the array
The middle element of the array
19
An advantage of passing a pointer by reference for
removing a node from a tree is: ?
It minimizes the size of the tree 3Mark
It eliminates the need for a parent pointer in the tree
It enables the code to directly manipulate child pointer that
points to the current node
It minimizes the depth of the tree
20 The worst case of linear search is when ?
Neither Option 1 nor Option 2 3Mark
Option 1: The element is present in the last location of the
array
Option 2: The element is not present in the array
Either Option 1 or Option 2
21 Subjective Question to be done on server ?
4Mark
Page 7 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302


22
It is not a good idea to use binary search to find a
value in a sorted linked list of values. Why? ?
Linked list uses dynamic memory allocation. So the number of
items are not known.
3Mark
Binary search may not work for a linked list
Binary search using a linked list would usually be much slower
than Linear search
It is not possible to sort a linked list, but sorted data is needed
for binary search.
23
For an array containing 5 elements as : 42 29 75 11
65 58 60 18 what will be the result of sorting in
ascending order using bubble sort after 2 passes
have completed. ?
11 29 42 18 58 60 65 75 3Mark
29 42 11 65 58 60 18 75
11 29 42 58 18 60 65 75
29 11 42 58 60 18 65 75
24
For a doubly linked list does the following segment
of code removes the element pointed to by X , if it is
assumed that X points to neither the first nor the last
element in the list.
X->prev->next = X->next;
X->next->prev = X->prev; ?
True 5Mark
False
Not Answer
Page 8 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302



submit
Page 9 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=513&s2=20302

Anda mungkin juga menyukai