Question

2.1 Searching and Sorting- 5 points each 1. Run Heapsort on the following array: A (7,3, 9, 4, 2,5, 6, 1,8) 2. Run merge sort
4. Gi pseudocode for an algorithm that will solve the following problem an array A[1..n] that contains every number between 1
2.1 Searching and Sorting- 5 points each 1. Run Heapsort on the following array: A (7,3, 9, 4, 2,5, 6, 1,8) 2. Run merge sort on the same array. 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Explain what modifications we can make to quick sort to make it run faster, and why this helps.
4. Gi pseudocode for an algorithm that will solve the following problem an array A[1..n] that contains every number between 1 and n +1 in Given sorted order, except that one of the numbers is missing. Find the missing ive number. Your algorithm should run in time θ(log n). (Hint: Modify Binary search). A pseudocode means an algorithm with if statements and loops, etc. Don't just write a paragraph. Also, if your algorithm is unclear, please explain what it does
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 1C++ prog #inelude iostream>File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 31 32 / main function to doFile Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 37 heapify (arr, , i) 38 39Dev-C+ 5.2.0.2 File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 37 heapify (a

2.

File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes | ν.cpp 1C progran for Merge Sort/File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes | ν.cpp 27 while (i < ni && j < n2File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 56 57 58 59 60 61 1 is tor lFile Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes | ν.cpp 72 mergeSort (arr, l, ) 73Dev-C+ 5.2.0.2 File Edit Search View Project Execute Debug Tools CVS Window Help globala) Project Classes V.cpp 72 mergeSort

3.

File Edit Format View Help The answer depends on strategy for choosing pivot. In early versions of Quick Sort where leftmost

4.

File Edit Format View Help METHOD 1(Use sum formula) Algorithm 1. Get the sum of numbers totaln(n+1)/2 2. Subtract all the nu

Add a comment
Know the answer?
Add Answer to:
2.1 Searching and Sorting- 5 points each 1. Run Heapsort on the following array: A (7,3, 9, 4, 2,5, 6, 1,8) 2. Run merge sort on the same array. 3. What is the worst case for quick sort? What is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT