SlideShare a Scribd company logo
1 of 2
Download to read offline
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.

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

More from 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
 
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
 

Recently uploaded

Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
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
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
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
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 

Recently uploaded (20)

Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
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
 
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
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
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...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 

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.