Question

In: Computer Science

1. If we view the selection sort as an application of "divide and conquer" strategy, what...

1. If we view the selection sort as an application of "divide and conquer"

strategy, what is the two-part partitioning of the index range [0, n)? Is it a balanced partition?

2. For the "divide and conquer" strategy for developing algorithm, do we pursue

balanced partitioning or unbalanced partitioning? Why?

3. For the quicksort, the selection of pivot determines the quality of partitioning.

Do we have any easy or cheap way for selecting a good pivot that always leads

to a very balanced partition?

Solutions

Expert Solution

1.If we see selection sort as application of divide and conquer strategey then in this the two divisions are sucth that first section includes larger element and other section includes n-1 elements.

This partitioning is not balanced partitioning as in balaced partioitoning there is an equal division or we can say that division takes place such that the algorithm runs asymtotically fast but in this division takes place like n-1,n-2 and so on.

2.We prefer balanced partitioning over unbalanced partitioning for divide and conquer starategy as if the partitioning is balanced, the algorithm runs asymptotically as fast as merge sort. If the partitioning is unbalanced, however, it can run asymptotically as slow as insertion sort.

3.If we want balanced partitioning in quick sort then pivot element should be the middle element i.e in every partiotion pivot element lies in middle.This will lead to partition such as n-1/2.

I hope my answer met all your requirements.

THANKYOU!


Related Solutions

a. Develop a divide-and-conquer algorithm to perform a parallel merge sort of an array. Hint: After...
a. Develop a divide-and-conquer algorithm to perform a parallel merge sort of an array. Hint: After division, each process sorts its part of the array using an efficient algorithm. Then, the subarrays are merged into larger sorted subarrays. b. Analyze the communication and computation times if the number of processes is equal to the number of array elements, n. c. Repeat Part b if the number of processes is less than the number of array elements. Assume that the computation...
Divide and conquer problem. Suppose we are given two sorted arrays A[1 . . . n]...
Divide and conquer problem. Suppose we are given two sorted arrays A[1 . . . n] and B[1 . . . n] and an integer k. Describe an algorithm to find the kth smallest element in the union of A and B in O(log n) time. For example, if k = 1, your algorithm should return the smallest element of A ∪ B; if k = n, your algorithm should return the median of A ∪ B.) You can assume...
Step (D) of the divide-and-conquer strategy (i.e. combine the solutions to smaller instances of the problem...
Step (D) of the divide-and-conquer strategy (i.e. combine the solutions to smaller instances of the problem to obtain the solution of the original instance) is not a necessary step for this design strategy. Mergesort is an example of such cases. Select one: True False
Create a Java Application that implements a Selection sort algorithm to sort an array of 20...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20 unsorted numbers. You should initiate this array yourself and first output the array in its original order, then output the array after it has been sorted by the selection sort algorithm. Create a second Java Application that implements an Insertion sort algorithm to sort the same array. Again, output the array in its original order, then output the array after it has been sorted...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20 unsorted numbers. You should initiate this array yourself and first output the array in its original order, then output the array after it has been sorted by the selection sort algorithm.
• You should use the divide-and-conquer strategy and write multiple functions. • You should always use...
• You should use the divide-and-conquer strategy and write multiple functions. • You should always use arrays for the data sequences. • You should always use const int to define the sizes of your arrays. a. Write a C++ program. The program first asks the user to enter 4 numbers to form Sequence 1. Then the program asks the user to enter 8 numbers to form Sequence 2. Finally, the program shall tell which sequence has a larger average. For...
1. programmers often refer to a _____ search as a "divide and conquer" procedure a. bubble...
1. programmers often refer to a _____ search as a "divide and conquer" procedure a. bubble b. binary c. division d. split 2. you can add an item at any point in a _______ container and the array size expands automatically to accomodate the new item a. arraylLst b. Array c. ResizableArray d. array 3.int[][] myVals = {{2,4,6,8},{20,40,60,80}; Using the above two dimensional array, what is the value of myVals[1][2]? a. 4 b.60 c. 6 d.40
In class we saw that the fast divide and conquer integer multiplication method takesO(nlog3) time. Thisis...
In class we saw that the fast divide and conquer integer multiplication method takesO(nlog3) time. Thisis because the the shifts and additions can be done in time O(n). Suppose we use a very inefficient method for doingthe shifts and additions, so these take timeO(n2). With this slower method for doing the shifts and additions, figureout how much time will the divide and conquer integer multiplication method take . You can assume that nothing elsechanges in the divide and conquer integer...
Exercise 1: (Divide and Conquer: Binary tree traversal) Write pseudocode for one of the classic traversal...
Exercise 1: (Divide and Conquer: Binary tree traversal) Write pseudocode for one of the classic traversal algorithms (preorder, inorder, and postorder) for binary trees. Assuming that your algorithm is recursive, find the number of recursive calls made.
Design and analyze a divide-and-conquer algorithm for finding the maximum element in a list: L[0: n – 1].
The following submission rules apply:·    For those questions requiring programs, the solutions must be implemented using JavaScript or Java.o Appropriate self-documenting comments in the source code are mandatory, consistent with good programming practices.o Solutions must be provided in plain text so that formatting is not lost.·    All answers must be provided in this document.·    Sources must be given accurate and complete citations sufficient for the instructor to find and confirm them.Design and analyze a divide-and-conquer algorithm for finding the maximum...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT