SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
EE693 DATA STRUCTURES AND ALGORITHMS
QUIZ-GT-2 EXAMINATION
25 OCTOBER, 2014, Time: 1 Hours
EEE Department, IIT Guwahati
NOTE: Attempt and solve all the questions. Question-1 to Question-16 are fill in the blank questions. 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.
All the questions are of 2 marks. Question 16 is for 2 Bonus Marks. You should attempt it after solving
all the other problems (Questions 1-15).
Name: Roll No:
1. This is the welcome question! All the best for EE693 Quiz-2 (GT).
Let A be a square matrix of size n x n. Consider the following program. The expected output is ⋯⋯
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Output(A[i][j]);
2. The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5
+ 4X3
+ 6X + 5 for a
given value of X using only one temporary variable are ⋯⋯.
3. You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the
array as the pivot. In that case, the tightest upper bound for the worst case performance is ⋯⋯
4. The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is ⋯⋯
5. Consider two strings A = qpqrr and B = pqprqrp. Let x be the length of the longest common subsequence (not
necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A
and B. Then x + 10y = ⋯⋯⋯
6. Suppose P,Q,R,S,T are sorted sequences having lengths 20,24,30,35,50 respectively. They are to be merged into a
single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the
worst case by the optimal algorithm for doing this is ⋯⋯⋯
7. Consider the following pseudo code. The total number of multiplications to be performed is ⋯⋯⋯
D = 2
for i = 1 to n do
for j = i to n do
for k = j + 1 to n do
D = D * 3
8. Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The
following 9 keys are inserted in the order: 5,28,19,15,20,33,12,17,10. The maximum, minimum, and average chain
lengths in the hash table, respectively, are ⋯⋯⋯
9. A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is:
10,8,5,3,2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap
after the insertion of the elements is ⋯⋯⋯
10. Consider a rooted Binary tree represented using pointers. The best upper bound on the time required to determine
the number of subtrees having having exactly 4 nodes O(na
Log(nb
)). Then the value of a + 10b is ⋯⋯⋯
11. Let P be a QuickSort Program to sort numbers in ascending order using the first element as pivot. Let t1 and t2
be the number of comparisons made by P for the inputs {1,2,3,4,5} and {4,1,5,3,2} respectively. The relationship
between t1 and t2 is ⋯⋯⋯
12. Consider the following C function in which size is the number of elements in the array E. The value returned by the
function MyX is ⋯⋯⋯
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;
for (i = 0; i < size; i++)
Y = Y + E[i];
for (i = 0; i < size; i++)
for (j = i; j < size; j++)
{
Z = 0;
for (k = i; k <= j; k++)
Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}
13. The maximum height of any AVL-tree with 7 nodes is ⋯⋯⋯. Assume that the height of a tree with a single node is
0.
14. The worst case possible height of AVL tree is ⋯⋯⋯
15. The worst case possible height of Red-Black tree is ⋯⋯⋯
16. (Bonus Question) A program takes as input a balanced binary search tree with n leaf nodes and computes the value
of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of
leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is ⋯⋯⋯
All the best for next week quiz.

Contenu connexe

Tendances

Exercise 2
Exercise 2Exercise 2
Exercise 2math126
 
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...Mumbai B.Sc.IT Study
 
Chapter 3 classroom
Chapter 3 classroomChapter 3 classroom
Chapter 3 classroomwellingb
 
Day 7 examples u6w14
Day 7 examples u6w14Day 7 examples u6w14
Day 7 examples u6w14jchartiersjsd
 
10 mathfinal2011review
10 mathfinal2011review10 mathfinal2011review
10 mathfinal2011reviewJoshua Gerrard
 
7th PreAlg - L47--Jan17
7th PreAlg - L47--Jan177th PreAlg - L47--Jan17
7th PreAlg - L47--Jan17jdurst65
 
Exercise set 3.7
Exercise set 3.7Exercise set 3.7
Exercise set 3.7math265
 
Mathematicalfoundationofcomputerscience
MathematicalfoundationofcomputerscienceMathematicalfoundationofcomputerscience
Mathematicalfoundationofcomputersciencejntuworld
 
March 17, 2015
March 17, 2015March 17, 2015
March 17, 2015khyps13
 
FUNCTION- Algebraic Function
FUNCTION- Algebraic FunctionFUNCTION- Algebraic Function
FUNCTION- Algebraic FunctionJanak Singh saud
 
Admission for b.tech
Admission for b.techAdmission for b.tech
Admission for b.techEdhole.com
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadraticsmrodolewicz
 

Tendances (18)

Exercise 2
Exercise 2Exercise 2
Exercise 2
 
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...
[Question Paper] Logic and Discrete Mathematics (Revised Course) [January / 2...
 
Chapter 3 classroom
Chapter 3 classroomChapter 3 classroom
Chapter 3 classroom
 
Day 7 examples u6w14
Day 7 examples u6w14Day 7 examples u6w14
Day 7 examples u6w14
 
10 mathfinal2011review
10 mathfinal2011review10 mathfinal2011review
10 mathfinal2011review
 
Lec9
Lec9Lec9
Lec9
 
7th PreAlg - L47--Jan17
7th PreAlg - L47--Jan177th PreAlg - L47--Jan17
7th PreAlg - L47--Jan17
 
Exercise set 3.7
Exercise set 3.7Exercise set 3.7
Exercise set 3.7
 
Doc 20180130-wa0004
Doc 20180130-wa0004Doc 20180130-wa0004
Doc 20180130-wa0004
 
Mathematicalfoundationofcomputerscience
MathematicalfoundationofcomputerscienceMathematicalfoundationofcomputerscience
Mathematicalfoundationofcomputerscience
 
Lec8
Lec8Lec8
Lec8
 
March 17, 2015
March 17, 2015March 17, 2015
March 17, 2015
 
FUNCTION- Algebraic Function
FUNCTION- Algebraic FunctionFUNCTION- Algebraic Function
FUNCTION- Algebraic Function
 
Admission for b.tech
Admission for b.techAdmission for b.tech
Admission for b.tech
 
Doc 20180130-wa0006
Doc 20180130-wa0006Doc 20180130-wa0006
Doc 20180130-wa0006
 
Introduction to curve
Introduction to curveIntroduction to curve
Introduction to curve
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadratics
 
Day 6 examples
Day 6 examplesDay 6 examples
Day 6 examples
 

Similaire à Ee693 sept2014quizgt2

Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsemGopi Saiteja
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.pptjvjfvvoa
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematicsMark Simon
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryMark Simon
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Improving the initial values of VFactor suitable for balanced modulus
Improving the initial values of VFactor suitable for  balanced modulus Improving the initial values of VFactor suitable for  balanced modulus
Improving the initial values of VFactor suitable for balanced modulus IJECEIAES
 
A New Deterministic RSA-Factoring Algorithm
A New Deterministic RSA-Factoring AlgorithmA New Deterministic RSA-Factoring Algorithm
A New Deterministic RSA-Factoring AlgorithmJim Jimenez
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notationsajinis3
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Kai Katsumata
 
Size Measurement and Estimation
Size Measurement and EstimationSize Measurement and Estimation
Size Measurement and EstimationLouis A. Poulin
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanationsGopi Saiteja
 
Longest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisLongest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisRex Yuan
 

Similaire à Ee693 sept2014quizgt2 (20)

Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
 
Discrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata TheoryDiscrete Math IP4 - Automata Theory
Discrete Math IP4 - Automata Theory
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
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
 
Software Metrics
Software MetricsSoftware Metrics
Software Metrics
 
Improving the initial values of VFactor suitable for balanced modulus
Improving the initial values of VFactor suitable for  balanced modulus Improving the initial values of VFactor suitable for  balanced modulus
Improving the initial values of VFactor suitable for balanced modulus
 
A New Deterministic RSA-Factoring Algorithm
A New Deterministic RSA-Factoring AlgorithmA New Deterministic RSA-Factoring Algorithm
A New Deterministic RSA-Factoring Algorithm
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
 
Size Measurement and Estimation
Size Measurement and EstimationSize Measurement and Estimation
Size Measurement and Estimation
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
Longest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisLongest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm Analysis
 
algo1
algo1algo1
algo1
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 

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
 
Ee693 questionshomework
Ee693 questionshomeworkEe693 questionshomework
Ee693 questionshomework
 
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
 

Dernier

Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsDILIPKUMARMONDAL6
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptxNikhil Raut
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 

Dernier (20)

Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teams
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptx
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 

Ee693 sept2014quizgt2

  • 1. EE693 DATA STRUCTURES AND ALGORITHMS QUIZ-GT-2 EXAMINATION 25 OCTOBER, 2014, Time: 1 Hours EEE Department, IIT Guwahati NOTE: Attempt and solve all the questions. Question-1 to Question-16 are fill in the blank questions. 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. All the questions are of 2 marks. Question 16 is for 2 Bonus Marks. You should attempt it after solving all the other problems (Questions 1-15). Name: Roll No: 1. This is the welcome question! All the best for EE693 Quiz-2 (GT). Let A be a square matrix of size n x n. Consider the following program. The expected output is ⋯⋯ C = 100 for i = 1 to n do for j = 1 to n do { Temp = A[i][j] + C A[i][j] = A[j][i] A[j][i] = Temp - C } for i = 1 to n do for j = 1 to n do Output(A[i][j]); 2. The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable are ⋯⋯. 3. You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. In that case, the tightest upper bound for the worst case performance is ⋯⋯ 4. The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is ⋯⋯ 5. Consider two strings A = qpqrr and B = pqprqrp. Let x be the length of the longest common subsequence (not necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A and B. Then x + 10y = ⋯⋯⋯ 6. Suppose P,Q,R,S,T are sorted sequences having lengths 20,24,30,35,50 respectively. They are to be merged into a single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the worst case by the optimal algorithm for doing this is ⋯⋯⋯ 7. Consider the following pseudo code. The total number of multiplications to be performed is ⋯⋯⋯ D = 2 for i = 1 to n do for j = i to n do for k = j + 1 to n do D = D * 3 8. Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5,28,19,15,20,33,12,17,10. The maximum, minimum, and average chain lengths in the hash table, respectively, are ⋯⋯⋯ 9. A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10,8,5,3,2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is ⋯⋯⋯
  • 2. 10. Consider a rooted Binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having having exactly 4 nodes O(na Log(nb )). Then the value of a + 10b is ⋯⋯⋯ 11. Let P be a QuickSort Program to sort numbers in ascending order using the first element as pivot. Let t1 and t2 be the number of comparisons made by P for the inputs {1,2,3,4,5} and {4,1,5,3,2} respectively. The relationship between t1 and t2 is ⋯⋯⋯ 12. Consider the following C function in which size is the number of elements in the array E. The value returned by the function MyX is ⋯⋯⋯ int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for (i = 0; i < size; i++) Y = Y + E[i]; for (i = 0; i < size; i++) for (j = i; j < size; j++) { Z = 0; for (k = i; k <= j; k++) Z = Z + E[k]; if (Z > Y) Y = Z; } return Y; } 13. The maximum height of any AVL-tree with 7 nodes is ⋯⋯⋯. Assume that the height of a tree with a single node is 0. 14. The worst case possible height of AVL tree is ⋯⋯⋯ 15. The worst case possible height of Red-Black tree is ⋯⋯⋯ 16. (Bonus Question) A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is ⋯⋯⋯ All the best for next week quiz.