Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 6 Choose the best sorting algorithm in the following scenarios AND write it's time complexity in that scenario. When the input is sorted A

image text in transcribed
image text in transcribed
image text in transcribed
QUESTION 6 Choose the best sorting algorithm in the following scenarios AND write it's time complexity in that scenario. When the input is sorted A Merge Sort B. Selection Sort When the available memory is limited. C.insertion sort D.Quick Sort QUESTION 7 Suppose the running time of applying Selection Sort on a given array is 1024ms. How much time do we need to spend using Merge sort to sort on the same array? Al QUESTIONS Assume that we call partition on an array of size 10, and the result after partitioning is: 532 11 15 21 12 17 60 What was the pivot? JA QUESTION 9 Assume I have an efficient method to compute median of an array in O(n). In this case, if I choose the median as the pivot, what would be the time complexity of quick sort? IA QUESTION 10 Please fill in the missing statement (one statement) to implement the partitioning process for Quick Sort? [A] public int partitionIt(int left, int right, long pivot) { int leftPtr = left - 1; // left (after ++) int rightPtr right; // right-1 (after --> while (true) { while (leftPtr right theArray(leftPtr+1) white (rightPtr > W theArrayI--rightPtr) > pivot) { if (leftPtr > rightPtr) // if pointers cross, break; // partition done else // not crossed, so swap(leftptr, rightptr); // swap elements // end while(true) swap(leftPtr, right); // restore pivot return leftPtr; // return pivot location // end partitionIt() QUESTION 11 Please fill in the missing codes to implement the enqueue method for a maximum priority queue implemented by an array, class PriorityQueue { // array in sorted order, from min at o to max at size-1 private int maxSize; private int Il gueAccay private int nItems; // public PriorityQueue int max) // constructor { maxSize = max; queAccay = new int (maxSize): nItems: } // public void enqueue(int iten) // enqueue an element // YOUR CODES } // public int dequeue() // dequeue the maximum elenent { return QueAccayl--nItems): }

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago