What is the running time of Heap Sort on an array that is already sorted? What about an array that is sorted into reverse order?Explain.
HeapSort will run for O(n log n) time. even though it is in the
sorted order. It will ignore the order of the input and sorts it
again
HeapSort will run for O(n log n) time for reverse order also as it
will consider the order of the input
Note : If you like my answer please rate and help me it is very Imp for me
What is the running time of Heap Sort on an array that is already sorted? What...
This program should test the running time of these algorithms: Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort Heap Sort You have access to the implementation of all of these sorting algorithms, and you may use what is provided in your text directly. Be sure to cite the source of these implementations in the header of your program. Please maintain the property that these sorting algorithms sort arrays in ascending order. For this homework, you will write a...
Design a flowchart to delete an element in a sorted array. Sort the array first if not already sorted. Please use a scanner and not a camera if you've drawn the flowchart by hand. Thanks!
What is big-theta runtime of Merge sort and Quicksort on an almost sorted array? i.e. the array is sorted except that two elements are swapped. Explain.
6
6. Merge Bubble Sort: a) How does the merge bubble sort break the array into sublists? b) What does it need to use for each sublist and then what does it do with all of the sublists? c) What is the Big-O notation for this sort? 7. Merge Sort: a) How does the merge sort use recursion to break the array into sublists? b) What happens to each of these sublists to get the final sorted list? c) What...
5. Answer the following.
(a) (5 points) Suppose you are given a maxheap of n unique
numbers. Explain where will the smallest of these n numbers be
located in the maxheap. Explain where will the second largest
number be located on this maxheap. Please be specific.
(b) (5 points) Suppose you are given an array A of n numbers,
where all the elements of the array are already sorted in
decreasing order. Is this a max-heap? Explain.
(c) (5 points)...
In java create a program to test and measure an actual running time of Insertion sort and Merge sort on your machine. Each sorting algorithm must be a separate method: a. Randomly generate 100 integers between 0 and 500. b. Store those integers in an array and display them on screen. c. Using each sorting algorithm, sort numbers and display the sorted numbers. The array must be passed as an argument to call a method. d. For each sorting algorithm,...
1. Consider the following unordered list: 20, 35, 25, 10, 40, 50, 45. Perform heap sort to sort this list in nondecreasing (ascending) order. a. Perform the bottom-up method to arrange these values into a max heap. Show the heapify operations on each relevant subtree. (10 points) b. Show the tree representation and the array representation of these numbers after every dequeue operation. Remember that dequeue does not delete a number. Dequeue will instead remove that number from the heap...
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity? Group of answer choices nsertion Sort with time complexity O(kn) Heap Sort with time complexity O(nLogk) Quick Sort with time complexity O(kLogk) Merge Sort with time...
Consider a variation of Merge sort called 4-way Merge sort. Instead of splitting the array into two parts like Merge sort, 4-way Merge sort splits the array into four parts. 4-way Merge divides the input array into fourths, calls itself for each fourth and then merges the four sorted fourths. a) Give pseudocode for 4-way Merge sort. b) State a recurrence for the number of comparisons executed by 4-way Merge sort and solve to determine the asymptotic running time.
Let us suppose that there are n elements in the un-sorted array. Answer the following? q1: How is merge sort different from quick sort? q2: What is the split ratio in merge sort? q3: What is the worst-case/average-case/best-case running time of Merge Sort? q4: Why is the worst case running time of Merge sort O(n log n) always? q5: Why does Merge Sort use a static tree in the recursion process? (It is worth noting that the Quick Sort use...