Sorting on several keys, Data Structure & Algorithms

Assignment Help:

Thus far, we have been considering sorting depend on single keys. However, in real life applications, we may desire to sort the data on several keys. The simplest instance is that of sorting a deck of cards. The first key for sorting is the suit-clubs, diamonds, spades and hearts. Then, inside each of suit, sorting the cards into the ascending order from Ace, twos to king. Thus this is a case of sorting on 2 keys.

Now, it can be done in two ways.

1 •   Sort 52 cards within 4 piles according to the suit.

   •   Sort each of 4 piles according to face value of the cards.

2 •   Sort 52 cards within 13 piles according to face value.

   •   Stack these piles in order and then sort into 4 piles depend on suit.

The first method is called the as MSD (Most Significant Digit) sort & second method is called as the LSD (Least Significant Digit) sort. Digit stands for key. Although they are called as sorting methods, MSD & LSD sorts only choose the order of sorting. The sorting could be done by any of the sorting methods discussed in this unit.


Related Discussions:- Sorting on several keys

Sorting, Retrieval of information is made simpler when it is stored into so...

Retrieval of information is made simpler when it is stored into some predefined order. Therefore, Sorting is a very important computer application activity. Several sorting algorit

Binary search tree (bst), Q. Explain what do we understand by Binary Search...

Q. Explain what do we understand by Binary Search Tree (BST)? Make a BST for the following given sequence of the numbers. 45, 32, 90, 21, 78, 65, 87, 132, 90, 96, 41, 74, 92

Linked list, write an algorithm for multiplication of two sparse matrices u...

write an algorithm for multiplication of two sparse matrices using Linked Lists

Algorithm for determining who won rock paper scissors game, Suppose you are...

Suppose you are given the results of 5 games of rock-paper-scissors. The results are given to you on separate pieces of paper; each piece says either 'A' if the first person won, o

Efficiency of binary search, Each of the comparison in the binary search de...

Each of the comparison in the binary search decrease the number of possible candidates where the key value can be searched by a factor of 2 as the array is divided into two halves

What are the different ways of representing a graph, What are the different...

What are the different ways of representing a graph? The different ways of representing a graph is: Adjacency list representation: This representation of graph having of an

Adjacency matrix representation of a graph, An adjacency matrix representat...

An adjacency matrix representation of a graph cannot having information of : Parallel edges

Determine the stereo vision, Determine the stereo vision There is still...

Determine the stereo vision There is still one more major item missing, before we can look at a computer display or plot and perceive it just as we see a real object, namely th

Advantages of the last in first out method, Materials consumed are priced i...

Materials consumed are priced in a systematic and realistic manner. It is argued that current acquisition costs are incurred for the purpose of meeting current production and sales

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd