Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(a) Explain, and give pseudo-code for, the mergesort algorithm to sort an array A[ ] of integers into ascending order. Show the working of the

image text in transcribed

(a) Explain, and give pseudo-code for, the mergesort algorithm to sort an array A[ ] of integers into ascending order. Show the working of the algorithm on the array A = [ 4 8 9 2 1 736 ]. Give the tree representing the execution of the algorithm. State the worst case runtime of mergesort, of an array of n entries, in big-Oh notation, and give a justification of your answer. (9 marks) (b) Explain, and give pseudo-code for, the quicksort algorithm to sort an array A[ ] of integers into ascending order. Both mergesort and quicksort are in the divide-and-conquer class of algorithms, but differ in their approach to this. Briefly, describe how they take a different approach to the 'divide' and to the 'conquer' steps. (7 marks) (c) Suppose that the pivot is selected randomly from within the array. Briefly outline a proof that the resulting average case complexity is O(n log n) (4 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

Summarize the key provisions of WTO.

Answered: 1 week ago