Address Calculation
Sort
 This can be one of the fastest types of distributive sorting
technique if enough space is available also called as
Hashing.
 In this algorithm, a hash function is used and applied to
each element in the list. The result of the hash function
is placed in to an address in the table that represents the
key.
 Linked lists are used as address table for storing keys.(if
there are 4 keys then 4 linked lists are used).
 The hash function places the elements in linked lists are
called as sub files. An item is placed into a sub-file in
correct sequence by using any sorting method. After all
the elements are placed into subfiles, the lists
(subfies)are concatenated to produce the sorted list.
Address Calculation Sort
Procedure:
1. In this method a hash function f is applied to each key.
2. The result of this function determines into which of the
several subfiles the record is to be placed.
The function should have the property that: if x <= y ,
f (x) <= f (y), Such a function is called order preserving.
3. An item is placed into a subfile in correct sequence by
using any sorting method – simple insertion is often
used.
4. After all the elements are placed into subfiles, the lists
(subfiles) are concatenated to produce the sorted list.
Address Calculation Sort
Example:
25 57 48 37 12 92 86 33
Let us create 10 subfiles (linked lists). Initially each of
these subfiles is empty.
Key.
Address Calculation Sort
0
1
2
3
4
5
6
7
8
9
Example:
The number is passed to hash function, which returns its last
digit (ten’s place digit), which is placed at that position only,
in the linked lists.
num= 25 - f(25) gives 2
57 - f(57) gives 5
48 - f(48) gives 4
37 - f(37) gives 3
12 - f(12) gives 1
92 - f(92) gives 9
86 - f(86) gives 8
33 - f(33) gives 3
which is repeated.
Address Calculation Sort
0
1
2
3
4
5
6
7
8
9
25
57
48
33
12
92
86
37
Example:
After concatenating all linked list we get the sorted list.
12 25 33 37 48 57 86 92
Efficiency:
If all the elements (n) are uniformly distributed over m
subfiles then n/m is approximately 1, time of the sort is near
O(n).
On the other hand if maximum elements accommodate in
one or two subfiles, then n/m is much larger significant work
is required to insert element into proper subfile at its proper
position and efficiency is O(n2).
Address Calculation Sort
Thank You

address-calculation-sort.pptx

  • 1.
  • 2.
     This canbe one of the fastest types of distributive sorting technique if enough space is available also called as Hashing.  In this algorithm, a hash function is used and applied to each element in the list. The result of the hash function is placed in to an address in the table that represents the key.  Linked lists are used as address table for storing keys.(if there are 4 keys then 4 linked lists are used).  The hash function places the elements in linked lists are called as sub files. An item is placed into a sub-file in correct sequence by using any sorting method. After all the elements are placed into subfiles, the lists (subfies)are concatenated to produce the sorted list. Address Calculation Sort
  • 3.
    Procedure: 1. In thismethod a hash function f is applied to each key. 2. The result of this function determines into which of the several subfiles the record is to be placed. The function should have the property that: if x <= y , f (x) <= f (y), Such a function is called order preserving. 3. An item is placed into a subfile in correct sequence by using any sorting method – simple insertion is often used. 4. After all the elements are placed into subfiles, the lists (subfiles) are concatenated to produce the sorted list. Address Calculation Sort
  • 4.
    Example: 25 57 4837 12 92 86 33 Let us create 10 subfiles (linked lists). Initially each of these subfiles is empty. Key. Address Calculation Sort 0 1 2 3 4 5 6 7 8 9
  • 5.
    Example: The number ispassed to hash function, which returns its last digit (ten’s place digit), which is placed at that position only, in the linked lists. num= 25 - f(25) gives 2 57 - f(57) gives 5 48 - f(48) gives 4 37 - f(37) gives 3 12 - f(12) gives 1 92 - f(92) gives 9 86 - f(86) gives 8 33 - f(33) gives 3 which is repeated. Address Calculation Sort 0 1 2 3 4 5 6 7 8 9 25 57 48 33 12 92 86 37
  • 6.
    Example: After concatenating alllinked list we get the sorted list. 12 25 33 37 48 57 86 92 Efficiency: If all the elements (n) are uniformly distributed over m subfiles then n/m is approximately 1, time of the sort is near O(n). On the other hand if maximum elements accommodate in one or two subfiles, then n/m is much larger significant work is required to insert element into proper subfile at its proper position and efficiency is O(n2). Address Calculation Sort
  • 7.