- Particles
- Linear Sorts
- Skyline Queries Project Report
- 15-150703-Design and Analysis of Algorithms.pdf
- 8.Quick Sort
- Studying for a Tech Interview Sucks
- VTU ADA MODEL QUESTION PAPER
- VANIDAALECTURENOTES.pdf
- This is My Technical Interview Cheat Sheet
- Shorts
- Dutch National Flag
- Future First
- Data Structures Viva Questions
- lec10
- Test Bank Ninth Edition
- gs_devn
- Lect 6
- R-lang
- Excel Dynamic Named Ranges.docx
- Data Structure - Shrivastava - Ibrg
- CS145
- RHINO GRASSHOPPER. Www.woojsung.com TUTORIAL Woo Jae Sung
- Samples
- Thoery of Matrices Mac Duffee
- Cpphtp4 PPT 04
- Notes
- mca sem1 mc9217lm
- CSCE-206-505
- unit1-sp
- Sorting
- 1.1 Round Off Errors:
- Sequences Series and Convergence
- Truncation Errors
- 1.3. Truncation Errors: 1.3.1. Exercises: Following Are Some Known Results

Faculty of Engineering

Department of Computer Science & Engineering In Class Quiz B.Sc. Engineering, Level 2, Semester II (CS2020) Question 1 Let in the usual notation. 1. 2. 3. 4. be a finite array of integers. Consider the following sorting algorithm 18th March 2009

a) Write pseudo code to perform the exchange operation of the above algorithm (line 4). The method signature would be and a call to this method will th th exchange the element of A with element of . b) Considering the integer nature of the array elements, do you think it is possible to write the exchange operation without the need of an additional variable? If so, write pseudo code for the new implementation of the exchange method. Use the same method declaration as in part a). c) What is the significance of limiting the maximum of to – d) Perform the above algorithm on only. Question 2 a) Two sorting algorithms, and , have asymptotic running times of and ? in the inner for loop? and

. Give steps for

. Which algorithm do you think would be efficient with the growth of Briefly explain your answer.

b) If either or is more efficient than the other, based on the asymptotic running times, then will there be any usage of the “inefficient” algorithm in practice? Briefly explain your answer. c) Let be a finite array of integers. Consider the following insertion sort algorithm in the usual notation.

© Saliya Ekanayake WSO2 Inc.

1. 2. 3. 4. 5. 6. 7. i) What can you say about the elements in loop of lines 1 – 7? for any iteration of the for

ii) How can we incorporate insertion sort with merge sort to improve the efficiency of sorting? d) Suggest a method to merge two separately sorted integer arrays into one final array. No need to write pseudo code, an example based explanation is sufficient. Hint: think of the smallest element of a sorted array. Question 3 a) Let be a finite array of integers. Let be the starting index and be the ending index of (i.e. and ). Consider the following partition algorithm associated with quick sort in the usual notation. 1. 2. 3. 4. 5. 6. 7. 8. For any iteration of the loop in lines 3 – 6 and for any index, of what can you say about the value of with respect to , under the following conditions of ? i) ii) iii) b) What can you say about the position of the pivot element after the completion of the partition algorithm? © Saliya Ekanayake WSO2 Inc.

c) Answer the following questions based on your knowledge on max heaps and heap sort algorithm. i) Explain what is meant by a heap data structure? ii) State the property that should be satisfied by a heap in order to become a max heap. iii) Draw a tree view for the following heap.

16 14 10 8 7 9 3 2 4 1

th

d) We can use the following node of a heap. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

algorithm to make the sub tree rooted at

i) What assumption should hold true in order for the ii) What is the purpose of checking lines 3 and 6? iii) Apply for and tree view.

to be successful? and in

. Show steps based on the

© Saliya Ekanayake WSO2 Inc.

- ParticlesUploaded byusmanzubair
- Linear SortsUploaded byMohammed Jeelan
- Skyline Queries Project ReportUploaded bySaptarshi Gan
- 15-150703-Design and Analysis of Algorithms.pdfUploaded byHarshang Rana
- 8.Quick SortUploaded byHaris Muhibic
- Studying for a Tech Interview SucksUploaded byJoy Rahman
- VTU ADA MODEL QUESTION PAPERUploaded byvturesource
- VANIDAALECTURENOTES.pdfUploaded byAbi Haris Hafiz
- This is My Technical Interview Cheat SheetUploaded byAshish
- ShortsUploaded bykepler1729
- Dutch National FlagUploaded byJohn Jairo Silva
- Future FirstUploaded byparth-gupta-3041
- Data Structures Viva QuestionsUploaded bySumathi Kanna
- lec10Uploaded byOjasvi Monga
- Test Bank Ninth EditionUploaded byhamed
- gs_devnUploaded byjonhinno
- Lect 6Uploaded byGeeta Patil
- R-langUploaded byAnonymous jbGc8elR
- Excel Dynamic Named Ranges.docxUploaded bySohaib Abdullah
- Data Structure - Shrivastava - IbrgUploaded byLaxmi Devi
- CS145Uploaded byNivedita Mittal
- RHINO GRASSHOPPER. Www.woojsung.com TUTORIAL Woo Jae SungUploaded byapi-26010409
- SamplesUploaded bydieuna
- Thoery of Matrices Mac DuffeeUploaded bySandy
- Cpphtp4 PPT 04Uploaded byMuhammad Rana Farhan
- NotesUploaded byVinamra Mittal
- mca sem1 mc9217lmUploaded byapi-251853647
- CSCE-206-505Uploaded byfolwanmojo
- unit1-spUploaded byhrsli
- SortingUploaded byrubikmail8218