Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.1: There are two parts to this problem (HW4.1A,HW4.1B) 4.1A: Draw the decision tree for Mergesort (Algorithm 4.5, Page 175), which uses Merge (Algorithm 4.4,

4.1: There are two parts to this problem (HW4.1A,HW4.1B) 4.1A: Draw the decision tree for Mergesort (Algorithm 4.5, Page 175), which uses Merge (Algorithm 4.4, Page 172) when n=3. To get this right, you'll have to carefully examine the code at the bottom of page 175; remember that array numbering starts at index zero, and that integer division *truncates* (it doesn't round). 4.1B: Based on *your* decision tree in 4.1A, determine the average number of comparisons done by Mergesort when n=3. (Do NOT try to plug into some formula; I am simply asking you to examine your decision tree and count the number of comparisons, taking a weighted average to find the exact answer.)

page # 175

image text in transcribed

page # 172image text in transcribed

This is the similar diagram on page 178, but the one needed to be drawn is slightly different:

image text in transcribed

The solution would be exactly what you need if you add the decision tree diagram mentioned in the problem.

Algorithm 4.5 Mergesort Input: Array E and indexes first, and last, such that the elements of Elil are defined for first si last. Output: Elfirst],..., Ellast] is a sorted rearrangement of the same elements. 2 void mergeSort(Element[] E, int first, int last) if (first

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

=+4. Discuss what you understand by the term change paradox.

Answered: 1 week ago

Question

How effective was the school improvement plan?

Answered: 1 week ago

Question

Data points include: surveys, discipline, demographics

Answered: 1 week ago

Question

What environmental factors influenced achievement?

Answered: 1 week ago