SlideShare a Scribd company logo
EE693 DATA STRUCTURES AND ALGORITHMS
MID-SEMESTER EXAMINATION
22 SEPTEMBER, 2014, Time: 2 Hours
EEE Department, IIT Guwahati
NOTE: Attempt and solve all the questions. Question-1 to Question-30 are multiple choice questions (more than one
choices may be correct). Question-1 to Question-30, marks will be awarded, if and only if, all the correct
choice(s) will be made. Use of any kind of electronic media other than calculators are strictly prohibited. If
anybody finds voiding this rule will be penalized with -10 marks penalty. Please do not forget to mention your
Name and Roll No in the paper sheet. Please tick the correct choice(s). All the questions are of 1
mark.
Name: Roll No:
1. This is the welcome question! All the best for EE693 Mid-Semester Examination.
Out of all the 2-digit integers between 1 and 100, a 2-digit number has to be selected at random. What is the
probability that the selected number is not divisible by 7?
(a) 13/90 (b) 12/90 (c) 78/90 (d) 77/90
2. Consider the following function
int unknown( int n)
{
int i , j , k = 0;
for ( i=n /2; i<=n ; i++)
for ( j =2; j<=n ; j=j ∗2)
k=k+n /2;
return k ;
}
The return value of the function is
(a) Θ(n2
) (b) Θ(n2
log n) (c) Θ(n3
) (d) Θ(n3
log n)
3. Let g(n) and f(n) denote respectively, the worst case and average case running time of an algorithm executed on an
input of size n. Which of the following is ALWAYS TRUE?
(a) f(n) = Ω(g(n)) (b) f(n) = Θ(g(n))
(c) f(n) = O(g(n)) (d) None of the above
4. Which of the given options provides the increasing order of asymptotic complexity of functions f1(n) = 2n
, f2(n) = n3/2
,
f3(n) = nlog2 n, f4(n) = nlog2 n
?
(a) f3,f2,f4,f1 (b) f3,f2,f1,f4 (c) f2,f3,f1,f4 (d) f2,f3,f4,f1
5. Two alternative packages A and B are available for processing a database having 10k
records. Package A requires
0.0001n2
time units and package B requires 10nlog10 n time units to process n records. What is the smallest value of
k for which package B will be preferred over A?
(a) 12 (b) 10 (c) 6 (d) 5
6. A list of n strings, each of length n, is sorted into lexicographic (dictionary) order using the merge-sort algorithm by
a machine that can compare alphabets. The worst case running time of this computation is
(a) O(nlog n) (b) O(n2
log n) (c) O(nlog2
n) (d) O(n2
)
7. Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into
two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required
to sort n elements. Then
(a) T(n) ≤ 2T(n/5) + n (b) T(n) ≤ T(n/5) + T(4n/5) + n
(c) T(n) ≤ 2T(4n/5) + n (d) T(n) ≤ 2T(n/2) + n
8. The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes
in a binary tree of height h is
(a) 2h
− 1 (b) 2h−1
− 1 (c) 2h+1
− 1 (d) 2h+1
9. Given the selection sort function
selection_sort ( int s [ ] , int n)
{
int i , j ;
int min ;
for ( i =0; i<n ; i ++){
min=i ;
for ( j=i +1; j<n ; j++)
i f ( s [ j ] < s [ min ] ) min=j ;
swap(&s [ i ] ,& s [ min ] ) ;
}
}
the maximum number of swaps it might have to do is
(a) O(n2
/log n) (b) O(nlog n) (c) O(n) (d) O(log n)
10. Given a set of n distinct numbers, the fastest algorithm that finds
√
n numbers that are closest to the median has
the asymptotic performance
(a) O(
√
nlog n) (b) O(n) (c) O(nlog n) (d) O(n
√
n)
11. Let A be a sequence of 8 distinct integers sorted in ascending order. How many distinct pairs of sequences, B and
C are there such that (i) each is sorted in ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of
merging B and C gives A?
(a) 2 (b) 30 (c) 56 (d) 256
12. Find the worst inputs for Counting Sort among the following:
(a) A =< 3,5,3,2,2,4,1,6,4,2,4,1 >
(b) A =< 4,1,2,3,5,1,3,6,4,4,1,1 >
(c) A =< 3,5,3,2,2,2,1,6,2,2,2,1 >
(d) A =< 3,3,3,2,2,4,1,1,4,2,4,1 >
13. Find the worst inputs for Insertion Sort among the following (a to z):
(a) A =< a,d,o,b,e,s >
(b) A =< g,l,i,d,e,r >
(c) A =< n,o,m,a,d,s >
(d) A =< z,a,b,i,s,m >
14. Find the worst inputs for Merge Sort among the following (a to z):
(a) A =< a,d,o,b,e,s >
(b) A =< g,l,i,d,e,r >
(c) A =< n,o,m,a,d,s >
(d) A =< z,a,b,i,s,m >
15. Find the worst inputs for Quick Sort (if pivoting is done using the median at every step) among the following:
(a) A =< 3,5,1,6,2,4 >
(b) A =< 6,4,5,3,1,2 >
(c) A =< 3,1,4,5,6,2 >
(d) A =< 6,4,2,5,3,1 >
16. Suppose we use a hash function h to hash n distinct keys into an array T of length m. Assuming sim-
ple uniform hashing, what is the expected number of collisions? Given {{k,l} k ≠ l and h(k) = h(l)}.
(a) n(n+1)
2m
(b) n(n+1)
m
(c) n(n−1)
2m
(d) n(n−1)
m
17. Consider a version of the division method in which h(k) = k mod m, where m = 2p
− 1 and k is a charac-
ter string interpreted in radix 2p
. If we can derive string x from string y by permuting its characters, then
(a) x and y hash to the same value.
(b) x and y hash to the different values.
(c) x and y hash values cannot be defined.
(d) None of the above
18. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash-
ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires strictly more than k probes.
(a) 2k+1
(b) 2−k−1
(c) 2−k
(d) 2−k+1
19. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash-
ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires more than 2log(n) probes.
(a) 1/n (b) n (c) 1/(m + n) (d) 1/n2
20. Suppose that we have numbers between 1 and 1000 in a binary search tree, and we want to search
for the number 363. Which of the following sequences could not be the sequence of nodes examined?
(a) 2, 252, 401, 398, 330, 344, 397, 363
(b) 924, 220, 911, 244, 898, 258, 362, 363
(c) 925, 202, 911, 240, 912, 245, 363
(d) 2, 399, 387, 219, 266, 382, 381, 278, 363
(e) 935, 278, 347, 621, 299, 392, 358, 363
21. If a node in a binary search tree has two children, then its successor has no right child and its predecessor has no left
child.
(a) The statement is true. (b) The statement is false. (c) Cannot say. (d) None of the above.
22. We can sort a given set of n numbers by first building a binary search tree containing these numbers (using TREE-
INSERT repeatedly to insert the numbers one by one) and then printing the numbers by an inorder tree walk.
(a) The worst-case running times for this sorting algorithm is Θ(n2
).
(b) The best-case running times for this sorting algorithm is Θ(n log(n)).
(c) The worst-case running times for this sorting algorithm is Θ(log(n)).
(d) The best-case running times for this sorting algorithm is Θ(n).
23. Suppose a circular queue of capacity (n − 1) elements is implemented with an array of n elements. Assume
that the insertion and deletion operation are carried out using REAR and FRONT as array index variables,
respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
(a) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
(b) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
(c) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
(d) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
24. We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how
many ways can we populate the tree with the given set so that it becomes a binary search tree?
(a) 0 (b) 1 (c) n! (d) 1
n+1
2n
Cn
25. Consider the following C program that attempts to locate an element x in an array Y [] using binary search. The
program is erroneous.
1. f(int Y [10], int x) {
2. int i,j,k;
3. i = 0;j = 9;
4. do {
5. k = (i + j)/2;
6. if( Y [k] < x) i = k; else j = k;
7. } while((Y [k] ≠ x) && (i < j));
8. if(Y [k] == x) printf ("x is in the array ") ;
9. else printf (" x is not in the array ") ;
10. }
On which of the following contents of Y and x does the program fail?
(a) Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
(b) Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
(c) Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
(d) Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
26. In Question 25, the correction needed in the program to make it work properly is
(a) Change line 6 to: if (Y [k] < x) i = k + 1; else j = k − 1;
(b) Change line 6 to: if (Y [k] < x) i = k − 1; else j = k + 1;
(c) Change line 6 to: if (Y [k] ≤ x) i = k; else j = k;
(d) Change line 7 to: }while((Y [k] == x) && (i < j));
27. Consider the following C program segment where CellNode represents a node in a binary tree:
struct CellNode {
struct CellNOde *leftChild;
int element;
struct CellNode *rightChild;
};
int GetValue (struct CellNode *ptr) {
int value = 0;
if (ptr != NULL) {
if ((ptr->leftChild == NULL) && (ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)+ GetValue(ptr->rightChild);
}
return(value);
}
The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is:
(a) the number of nodes in the tree
(b) the number of internal nodes in the tree
(c) the number of leaf nodes in the tree
(d) the height of the tree
28. An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these
n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
(a) At least 2n − c comparisons, for some constant c, are needed.
(b) At most 1.5n − 2 comparisons are needed.
(c) At least nlog2n comparisons are needed.
(d) None of the above.
29. What is the time complexity of the following recursive function:
int DoSomething (int n) {
if (n ≤ 2)
return 1;
else
return (DoSomething (floor(sqrt(n))) + n);
}
(a) Θ(n2
) (b) Θ(nlog2n) (c) Θ(log2n) (d) Θ(log2log2n)
30. In the following C function, let n geqm.
int gcd(n,m){
if (n%m ==0) return m;
n = n%m;
return gcd(m,n);
}
How many recursive calls are made by this function?
(a) Θ(log2n) (b) Ω(n) (c) Θ(log2log2n) (d) Θ(
√
n)
All the best for your remaining mid-semester examinations.

More Related Content

What's hot

DSP System Homework Help
DSP System Homework HelpDSP System Homework Help
DSP System Homework Help
Matlab Assignment Experts
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
Programming Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
Krish_ver2
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
Ravi Rajput
 
Backtracking
BacktrackingBacktracking
Backtracking
Sally Salem
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
Krish_ver2
 
Signal Processing Assignment Help
Signal Processing Assignment HelpSignal Processing Assignment Help
Signal Processing Assignment Help
Matlab Assignment Experts
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
Statistics Assignment Help
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
Backtracking
BacktrackingBacktracking
Backtracking
Vikas Sharma
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
Lecture#9
Lecture#9Lecture#9
Lecture#9
Ali Shah
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
Matlab Assignment Experts
 

What's hot (20)

DSP System Homework Help
DSP System Homework HelpDSP System Homework Help
DSP System Homework Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
 
algorithm unit 1
algorithm unit 1algorithm unit 1
algorithm unit 1
 
Backtracking
BacktrackingBacktracking
Backtracking
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
 
Signal Processing Assignment Help
Signal Processing Assignment HelpSignal Processing Assignment Help
Signal Processing Assignment Help
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
Backtracking
BacktrackingBacktracking
Backtracking
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
Unit 3
Unit 3Unit 3
Unit 3
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
 
Lecture#9
Lecture#9Lecture#9
Lecture#9
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 

Similar to Ee693 sept2014midsem

Ee693 sept2014quiz1
Ee693 sept2014quiz1Ee693 sept2014quiz1
Ee693 sept2014quiz1
Gopi Saiteja
 
GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004
Rohit Garg
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
RamKumar42580
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
Rahul Jain
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1
Gopi Saiteja
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
Rohit Garg
 
Gate-Cs 2010
Gate-Cs 2010Gate-Cs 2010
Gate-Cs 2010
Ravi Rajput
 
AP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paperAP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paper
Eneutron
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
appasami
 
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
ahmed8651
 
S.Y.B.Sc. 2013 Pattern Old question Paper
S.Y.B.Sc. 2013 Pattern Old question PaperS.Y.B.Sc. 2013 Pattern Old question Paper
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
showkat27
 
Adobe
AdobeAdobe
Gate-Cs 2007
Gate-Cs 2007Gate-Cs 2007
Gate-Cs 2007
Ravi Rajput
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
Gopi Saiteja
 

Similar to Ee693 sept2014midsem (20)

Ee693 sept2014quiz1
Ee693 sept2014quiz1Ee693 sept2014quiz1
Ee693 sept2014quiz1
 
GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004
 
Paper computer
Paper computerPaper computer
Paper computer
 
Paper computer
Paper computerPaper computer
Paper computer
 
Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
Gate-Cs 2010
Gate-Cs 2010Gate-Cs 2010
Gate-Cs 2010
 
AP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paperAP PGECET Computer Science 2016 question paper
AP PGECET Computer Science 2016 question paper
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
4th Semester CS / IS (2013-June) Question Papers
4th Semester CS / IS (2013-June) Question Papers 4th Semester CS / IS (2013-June) Question Papers
4th Semester CS / IS (2013-June) Question Papers
 
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
4th Semester Electronic and Communication Engineering (June/July-2015) Questi...
 
G029037043
G029037043G029037043
G029037043
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
 
S.Y.B.Sc. 2013 Pattern Old question Paper
S.Y.B.Sc. 2013 Pattern Old question PaperS.Y.B.Sc. 2013 Pattern Old question Paper
S.Y.B.Sc. 2013 Pattern Old question Paper
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
 
Adobe
AdobeAdobe
Adobe
 
Gate-Cs 2007
Gate-Cs 2007Gate-Cs 2007
Gate-Cs 2007
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
 

More from Gopi Saiteja

Trees gt(1)
Trees gt(1)Trees gt(1)
Trees gt(1)
Gopi Saiteja
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearching
Gopi Saiteja
 
Heapsort
HeapsortHeapsort
Heapsort
Gopi Saiteja
 
Hashing gt1
Hashing gt1Hashing gt1
Hashing gt1
Gopi Saiteja
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Gopi Saiteja
 
Cs105 l15-bucket radix
Cs105 l15-bucket radixCs105 l15-bucket radix
Cs105 l15-bucket radix
Gopi Saiteja
 
Chapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiencyChapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiency
Gopi Saiteja
 
Sorting
SortingSorting
Sorting
Gopi Saiteja
 
Solution(1)
Solution(1)Solution(1)
Solution(1)
Gopi Saiteja
 
Pthread
PthreadPthread
Pthread
Gopi Saiteja
 
Open mp
Open mpOpen mp
Open mp
Gopi Saiteja
 
Introduction
IntroductionIntroduction
Introduction
Gopi Saiteja
 
Cuda
CudaCuda
Vector space interpretation_of_random_variables
Vector space interpretation_of_random_variablesVector space interpretation_of_random_variables
Vector space interpretation_of_random_variables
Gopi Saiteja
 
Statistical signal processing(1)
Statistical signal processing(1)Statistical signal processing(1)
Statistical signal processing(1)
Gopi Saiteja
 
Prob review
Prob reviewProb review
Prob review
Gopi Saiteja
 
Estimationtheory2
Estimationtheory2Estimationtheory2
Estimationtheory2
Gopi Saiteja
 
Estimation theory 1
Estimation theory 1Estimation theory 1
Estimation theory 1
Gopi Saiteja
 
Before quiz 2
Before quiz 2Before quiz 2
Before quiz 2
Gopi Saiteja
 
Assignment for practice
Assignment for practiceAssignment for practice
Assignment for practice
Gopi Saiteja
 

More from Gopi Saiteja (20)

Trees gt(1)
Trees gt(1)Trees gt(1)
Trees gt(1)
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearching
 
Heapsort
HeapsortHeapsort
Heapsort
 
Hashing gt1
Hashing gt1Hashing gt1
Hashing gt1
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Cs105 l15-bucket radix
Cs105 l15-bucket radixCs105 l15-bucket radix
Cs105 l15-bucket radix
 
Chapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiencyChapter11 sorting algorithmsefficiency
Chapter11 sorting algorithmsefficiency
 
Sorting
SortingSorting
Sorting
 
Solution(1)
Solution(1)Solution(1)
Solution(1)
 
Pthread
PthreadPthread
Pthread
 
Open mp
Open mpOpen mp
Open mp
 
Introduction
IntroductionIntroduction
Introduction
 
Cuda
CudaCuda
Cuda
 
Vector space interpretation_of_random_variables
Vector space interpretation_of_random_variablesVector space interpretation_of_random_variables
Vector space interpretation_of_random_variables
 
Statistical signal processing(1)
Statistical signal processing(1)Statistical signal processing(1)
Statistical signal processing(1)
 
Prob review
Prob reviewProb review
Prob review
 
Estimationtheory2
Estimationtheory2Estimationtheory2
Estimationtheory2
 
Estimation theory 1
Estimation theory 1Estimation theory 1
Estimation theory 1
 
Before quiz 2
Before quiz 2Before quiz 2
Before quiz 2
 
Assignment for practice
Assignment for practiceAssignment for practice
Assignment for practice
 

Recently uploaded

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 

Recently uploaded (20)

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 

Ee693 sept2014midsem

  • 1. EE693 DATA STRUCTURES AND ALGORITHMS MID-SEMESTER EXAMINATION 22 SEPTEMBER, 2014, Time: 2 Hours EEE Department, IIT Guwahati NOTE: Attempt and solve all the questions. Question-1 to Question-30 are multiple choice questions (more than one choices may be correct). Question-1 to Question-30, marks will be awarded, if and only if, all the correct choice(s) will be made. Use of any kind of electronic media other than calculators are strictly prohibited. If anybody finds voiding this rule will be penalized with -10 marks penalty. Please do not forget to mention your Name and Roll No in the paper sheet. Please tick the correct choice(s). All the questions are of 1 mark. Name: Roll No: 1. This is the welcome question! All the best for EE693 Mid-Semester Examination. Out of all the 2-digit integers between 1 and 100, a 2-digit number has to be selected at random. What is the probability that the selected number is not divisible by 7? (a) 13/90 (b) 12/90 (c) 78/90 (d) 77/90 2. Consider the following function int unknown( int n) { int i , j , k = 0; for ( i=n /2; i<=n ; i++) for ( j =2; j<=n ; j=j ∗2) k=k+n /2; return k ; } The return value of the function is (a) Θ(n2 ) (b) Θ(n2 log n) (c) Θ(n3 ) (d) Θ(n3 log n) 3. Let g(n) and f(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE? (a) f(n) = Ω(g(n)) (b) f(n) = Θ(g(n)) (c) f(n) = O(g(n)) (d) None of the above 4. Which of the given options provides the increasing order of asymptotic complexity of functions f1(n) = 2n , f2(n) = n3/2 , f3(n) = nlog2 n, f4(n) = nlog2 n ? (a) f3,f2,f4,f1 (b) f3,f2,f1,f4 (c) f2,f3,f1,f4 (d) f2,f3,f4,f1 5. Two alternative packages A and B are available for processing a database having 10k records. Package A requires 0.0001n2 time units and package B requires 10nlog10 n time units to process n records. What is the smallest value of k for which package B will be preferred over A? (a) 12 (b) 10 (c) 6 (d) 5 6. A list of n strings, each of length n, is sorted into lexicographic (dictionary) order using the merge-sort algorithm by a machine that can compare alphabets. The worst case running time of this computation is (a) O(nlog n) (b) O(n2 log n) (c) O(nlog2 n) (d) O(n2 ) 7. Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then (a) T(n) ≤ 2T(n/5) + n (b) T(n) ≤ T(n/5) + T(4n/5) + n (c) T(n) ≤ 2T(4n/5) + n (d) T(n) ≤ 2T(n/2) + n 8. The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is (a) 2h − 1 (b) 2h−1 − 1 (c) 2h+1 − 1 (d) 2h+1
  • 2. 9. Given the selection sort function selection_sort ( int s [ ] , int n) { int i , j ; int min ; for ( i =0; i<n ; i ++){ min=i ; for ( j=i +1; j<n ; j++) i f ( s [ j ] < s [ min ] ) min=j ; swap(&s [ i ] ,& s [ min ] ) ; } } the maximum number of swaps it might have to do is (a) O(n2 /log n) (b) O(nlog n) (c) O(n) (d) O(log n) 10. Given a set of n distinct numbers, the fastest algorithm that finds √ n numbers that are closest to the median has the asymptotic performance (a) O( √ nlog n) (b) O(n) (c) O(nlog n) (d) O(n √ n) 11. Let A be a sequence of 8 distinct integers sorted in ascending order. How many distinct pairs of sequences, B and C are there such that (i) each is sorted in ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging B and C gives A? (a) 2 (b) 30 (c) 56 (d) 256 12. Find the worst inputs for Counting Sort among the following: (a) A =< 3,5,3,2,2,4,1,6,4,2,4,1 > (b) A =< 4,1,2,3,5,1,3,6,4,4,1,1 > (c) A =< 3,5,3,2,2,2,1,6,2,2,2,1 > (d) A =< 3,3,3,2,2,4,1,1,4,2,4,1 > 13. Find the worst inputs for Insertion Sort among the following (a to z): (a) A =< a,d,o,b,e,s > (b) A =< g,l,i,d,e,r > (c) A =< n,o,m,a,d,s > (d) A =< z,a,b,i,s,m > 14. Find the worst inputs for Merge Sort among the following (a to z): (a) A =< a,d,o,b,e,s > (b) A =< g,l,i,d,e,r > (c) A =< n,o,m,a,d,s > (d) A =< z,a,b,i,s,m > 15. Find the worst inputs for Quick Sort (if pivoting is done using the median at every step) among the following: (a) A =< 3,5,1,6,2,4 > (b) A =< 6,4,5,3,1,2 > (c) A =< 3,1,4,5,6,2 > (d) A =< 6,4,2,5,3,1 > 16. Suppose we use a hash function h to hash n distinct keys into an array T of length m. Assuming sim- ple uniform hashing, what is the expected number of collisions? Given {{k,l} k ≠ l and h(k) = h(l)}. (a) n(n+1) 2m (b) n(n+1) m (c) n(n−1) 2m (d) n(n−1) m 17. Consider a version of the division method in which h(k) = k mod m, where m = 2p − 1 and k is a charac- ter string interpreted in radix 2p . If we can derive string x from string y by permuting its characters, then (a) x and y hash to the same value. (b) x and y hash to the different values. (c) x and y hash values cannot be defined. (d) None of the above 18. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash- ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires strictly more than k probes. (a) 2k+1 (b) 2−k−1 (c) 2−k (d) 2−k+1
  • 3. 19. Suppose that we use an open-addressed hash table of size m to store n ≤ m/2 items. Assuming uniform hash- ing, for i = 1,2,3,⋯,n, the probability is at most ⋯⋯ that the i insertion requires more than 2log(n) probes. (a) 1/n (b) n (c) 1/(m + n) (d) 1/n2 20. Suppose that we have numbers between 1 and 1000 in a binary search tree, and we want to search for the number 363. Which of the following sequences could not be the sequence of nodes examined? (a) 2, 252, 401, 398, 330, 344, 397, 363 (b) 924, 220, 911, 244, 898, 258, 362, 363 (c) 925, 202, 911, 240, 912, 245, 363 (d) 2, 399, 387, 219, 266, 382, 381, 278, 363 (e) 935, 278, 347, 621, 299, 392, 358, 363 21. If a node in a binary search tree has two children, then its successor has no right child and its predecessor has no left child. (a) The statement is true. (b) The statement is false. (c) Cannot say. (d) None of the above. 22. We can sort a given set of n numbers by first building a binary search tree containing these numbers (using TREE- INSERT repeatedly to insert the numbers one by one) and then printing the numbers by an inorder tree walk. (a) The worst-case running times for this sorting algorithm is Θ(n2 ). (b) The best-case running times for this sorting algorithm is Θ(n log(n)). (c) The worst-case running times for this sorting algorithm is Θ(log(n)). (d) The best-case running times for this sorting algorithm is Θ(n). 23. Suppose a circular queue of capacity (n − 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are (a) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT (b) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR (c) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT (d) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT 24. We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how many ways can we populate the tree with the given set so that it becomes a binary search tree? (a) 0 (b) 1 (c) n! (d) 1 n+1 2n Cn 25. Consider the following C program that attempts to locate an element x in an array Y [] using binary search. The program is erroneous. 1. f(int Y [10], int x) { 2. int i,j,k; 3. i = 0;j = 9; 4. do { 5. k = (i + j)/2; 6. if( Y [k] < x) i = k; else j = k; 7. } while((Y [k] ≠ x) && (i < j)); 8. if(Y [k] == x) printf ("x is in the array ") ; 9. else printf (" x is not in the array ") ; 10. } On which of the following contents of Y and x does the program fail? (a) Y is [1 2 3 4 5 6 7 8 9 10] and x < 10 (b) Y is [1 3 5 7 9 11 13 15 17 19] and x < 1 (c) Y is [2 2 2 2 2 2 2 2 2 2] and x > 2 (d) Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even 26. In Question 25, the correction needed in the program to make it work properly is (a) Change line 6 to: if (Y [k] < x) i = k + 1; else j = k − 1; (b) Change line 6 to: if (Y [k] < x) i = k − 1; else j = k + 1; (c) Change line 6 to: if (Y [k] ≤ x) i = k; else j = k; (d) Change line 7 to: }while((Y [k] == x) && (i < j));
  • 4. 27. Consider the following C program segment where CellNode represents a node in a binary tree: struct CellNode { struct CellNOde *leftChild; int element; struct CellNode *rightChild; }; int GetValue (struct CellNode *ptr) { int value = 0; if (ptr != NULL) { if ((ptr->leftChild == NULL) && (ptr->rightChild == NULL)) value = 1; else value = value + GetValue(ptr->leftChild)+ GetValue(ptr->rightChild); } return(value); } The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is: (a) the number of nodes in the tree (b) the number of internal nodes in the tree (c) the number of leaf nodes in the tree (d) the height of the tree 28. An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed? (a) At least 2n − c comparisons, for some constant c, are needed. (b) At most 1.5n − 2 comparisons are needed. (c) At least nlog2n comparisons are needed. (d) None of the above. 29. What is the time complexity of the following recursive function: int DoSomething (int n) { if (n ≤ 2) return 1; else return (DoSomething (floor(sqrt(n))) + n); } (a) Θ(n2 ) (b) Θ(nlog2n) (c) Θ(log2n) (d) Θ(log2log2n) 30. In the following C function, let n geqm. int gcd(n,m){ if (n%m ==0) return m; n = n%m; return gcd(m,n); } How many recursive calls are made by this function? (a) Θ(log2n) (b) Ω(n) (c) Θ(log2log2n) (d) Θ( √ n) All the best for your remaining mid-semester examinations.