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

Linked list, how to creat atm project by using linked list?

how to creat atm project by using linked list?

Structure of an avl tree, Given is the structure of an AVL tree: struct ...

Given is the structure of an AVL tree: struct avl { struct node *left; int info; int bf; struct node *right; }; 2) A multiway tree of n order is an ord

Storing street addresses with doubly linked lists, Write a C++ program with...

Write a C++ program with header and source les to store street addresses using the Doubly Linked List ADT. Modify the Node class from Lab Assignment 3 so that it becomes a node in

Indexed sequential file organisation, When there is requirement to access r...

When there is requirement to access records sequentially by some key value and also to access records directly by the similar key value, the collection of records may be organized

Types of tree ?, Binary: Each node has one, zero, or two children. This ...

Binary: Each node has one, zero, or two children. This assertion creates many tree operations efficient and simple. Binary Search : A binary tree where each and every left

Binary tree, A binary tree is a tree data structures in which each node hav...

A binary tree is a tree data structures in which each node have at most two child nodes, generally distinguished as "right" and "left". Nodes with children are called parent nodes,

Search, What are the conditions under which sequential search of a list is ...

What are the conditions under which sequential search of a list is preferred over binary search?

Implementation of stack using linked lists, In the last subsection, we have...

In the last subsection, we have implemented a stack by using an array. While a stack is implemented by using arrays, it suffers from the basic restriction of an array - i.e., its s

Insertion of a node into a binary search tree, A binary search tree is cons...

A binary search tree is constructed through the repeated insertion of new nodes in a binary tree structure. Insertion has to maintain the order of the tree. The value to the lef

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