Discover the depth  of  C

  C C++  Linux ProgrammingNEW   Operating Systems  Data StructuresNEW  Compilers  Contact Us

Navigation

Join C4SwimmersGroup

 sitepromotion.gif (577 bytes) New Member

Data Structures

  Introduction

Stacks

  About Stacks

  Types of Notations

  Infix to Postfix

  Infix to Prefix

  Evaluating Postfix

Queues

  About Queues
  Circular Queue
  Priority Queue
Linked Lists 
 About Linked Lists
 Singly Lists
 Doubly Lists
 Circular Lists
 Circular Doubly Lists
Sorting
 Bubble Sort
 Insertion Sort
 Selection Sort
 Shell Sort
 Merge Sort
 Quick Sort
Searching
 About Searching
 Linear Search
 Binary Search
Online Certifications
premiumservices.gif (1070 bytes) Brainbench
premiumservices.gif (1070 bytes) Benchmarks Global
Help and Support
customer_care_small.gif (1018 bytes) Suggestions
post-question_icon.gif (1062 bytes) Contribute
premiumservices.gif (1070 bytes) Feedback
premiumservices.gif (1070 bytes) Advertise with us
 

 memberhome.gif (1052 bytes) -Home Page-

 
 
.  

C For Swimmers : Mastering C step-by-step

Google


WWW c4swimmers.esmartguy.com

Shell Sort

 

Definition : 

Shell Sort is a simple extension of Insertion sort. Its speed comes from the fact that it exchanges elements that are far apart (the insertion sort exchanges only adjacent elements).

The idea of the Shell sort is to rearrange the file to give it the property that taking every hth element (starting anywhere) yields a sorted file. Such a file is said to be h-sorted.


ALGORITHM : SHELL SORT

Procedure ShellSort(A, MAX) : Here A is an array consisting of MAX elements. This procedure sorts the elements in Ascending Order by repeatedly exchanging elements that are far apart, if necessary. Here 'temp' is a temporary variable used to exchange the elements in this procedure.

ASCENDING ORDER

for h = 1 to h £ MAX/9 do
    for (; h > 0; h != 3) do
        for i = h+1 to i £ MAX do
            v = A[i]
            j = i
            while (j > h AND A[j-h] > v)
                    A[i] = A[j-h]
                    j = j - h
            A[j] = v
            i = i + 1

 

FREE Source Code

premiumservices.gif (1070 bytes) Click Here: Shell Sort - Ascending Order

premiumservices.gif (1070 bytes)Click Here : To learn more about Shell Sort

You are Visitor No.

Sign my Guestbook View my Guestbook

Subscribe to C4Swimmers Group
Designed and Maintained by  Nanda Kishor

Thanks for using C For Swimmers.
Regarding this material, you can send Bug Reports, Suggestions, Comments, etc. to

nandakishorkn@rediffmail.com

Note: All logos or trademarks are related to their respective owners.

Although every precaution has been taken, the designer(s) owe no responsibility for malicious errors.

No liability assumed for damages resulting from the use of the available information.