Sort Huge amount of data using C Programming Language

Various Sorting Algorithms

The big sort routine implements a way to sort huge amounts of data using C programming language. It sorts the data that do not fit into main memory by using a multi-phase sorting on files. It is a implementation from the book “Algorithms and data structures” by Niklaus Wirth. Additionally, this routine recognizes small amounts of data that do fit into memory and resorts to a in-place quicksort.

Inside this source code you shall find implementations of Sorting Arrays, Binary search implementation, heapsort, quicksort, minimize memory requirement, use of Fibonacci numbers, insertion sort algorithm

  Sort Huge amount of data (20.0 KiB, 4,623 hits)

Example Usage

//Example 1: To generate a quicksort routine which sorts an integer array
 //in increasing order, use the following lines:
    | Left margin
    V
    #define GENSORT_NAME                 intquicksort
    #define GENSORT_TYPE                 int
    #define GENSORT_KEYTYPE              int
    #define GENSORT_GETKEY(a)            a
    #define GENSORT_COMPAREKEYS(k1,k2)   k1 < k2

    #include "gensort.h"

//Example 2: To generate a pointer quicksort routine that sorts a structure
//according to a string in the key field (<string.h> is included to get
//the prototype for the strcmp function):
    | Left margin
    V
    #include <string.h>

    struct Test {
      char *KeyString;
      int   OtherFields;
       ....
    };

    #define GENSORT_NAME                 namequicksort
    #define GENSORT_TYPE                 struct Test
    #define GENSORT_KEYTYPE              char *
    #define GENSORT_GETKEY(a)            a.KeyString
    #define GENSORT_COMPAREKEYS(k1,k2)   strcmp(k1,k2) < 0

    #define GENSORT_USEPOINTERS

    #include "gensort.h"

See also: Shell SortQuick SortBubble SortInsertion SortSelection Sort

Bug reports, questions, improvements, mail to Jörg Schön

This program is Copyright © 1993-1995 by Joerg Schoen. Permission to use, copy and distribute this software together with its documentation for any purpose is herby granted provided that the above copyright notice appears in all copies. No fee must be taken for this package. This software is provided “as is” without expressed or implied warranty.

M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post