DS – Sorting Techniques

Sorting techniques

  • A sorting technique is used to re-arrange the element in the given array.
  • Sorting always done using comparison operators.
  • Some of algorithms:
    • Bubble sort
    • Selection sort
    • Insertion sort
    • Heap sort
    • Quick sort
    • Merge sort

Generating random values:

  • The C library is providing pre-defined function to generate random values.
  • Prototype is
    • int  rand(void);
  • RAND_MAX is a constant whose default value vary from 0 to 32767
#include<stdio.h>
int main()
{
            int x,i;
            for(i=1 ; i<=10 ; i++)
            {
                        x = rand()%50;
                        printf(“x value : %d \n”, x);
            }
            return 0;
}
Scroll to Top