SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
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.

Contenu connexe

Tendances

Tendances (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
 

Similaire à Ee693 sept2014midsem

Ee693 sept2014quiz1
Ee693 sept2014quiz1Ee693 sept2014quiz1
Ee693 sept2014quiz1Gopi Saiteja
 
GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004GATE Computer Science Solved Paper 2004
GATE Computer Science Solved Paper 2004Rohit Garg
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years PapersRahul Jain
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Gopi 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
 
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 paperEneutron
 
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 keyappasami
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfahmed8651
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexityshowkat27
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Gopi Saiteja
 

Similaire à 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
 

Plus de Gopi Saiteja

Plus de 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
 

Dernier

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 

Dernier (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 

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.