Question: PROBLEM 1 Given the following array: {24, 3, 27, 13, 34, 2, 50, 12} If the array were sorted using the version of mergesort presented

PROBLEM 1

Given the following array:

{24, 3, 27, 13, 34, 2, 50, 12} 

If the array were sorted using the version of mergesort presented in lecture, what would the array look like after the completion of the second call to the merge() methodthe method that merges two subarrays? Note: The merge method is the separate helper method; is not the recursive mSort method.

1. What would the array look like after the completion of the fourth call to the merge()method?

2. The initial call to the recursive mSort() method is made from within the mergeSort()wrapper method. This initial call to mSort() is not a recursive call, because the method is not calling itself. Rather, all recursive calls to mSort() are made from within mSort().

3. Assuming that the array has at least two elements, the initial invocation of mSort()makes two recursive calls (which in turn lead to other recursive calls, and so on). Starting with the initial array above, what would the array look like after the completion of the firstof these two recursive calls?

_____

PROBLEM 2

In lecture, we will look at two different implementations of the list ADT: ArrayList and LLList. For each of the following applications, decide which list implementation would be better for that particular application. Your should consider both time efficiency and space efficiency, and you should assume that both implementations have an associated iterator like the LLListIterator that we discussed in lecture. Explain your answers.

1. You need to store information about the gardening tools that you sell in your online store. To do so, you maintain a list of product records, each of which contains information about a single type of product, including how many copies of it you have in stock. You dont tend to change the types of tools that you sell, and thus items are seldom added or removed from the list. However, you need to update a products record whenever your inventory of that product changes (e.g., because someone purchases one!). A products position in the list is also its product ID, and therefore updating a record involves using the product ID to get the corresponding record and modifying its contents.

2. You need to maintain a list of tweets that are made by government officials in the current week. The number of tweets can vary widely from week to week in a way that is hard to predict. You start with an empty list at the start of the week, and as tweets are made you add them to the list. You need to frequently display the tweets in reverse chronological order from most recent to least recent.

3. You are responsible for maintaining a monthly list of events for an online arts calendar. The number of events is fairly consistent from month to month. Events are added to the list in chronological order, and you need to display them in that same order.

please helppp solving either one of the problems

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!