- Introduction to Challenges
- Insertion Sort 1
- Insertion Sort Itself
- Correctness and the Loop Invariant
- Running Time
Counting Sort 1
- Simple Counting Sort
- Prepare for Full Counting Sort
- The Full Counting Sort
- Simple Quick Sort
- Quick-Sort Advanced
- Quick Sort Running Time
Input Format for standard Sorting Challenges:
- t - the number of test cases
- s - the size of the array
- ar - the list of integers
The Full Counting Sort
In this challenge you need to print the data that accompanies each integer in a list. In addition, if two strings have the same integers, you need to print the strings in their original order. This means your sorting algorithm will need to be stable, i.e. that the original order is maintained for equal elements.
In the previous challenge, you created a “helper array” that contains information about the starting position of of each element in a sorted array. Can you use this array to help you create a sorted array of the original list?
Hint: You can go through the original array to access the strings. You can then use your helper array to help determine where to place those strings in the sorted array. Be careful about being one off.
You will be given a list that contains both integers and strings. Can you print the strings in order of their accompanying integers? If the integers for two strings are equal, make sure to print them in the order they appeared in the original list.
t - the number of test cases. t cases follow:
n - the size of the list ar.
n lines follow, each containing an integer x, and a string, s.
Print the strings in their correct order.
Print the characters according to the order of their accompanying integers.
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.
mikeAug 31, 2:51 PM