Question

1. Which is the best sorting algorithm for larger arrays if all the items can not...

1.

Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory?

selection sort

insertion sort

quicksort

Merge sort

2.

Which sorting algorithm sorts items without comparing them?

quick sort

radix sort

merge sort

Insertion sort

3

What is the average running time for quicksort?

O(n2)

O(logn)

O(nlogn)

O(n)

O(n2logn)

4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided:

  1. Recursively divide an array into two equal halves.
  2. Once the array can no longer be subdivided, put the halves back together; while doing so, sort the halves into a temporary array.
  3. Copy the temporary array back into the original array.

quick sort

radix sort

insertion sort

shell sort

Merge Sort

5. In the quicksort algorithm, why is the insertion sort algorithm used when the list becomes small?

Quicksort will not work on arbitrarily small lists.

Insertion sort is more efficient when the list is small.

Using insertion sort ensures a stable sort.

Quicksort cannot partition smaller arrays

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

1)Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory?

Ans) Merge sort

Explanation: for example you have to sort 1 GB of data with only 100 MB of available main memory. in this case this is the most appropriate algoritham is this merge sort

2)Which sorting algorithm sorts items without comparing them?

Ans)radix sort

Explanation: non-comparison based sorting algorithms like Radix Sort, Counting Sort, and Bucket Sort

3)What is the average running time for quicksort?

Ans)O(n log n)

Explanation: worst case - o(n2)

best case - o(n)

4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided:

Ans)Merge Sort

Explanation:

  1. Recursively divide an array into two equal halves.
  2. Once the array can no longer be subdivided, put the halves back together; while doing so, sort the halves into a temporary array.
  3. Copy the temporary array back into the original array.

5) In the quicksort algorithm, why is the insertion sort algorithm used when the list becomes small?

Ans)Insertion sort is more efficient when the list is small.

explanation : more than quick sort insertion sort is best when list size is small

Add a comment
Know the answer?
Add Answer to:
1. Which is the best sorting algorithm for larger arrays if all the items can not...
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
  • Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case...

    Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case run (a) Heap sort (b) Merge sort (c) Quick sort (d) Insertion sort 18. Which statement below is false: (a) Quick uick sort and merge sort are divide and conquer algorithte (b) Counting sort is a linear time sorting algorithm. (e) Insertion sort and quicksort have similar best case (d) Generic minimum spanning tree algorithm is 19. Counting sort and radix sort are linked...

  • 8 Sorting Algorithms: Bubble, selection, insertion, quick, merge, bucket, radix, counting. 1. A..Which of the above...

    8 Sorting Algorithms: Bubble, selection, insertion, quick, merge, bucket, radix, counting. 1. A..Which of the above sorting algorithms does TimSort use? 2. Which of the above algorithms sort a REVERSE ORDER list in O(n2 ) (worst case)? 3. Which of the above algorithms sort a REVERSE ORDER list in O(nlogn) (worst case)? 4. Which of the above algorithms sort an ordered list , a reverse ordered list, and a random list (all three) in 0(nlogn) (worst case)? 5. Which of...

  • Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30...

    Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30. What is an execution frame? What is an activation record? What is contained in it? 31. Write a recursive Java method that computes the factorial of a number 2. Linear search may require up to comparisons while binary search will only require roughly comparisons 33. Sort sorts a list of values by repetitively putting a particular value into its final, sorted,...

  • . 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....

  • True or False? 1. Radix sort is a general-purpose sorting algorithm. 2. Insertion sort is not...

    True or False? 1. Radix sort is a general-purpose sorting algorithm. 2. Insertion sort is not efficient for large arrays. 3. You cannot partition a chain of linked nodes. 4. The n-queens problem requires an n x n chessboard and uses the rules of chess to create a solution.

  • Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. E...

    Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. Execute the sort algorithms against the same list, recording information for the total number of comparisons and total execution time for each algorithm. Try several different lists, including at least one that is already in sorted order. ---------------------------------------------------------------------------------------------------------------- /** * Sorting demonstrates sorting and searching on an...

  • 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();...

  • Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the ...

    Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...

  • 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...

  • ?PLEASE READ CAREFULLY QUESTION #1 I’m doing a project which requires you to implement 4 sorting...

    ?PLEASE READ CAREFULLY QUESTION #1 I’m doing a project which requires you to implement 4 sorting algorithms. Bubble sort pair-wise, Bubble sort list-wise a.k.a selection sort, merge sort, and quick sort. These 4 sorting methods takes in an array of strings and sorts them alphabetically from a-z. I have all 4 sorting algorithms working fine, but I still need to fill out the table. There’s only one section I need help filling out. I basically need help filling out the...

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