Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Which of the following is the correct pseudocode for a merge sort?
For each element in the collection While there is a next element Compare the next unsorted element with the sorted elements Merge the element into the correct position in the sorted elements
While there are unsorted numbers Find the smallest unsorted number Merge the element at the end of the sorted elements
If there are at least two elements in the collection, partition the collection into unsorted and sorted Find the next element in the unsorted Merge the element into the sorted partition
For each element in the collection Read the value of the item If the next value is lower, switch it with the previous item
If there is more than one element in the collection Break the collection into two halves Merge sort the left half Merge sort the right half Compare the two halves Merge the two subcollections into a sorted collection