You are on page 1of 9

PROJECT REPORT

ON
ANALYSIS THE ALGORITHUM OF QUICK SHORT

Submitted to Centurion University of Technology& Management


in partial fulfillment of the requirement for award of the degree of

B. TECH.

in

COMPUTER SCIENCE & ENGINEERING

Submitted By
NAME:- HRITHIK RAJ
Reg. No.- 210101120147

Under the Guidance of


Mr. SATYASANGRAM SAHOO

DEPT. OF COMPUTER SCIENCE & ENGINEERING

SCHOOL OF ENGINEERING &TECHNOLOGY,


CUTM, Paralakhemundi-761200

1
EVALUATION SHEET

1. Title Of the Project: - UNSUPERVISED LEARNING

2. Year Of Submission: - 2022


3. Name Of the Degree: - B. Tech
4. Student Name with Reg. No.: - Hrithik Raj (210101120147)
5. Name of the Guide: - Mr SatyaSangram Sahoo

6. Result: [APPROVED/REJECTED]

Signature of HOD Signature of Project Guide

Name of the HOD Name of the Guide


Mr. Devendra Maharana Mr. Satya Sangram Sahoo

Signature of External Examiner

2
INDEX

Sl. No. Topic Page no.


01 Introduction of Quick Short 05
02. Importance of Quick Short 06
03. Algorithm of Quick Short 07
04. Application of Quick Short 08
05. C Code for Quick Short 9-10

3
INTRODUCTION

 Sorting is a way of arranging items in a systematic


manner.

 Quicksort is the widely used sorting algorithm that


makes n log n comparisons in average case for
sorting an array of n elements.

 It is a faster and highly efficient sorting algorithm.


This algorithm follows the divide and conquer
approach.

 Quicksort is an in-place sorting algorithm.


Developed by British computer scientist Tony
Hoare in 1959 and published in 1961 it is still a
commonly used algorithm for sorting.

 When implemented well, it can be somewhat faster


than merge sort and about two or three times faster
than heapsort.

4
IMPORTANCE OF QUICK SHORT

 Quick sort is also known as Partition-exchange sort


based on the rule of Divide and Conquer.

 It is a highly efficient sorting algorithm.

 Quick sort is the quickest comparison-based sorting


algorithm.

 It is very fast and requires less additional space,


only O (n log n) space is required.

 Quick sort picks an element as pivot and partitions


the array around the picked pivot.

 Quick Sort in a data structure is a method to sort


the list of elements.

 It uses the divide and conquer approach for this that


means the array of elements are divided into 2
parts, and then further quick sort algorithm is
applied to these 2 parts.

5
ALGORITHUM OF QUICK SHORT

 Step 1:- Choose the highest index value as pivot.

 Step 2:- Take two variables to point left and right


of the list excluding pivot.

 Step 3:- Left points to the low index.

 Step 4:- Right points to the high index.

 Step 5:- While value at left < (Less than) pivot


move right.

 Step 6:- While value at right > (Greater than)


pivot move left.

 Step 7:- If both Step 5 and Step 6 does not


match, swap left and right.

 Step 8:- If left = (Less than or Equal to) right, the


point where they met is new pivot.

6
APPLICATION OF QUICK SHORT

 The sorting algorithm is used for information


searching and as Quicksort is the fastest algorithm
so it is widely used as a better way of searching.

 It is used everywhere where a stable sort is not


needed.

 Quicksort is a cache-friendly algorithm as it has a


good locality of reference when used for arrays.

 Quick Sort in a data structure is a method to sort


the list of elements.

 The sorting algorithm is used for information


searching and as Quicksort is the fastest algorithm
so it is widely used as a better way of searching.

 Quick Sort uses a function partition to find the


partitioning point for an array, and Quick Sort is
further called for 2 sub-arrays. This partition
function uses an assumption to take the last
element of the array as a pivot.

7
CODE FOR QUICK SHORT

#include<stdio.h>
#include<conio.h>

//quick Sort function to Sort Integer array list


void quicksort(int array[], int firstIndex, int lastIndex)
{
//declaaring index variables
int pivotIndex, temp, index1, index2;
if(firstIndex < lastIndex)
{
//assigninh first element index as pivot element
pivotIndex = firstIndex;
index1 = firstIndex;
index2 = lastIndex;
//Sorting in Ascending order with quick sort
while(index1 < index2)
{
while(array[index1] <= array[pivotIndex] && index1 < lastIndex)
{
index1++;
}
while(array[index2]>array[pivotIndex])
{
index2--;
}
if(index1<index2)
{
//Swapping opertation
temp = array[index1];
array[index1] = array[index2];
array[index2] = temp;
}
}
//At the end of first iteration, swap pivot element with index2 element
temp = array[pivotIndex];
array[pivotIndex] = array[index2];
array[index2] = temp;
//Recursive call for quick sort, with partiontioning

8
quicksort(array, firstIndex, index2-1);
quicksort(array, index2+1, lastIndex);
}
}
int main()
{
//Declaring variables
int array[100],n,i;
//Number of elements in array form user input
printf("Enter the number of element you want to Sort : ");
scanf("%d",&n);
//code to ask to enter elements from user equal to n
printf("Enter Elements in the list : ");
for(i = 0; i < n; i++)
{
scanf("%d",&array[i]);
}
//calling quickSort function defined above
quicksort(array,0,n-1);
//print sorted array
printf("Sorted elements: ");
for(i=0;i<n;i++)
printf(" %d",array[i]);
getch();
return 0;
}

CODE OUTPUT FOR QUICK SHORT

You might also like