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

Define min-heap, Define min-heap A min-heap is a complete binary tree i...

Define min-heap A min-heap is a complete binary tree in which each element is less than or equal to its children. All the principal properties of heaps remain valid for min-hea

Time complexity of merge sort and heap sort algorithms, What is the time co...

What is the time complexity of Merge sort and Heap sort algorithms? Time complexity of merge sort is O(N log2 N) Time complexity of heap sort is   O(nlog2n)

Define the term array, Define the term array. An array is a way to refe...

Define the term array. An array is a way to reference a series of memory locations using the same name. Each memory location is represented by an array element. An  array eleme

Briefly explain the prim''s algorithm, Question 1 Describe the following- ...

Question 1 Describe the following- Well known Sorting Algorithms Divide and Conquer Techniques Question 2 Describe in your own words the different asymptotic func

Curve, write a c++ program to find out the area of a curve y=f(x) between x...

write a c++ program to find out the area of a curve y=f(x) between x=a and x=b

Explain the theory of computational complexity, Explain the theory of compu...

Explain the theory of computational complexity A  problem's  intractability  remains  the  similar  for  all  principal  models  of   computations    and   all reasonable inpu

Types of triangular matrices, Triangular Matrices Tiangular Matrices is...

Triangular Matrices Tiangular Matrices is of 2 types: a)  Lower triangular b)  Upper triangular

Multiple stacks, how multiple stacks can be implemented using one dimension...

how multiple stacks can be implemented using one dimensional array

Process of accessing data stored in a serial access memory, The process of ...

The process of accessing data stored in a serial access memory is same to manipulating data on a By using stack  method.

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