Sie sind auf Seite 1von 9

THE TEST ON DSA

TimeLeft=1:34:54
1
You want to find the nth element of a set of
numbers. If you store the numbers in a list
_________________ ?
Finding the nth element is faster if it was stored in an array 3Mark
Finding the nth element takes the same amount of time across
all data structures
Finding the nth element is slower if it was stored in a hash
table
Finding the nth element is slower if it was stored in an array
2
Let S and S1 be two stacks and Q be the additional
Queue then what is the result after following pseudo
code is executed:

while (S not empty)
{
Q.insert(pop(S));
}

while(Q not empty)
{
push(S1,Q.delete());
} ?
S and S1 are same 6Mark
None of them
S and S1 will be different
S1 is reverse of S
Page 1 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
3
Algorithms A and B solve the same problem. Time
complexity of A is in O(n^2) and that of B is in O(n).
Which among the following can you guarantee? ?
A is having more executable instructions than B 3Mark
A is having less number of functions than B
A is having less executable instructions than B
A is having more number of functions than B
4
Assume that you have a very large array of elements.
You are required to sort this array. The main
contraint here is the space rather than time. Which
among the following algorithm is not an ideal
choice? ?
Merge Sort 3Mark
Insertion Sort
Bubble Sort
Quick Sort
5
Think about a server to which all ATM clients of a
particular bank is connected. There are requests
coming from different ATM centers and the server
has to verify the user name and password and do the
transaction also. There could be successful and
failure requests. There could be requests from other
banks? ATM also. Some customers may spend more
time than others.

Which all data structures could be involved for
implementing the same? Conceptualize your answer.
Would you go for an array implementation or linked
list implementation? Justify your answer. ?
4Mark
Page 2 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302

6
Minimum how many stacks are needed to implement
a queue ?
Cannot be implemented 3Mark
2
3
1
7
Which among the following is true for doubly linked
list ?
The left pointer of the right most node and right pointer of the
left most node are null
3Mark
The left pointer of the left most node and right pointer of the
right most node are null
The right pointer of the right most node and no condition on
the left most node
The left pointer of the right most node and no condition on the
left most node
unsigned int str_hash(unsigned char *string,
unsigned int buckets, unsigned in alphabet_size,
unsigned int hash_limit)
{
int i = 0;
unsigned int accum;

while ((string[i] != 0) && (i < hash_limit))
i++;

if (i < hash_limit)
Page 3 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
8
hash_limit = i;

accum = (unsigned int) string[hash_limit - 1];

for (i = hash_limit - 2; i >= 0; i--)
accum = string[i] + (accum * alphabet_size);

return accum % buckets;
}
What is this function trying to do?
Note: buckets is the array size which is a prime
number, alphabet_size is the number of all possible
characters, hash_limit is the length of a string and
string is a string. ?

4Mark
9
A quicksort algorithm is used to sort an array of N
elements.If all the N values were 0 then what would
be the time complexity of quicksort that uses first
element as the pivot. ?
O(1) 6Mark
O(N)
O(N log N)
O(N*N)
10
Which among the following are applications of
queues ?
Queues keep track of processes waiting for a turn in the CPU 3Mark
Queues keep track of events waiting to be handled, like
multiple button clicks
Queues are used in parsing
Page 4 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
Queues are used for evaluation of arithmetic expressions
11
Let S be the original stack and S1 and S2 the two
additional stacks then the following pseudo code is to
reverse the stack S:

while (S not empty)
{
push(S1,pop(S));
}

while(S1 not empty)
{
push(S2,pop(S1));
}

while(S2 not empty)
{
push(S,pop(S2));
} ?
True 6Mark
False
Not Answer
12
The hash function is
H1(k) = k % 50.
In the case of collision, the hash function used is
H(k) = (H1(k) + M x H2(k)) % 50
where H1(k) = k % 50 and H2(k) = k % 20.
M is initialized to 0 and is incremented by 1 each
time a collision occurs.
This could be categorized under which of the
following collision detection technique? ?
Linear Probing 3Mark
Page 5 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
Re-Hashing
Quadratic Probing
Double Hashing
13
What does the following function return, if q
contains the address of the first element in a linked
list

int function(NODE *q)
{
int c = 0;
while( q != NULL)
{
q = q->link;
c++;
}
return (c);
} ?
The value of the first elements of the linked list 4Mark
The number of elements in a linked list
The value of the last node of the linked list
The address of the last element of the linked list
14
Consider the following set of integers.
{20,25,57,48,37,12,92,86,33}
If one uses the quick sort algorithm to sort the above
set of integers, how many pivot values are required
to completely sort the file?
Note: you may choose middle element as a pivot. ?
3 3Mark
5
8
9
Page 6 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
15
The time complexity of insertion sort in worst case
is? ?
n(n+1)/4 3Mark
n(n+1)/2
n(n-1)/4
n(n-1)/2
16 Linear Search is best for ... ?
Small arrays 3Mark
Small or Large, but sorted arrays
Small or Large, but unsorted arrays
Large arrays
17
Assume that a structure for a Binary Search Tree
exists.
What does the following function do?

int function(root)
{
current = root;
while (current->left != NULL)
{
current = current->left;
}
return(current->data);
} ?

6Mark
What does the following function do if S is an array
used to implement a stack
Page 7 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302
18

float peep ( float S[], int *t, int i)
{
float val;
if( (*t-i+1) > 0)
{
val = S[*t-i+1];
return val;
}
} ?
Returns the value at the top of the stack 4Mark
Returns the ith value from top of the stack
It gives a compilation error
Returns the value at the ith postion of the array
19 The disadvantage of Binary Search is ?
It may not work for strings 3Mark
Its performance depends on the position of the search element
in the array
It has the overhead of sorting
It may not work for floating point numbers
20 Subjective Question to be done on server ?

4Mark
21
int MFunc(tree *T)
{
int N1,N2;
if(T == NULL)
return -1;
N1 = MFunc(T->left);
Page 8 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302




N2 = MFunc(T->right);
return (N1 > N2 ? N1 : N2) + 1;.
}
If T points to root of a tree, what does this function
do? Explain. ?

4Mark
22
Which is the best data structure for round robin
algorithm for CPU scheduling? ?
Queue implemented using stacks 5Mark
Doubly linked list
Circular queue
Stack implemented using queues
submit
Page 9 of 9
2/6/2009 http://10.203.161.13/OES/take.jsp?s1=506&s2=20302

Das könnte Ihnen auch gefallen