Write a program to demonstrate best case, average case and worst case for a list of n numbers using quick sort PDF

Title Write a program to demonstrate best case, average case and worst case for a list of n numbers using quick sort
Author Divya jain
Course Master of computer applications
Institution Chandigarh University
Pages 4
File Size 252.8 KB
File Type PDF
Total Views 140

Summary

Write a program to demonstrate best case, average case and worst case for a list of n numbers using quick sort...


Description

Student Name: DIVYA JAIN UID: 21mca2399 Branch: MCA Section/Group: 3/B Semester: I Date of Performance:19/09/2021 Subject Name: DESIGN AND ANALYSIS OF ALGORITHM LAB Subject Code: CAP-606

1.Aim/Overview of the practical: The Quicksort Process Once the partitioning is done, the group of elements smaller than the pivot element is placed before it, and the remaining, greater ones, after it. There are several variations of the quick sort algorithm, depending on what kind of element (or number) is selected as the pivot: • • • •

The first element as the pivot The last element as the pivot A random element as the pivot Median as the pivot

The main process in a quicksort algorithm is partitioning. If x is the pivot in an array, then the main intent of the sorting process is to put x at the right position in a sorted array, such that smaller elements precede x and greater elements follow it.

Quick Sort in C Program The following code demonstrates the quick sort in C process. It asks the user to input a number of elements (up to 25) that requires sorting and then presents those elements in the sorted order: #include void quicksort(int number[25],int first,int last){ int i, j, pivot, temp; if(first...


Similar Free PDFs