Knowee
Questions
Features
Study Tools

Question 5: Index or Key Sorting [1 CA Mark]Consider that we have got a big matrix/2d list of data like this that should be sorted: The number of rows could easily be a few thousand.  Typical sort algorithms have got 2 problems to handle such a case:1 -  Many sorting keys, for instance, back to the table above, if the ‘company’ is the same for a few records, the algorithm should refer to ‘body_style’ and then the next columns to decide.2 -  Displacement of big records of data to sort the table is time-consuming. You are going to develop a sort algorithm to address both concerns:·    We use selection or merge sort as the base of our algorithm. (other sort algorithms can be used too)·    To compare 2 records, your code should compare the  1st column firstly, if they are equal the 2nd column should be considered, again in the case of equality it should refer to the next column. Although in many cases just the 1st column is enough to decide.·    To make the algorithm faster, we add an index or key array. The length of that is equal to the number of rows/records of the main table (n), and would be initiated with the record number or 0 to n-1:  Results:Your function just should return a sorted index list and this would be tested to see if it works properly or not.

Question

Question 5: Index or Key Sorting [1 CA Mark]Consider that we have got a big matrix/2d list of data like this that should be sorted: The number of rows could easily be a few thousand.  Typical sort algorithms have got 2 problems to handle such a case:1 -  Many sorting keys, for instance, back to the table above, if the ‘company’ is the same for a few records, the algorithm should refer to ‘body_style’ and then the next columns to decide.2 -  Displacement of big records of data to sort the table is time-consuming. You are going to develop a sort algorithm to address both concerns:·    We use selection or merge sort as the base of our algorithm. (other sort algorithms can be used too)·    To compare 2 records, your code should compare the  1st column firstly, if they are equal the 2nd column should be considered, again in the case of equality it should refer to the next column. Although in many cases just the 1st column is enough to decide.·    To make the algorithm faster, we add an index or key array. The length of that is equal to the number of rows/records of the main table (n), and would be initiated with the record number or 0 to n-1:  Results:Your function just should return a sorted index list and this would be tested to see if it works properly or not.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The question is asking you to develop a sorting algorithm that can handle a large 2D list or matrix of data. The algorithm should be based on either selection sort or merge sort, but other sorting algorithms can also be used.

The algorithm should compare records based on the first column initially. If the values in the first column are equal, then it should compare the second column, and so on. However, in many cases, the first column will be enough to decide the order of the records.

To make the algorithm faster, you should add an index or key array. This array should have the same length as the number of rows or records in the main table (n), and should be initialized with the record number or 0 to n-1.

The function you develop should return a sorted index list. This list will be tested to see if your function works properly.

This problem has been solved

Similar Questions

A significant benefit to using an index to hold and sort keys to a file is:Question 10Select one:a.Smaller keys require less I/Ob.The entire sort can always be completed in memoryc.The head of the disk drive does not need to moved.There is no seek time added to the latency of I/O operations

Which of the following sorting methods would be most suitable for sorting a list which is almost sorted?

Which of the following sorting methods would be most suitable for sorting a list which is almost sorted?ans.

Question 1A data analyst at a high-tech manufacturer sorts inventory data in a spreadsheet. They sort all data by ranking in the Order Frequency column, keeping together all data across rows. What spreadsheet tool are they using? 1 pointSort SheetSort TogetherSort RowsSort Column

Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.