0% found this document useful (0 votes)
52 views2 pages

Name - Kushaggra Chaudhary ENROLL - A2305218568 Sec-5Cse 9X Quicksort External Practical

This document contains a C program that implements quicksort to sort an array of integers. It includes the quicksort function definition, which takes the array, starting index, and ending index as parameters. It recursively calls itself to sort subarrays until the entire array is sorted. The main function prompts the user to enter the size of the array and elements, calls quicksort to sort the array, and prints out the sorted elements.

Uploaded by

Kush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views2 pages

Name - Kushaggra Chaudhary ENROLL - A2305218568 Sec-5Cse 9X Quicksort External Practical

This document contains a C program that implements quicksort to sort an array of integers. It includes the quicksort function definition, which takes the array, starting index, and ending index as parameters. It recursively calls itself to sort subarrays until the entire array is sorted. The main function prompts the user to enter the size of the array and elements, calls quicksort to sort the array, and prints out the sorted elements.

Uploaded by

Kush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NAME - KUSHAGGRA CHAUDHARY

ENROLL - A2305218568
SEC- 5CSE 9X

QUICKSORT EXTERNAL PRACTICAL

#include<stdio.h>
void quicksort(int number[25],int first,int last){
int i, j, pivot, temp;

if(first<last){
pivot=first;
i=first;
j=last;

while(i<j){
while(number[i]<=number[pivot]&&i<last)
i++;
while(number[j]>number[pivot])
j--;
if(i<j){
temp=number[i];
number[i]=number[j];
number[j]=temp;
}
}

temp=number[pivot];
number[pivot]=number[j];
number[j]=temp;
quicksort(number,first,j-1);
quicksort(number,j+1,last);

}
}

int main(){
int i, count, number[25];

printf("How many elements are u going to enter?: ");


scanf("%d",&count);

printf("Enter %d elements: ", count);


for(i=0;i<count;i++)
scanf("%d",&number[i]);

quicksort(number,0,count-1);

printf("Order of Sorted elements: ");


for(i=0;i<count;i++)
printf(" %d",number[i]);

return 0;
}

OUTPUT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy