Question: Figure 2 shows a Java implementation of mergesort whose input is a linked list. Answer the following questions. Figure 2 . An implementation of mergesort

Figure 2 shows a Java implementation of mergesort whose input is a linked list.
Answer the following questions.
Figure 2. An implementation of mergesort of which an input is a linked list.
(1) The following codes sort the list A, and print all the elements of A from its head to
tail. (Note that A. getHead() and A.getTail() return the head and tail nodes of
A, respectively.) However, when you print the sorted list using the following codes,
you can find out the function mergeSort () does not work correctly.
Why does mergeSort () work incorrectly? How can you fix mergeSort () to make
the function work correctly? [10 points]
(2) Let n be the length of an input linked list. How many times is mergeSort()
called to sort the list? The initial call of the function should be included. [10 points]
 Figure 2 shows a Java implementation of mergesort whose input is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!