Question

Q3) Apply Quick sort algorithm to sort the following Array (Show complete steps, and show the...

Q3) Apply Quick sort algorithm to sort the following Array (Show complete steps, and show the values of p,r and q)

7 13 5 2 4 10 15 6 3 6


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hence the Quick sort algorithm is implemented as above in the given example with the values of i,c,p that is index, current and pivot elements.

Add a comment
Know the answer?
Add Answer to:
Q3) Apply Quick sort algorithm to sort the following Array (Show complete steps, and show the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • Show the execution of the selection sort algorithm on the following array. Hint: The yellow or...

    Show the execution of the selection sort algorithm on the following array. Hint: The yellow or shaded squares should be the remaining unsorted values. Pass # 0 1 2 3 4 5 6 7 0 16 11 21 32 41 20 3 9 1 2 3 4 5 6 7 Show the execution of the insertion sort algorithm on the following array. Hint: The yellow or shaded squares should be the remaining unsorted values. Pass # 0 1 2 3...

  • . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply...

    . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply that to the following array. Show your work in Detail. [15 points] 45 20 50 10 80 30 60 70 40 90 2. Is Shell sort a stable sorting algorithm? Answer this with an example. [10 points] 3. Apply Merge Sort to sort the following list. Show your work in Detail. [15 Points] 45 20 50 10 80 30 60 70 40 90 4....

  • 2. Consider your ID as an array of 9 elements, apply an insertion sort algorithm to...

    2. Consider your ID as an array of 9 elements, apply an insertion sort algorithm to sort the numbers in descending order. Show your steps. Example ID: 201710340 Array: 2 0 7 0 1 1 0 3 4

  • Please come up with an array of 9 random integers then sort the array. Show the...

    Please come up with an array of 9 random integers then sort the array. Show the contents of the array each time a sorting algorithm changes it while sorting the array into ascending order. The 6 sorting algorithm we are using are: 1. Selection Sort 3 points 2. Insertion Sort 3 points 3. Shell Sort 6 points 4. Bubble Sort 3 points 5. Merge Sort 10 points 6. Quick Sort 10 points It is OK to do this assignment on...

  • 6) Assume that we are using quick sort algorithm to sort the following elements in the...

    6) Assume that we are using quick sort algorithm to sort the following elements in the array 26, 15,30,11,8,17 22, 40, 4, 10. Use the first element in the array as pivot. (20 pts.) 1- How total iterations it would take to complete the sorting process? 2- Simulate the entire sorting process. (If you need additional space, complete it at the other side of the paper) public static void quick_sort(intl] a, int left, int right) if (left < right) (...

  • 1.Show the state of the following array after the outer loop of the bubble sort algorithm...

    1.Show the state of the following array after the outer loop of the bubble sort algorithm has executed one time. [0] [1] [2] [3] [4] [5] 19 23 2 4 99 1 2. Show the state of the following array after the outer loop of the selection sort algorithm has executed two times. [0] [1] [2] [3] [4] [5] 12 1 9 23 17 11 3. Show the state of the following array after the outer loop of the insertion...

  • JAVA Objectives: 1. Apply linear search algorithm 2. Apply select sort algorithm 3. Apply array iteration...

    JAVA Objectives: 1. Apply linear search algorithm 2. Apply select sort algorithm 3. Apply array iteration skill Problem description: Write the following eight methods and write a main function to test these methods // return the index of the first occurrence of key in arr // if key is not found in arra, return -1 public static int linearSearch(int arr[], int key) // sort the arr from least to largest by using select sort algorithm public stati void selectSort(int arr[])...

  • Sorting algorithm: quick sort Exercise One (20 marks) Given the following program body for implementing Quick...

    Sorting algorithm: quick sort Exercise One (20 marks) Given the following program body for implementing Quick sort, complete the program by writing code where required import java.util.Random; public class QuickSort public void quickSectlinti] A) QuickSort/A, O, A.length-1); private void guickSortlin Aiat low.int high) //Complete the code for the quicksort method (5 marks] private void swaplint[] a, int indexl, int index2) //Complete the code for the swap method [3 marks] private int setPivotlint low, int high) Random rand = new Random();...

  • 1. Show the steps in order to sort {11,5,6,3,8,1,9,2} using Mergesort algorithm. 2. Show the element...

    1. Show the steps in order to sort {11,5,6,3,8,1,9,2} using Mergesort algorithm. 2. Show the element sequences of running Shellsort on the input {15,2,8,1,10,7,4,3,9,11,12,6} at the increments {7, 3, 1}, respectively. 3. Show the steps in details of sorting {15, 2, 8, 1, 10, 7, 4, 3, 9, 11, 12, 6} using quicksort with median-of-three partitioning and a cutoff 3 (if the elements are less than 3, using insertion sort).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT