i want code of Sorting techniques like insertion sort , merge sort , bubble sort , quick sort. i want their output in gui or in any animation form in any language like c , c# or java. can any one help me plz ?Any one sorting technique is ok.

Recommended Answers

All 3 Replies

i find this program from http://www.madharasan.com/

/*
 * Auther: Jayarathina Madharasan. Y
 * Website: http://www.madharasan.com/
 * Date: Oct, 10, 2008
 * This program performs animation of bubble sort. 
The bubble sort works by comparing each item in the list with the item next to
it, and swapping them if required. The algorithm repeats this process until it
makes a pass all the way through the list without swapping any items (in other
words, all items are in the correct order). This causes larger values to
"bubble" to the end of the list while smaller values "sink" towards the
beginning of the list.
*/
#include <stdio.h>
#include <conio.h>

void PrintCurrentState(int numbers[], int max, int j)
{
    int i, temp, midt;
    clrscr();
    printf("\nThe elements are:\n");
    for(i = 0; i<max; i++)
    {
        if (i == j-1)
        {
            textcolor(GREEN);
            gotoxy(wherex(), wherey()+1);
            temp = cprintf("%c",24);
            gotoxy(wherex()-temp, wherey()-1);
        }
        else if(i == j)
        {
            textcolor(GREEN);
            gotoxy(wherex(), wherey()+1);
            if (numbers[j-1] > numbers[j])
                temp = cprintf("%c Will swap",24);
            else
                temp = cprintf("%c Will not swap",24);
            gotoxy(wherex()-temp, wherey()-1);
        }
        cprintf("%d", numbers[i]);
        printf(" ");
        textcolor(LIGHTGRAY);
    }
    delay(1000);
}

void bubbleSort(int numbers[], int array_size)
{
    int i, j, temp;
    _setcursortype(_NOCURSOR);
    for (i = (array_size - 1); i >= 0; i--)
        for (j = 1; j <= i; j++)
        {
            PrintCurrentState(numbers, array_size, j);
            if (numbers[j-1] > numbers[j])
            {
                temp = numbers[j-1];
                numbers[j-1] = numbers[j];
                numbers[j] = temp;
            }
        }
    PrintCurrentState(numbers, array_size, array_size+1);
    _setcursortype(_NORMALCURSOR);
    printf("\n\nList is sorted!");
}

int main()
{
    int i, a[100], max;
    clrscr();
    printf("Enter total number of elements:");
    scanf("%d", &max);
    printf("\nEnter the elements :\n\n");
    for (i=0; i<max;i++)
    {
        printf("Enter %d element:", i+1);
        scanf("%d", &a[i]);
    }
    bubbleSort(a, max);
    getch();
}
commented: can you plz tell me how to run this code in c++ project because it has many errors. plz sir help me +0

If all you want is the animations you can get that online. If you want to actually plug in a hand-made visualization to a particular code block it will be much harder and dependent on your ability in a chosen language.
Where are your strengths?

thnks guys...really thanku for your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.