beingtopper.jkp@gmail.com
+91-7529019575
Free Demo

Being Topper

  • Home
  • About Us
    • Founder’s Profile
    • Franchise
    • Women’s Entrepreneurship Development
  • Blog & Events
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Rajasthan
      • Ajmer
      • Jaipur
      • Jodhpur
      • Udaipur
      • Kota
      • Sikar
    • Janakpuri
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • Home
  • About Us
    • Founder’s Profile
    • Franchise
    • Women’s Entrepreneurship Development
  • Blog & Events
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Rajasthan
      • Ajmer
      • Jaipur
      • Jodhpur
      • Udaipur
      • Kota
      • Sikar
    • Janakpuri
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
  • Home
  • About Us
    • Founder’s Profile
    • Franchise
    • Women’s Entrepreneurship Development
  • Blog & Events
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Rajasthan
      • Ajmer
      • Jaipur
      • Jodhpur
      • Udaipur
      • Kota
      • Sikar
    • Janakpuri
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • Home
  • About Us
    • Founder’s Profile
    • Franchise
    • Women’s Entrepreneurship Development
  • Blog & Events
  • Modules
    • Website Planning and Creation
    • Social Media Marketing Course
    • Search Engine Optimization
    • SEM/PPC Training
  • Branches
    • Rajasthan
      • Ajmer
      • Jaipur
      • Jodhpur
      • Udaipur
      • Kota
      • Sikar
    • Janakpuri
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
Algorithm Design and analysis ProgramsB.tech notesC++ programInformation technology

C++ PROGRAM ON QUICK SORT

Being Topper 24/05/2013 0 Comments

QUICK SORT

QuickSort algorithm works on  a Divide and Conquer technique. It select an element as pivot and splits the given array around the picked pivot. There are lots of different versions of quickSort that select pivot in different ways.

  1. Always pick first element as pivot.
  2. Always pick last element as pivot
  3. Pick a random element as pivot.
  4. Pick median as pivot.

The main process in quickSort is partition(). Target of partitions is, given an array and an element x of array as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time.

 

check this video of Quick-sort with Hungarian folk dance


WRITE A PROGRAM ON QUICK -SORT
#include<iostream.h>

#include<conio.h>

#include<stdio.h>

int  partition(int arr[], int p,int r);

void  quicksort(int arr[],int p,int r)

{ int q;

if (p<r)

{  q= partition(arr,p,r);

quicksort(arr,p,q-1);

quicksort(arr,q+1,r);

}

int  partition(int  arr[],int  p, int r)

{    int t, k,y,i,x;

x=arr[r];

i=p-1;

for(j=p;j<r;j++)

{  if(arr[j]<=x)

{  i=i+1;

t=arr[i];

arr[i]=arr[j];

arr[j]= t;

}

}

k=arr[i+1];

arr[i+1]=arr[r];

arr[r]=k;

y = i+1;

return y  ; }

void main()

{

int arr[8],i;

cout<<“Enter array elements : \n”;

for(i=0;i<8 ;i++)

{  cin>>arr[i]; }

cout<<“\n The array elements are : \n”;

for(i=0;i<8;i++)

{   cout<<arr[i];  }

quicksort(arr,1,8);

cout<<” sorted array elements are :\n”;

for(i=0;i<8;i++)

cout<<  arr[i];

getch();

}
OUTPUT :

output

Algorithm and design analysis C++ PROGRAM ON QUICK SORT C++ PROGRAM ON QUICK SORT IMPLEMENTATION quick sort
1882 Views
AboutBeing Topper
In Socials:
C++ PROGRAM FOR ACTIVITY SELECTOR25/05/2013Next

Related Posts

B.tech notesBCA NOTESInformation technologyJava ProgramsPrograms/Algorithm

java program to make a GUI based calculator using frames

we are going to make a calculator’s gui … (more…)

Being Topper 01/04/2014
Algorithm Design and analysis ProgramsB.tech notesC++ programInformation technology

C++ program to perform robin karp string matching

       WRITE A PROGRAM TO PERFORM ROBIN KARP STRING MATCHING (more…)

Being Topper 25/05/2013
Categories
Recent Posts
  • Vipin Khuttel Inspires Entrepreneurs at Networking Meet in Gurgaon
  • Vipin Khuttel Founder of Being Topper Recognized for Advancing Digital Literacy and Social Empowerment
  • Vipin Khuttel Organizes International Conference for Digital Excellence 2, Elevating the Future of Technology
  • India’s Top Occult Science Enthusiasts Gather at AgyatOnSearch – Awards & Seminar in New Delhi
  • India’s Leading Digital Marketer, Vipin Khuttel Interacted with Top Influencers of Delhi at BJP West Delhi’s Event

Copyright © 2025 Being Topper ® . All Rights Reserved