Beruflich Dokumente
Kultur Dokumente
Project head
D
HO
ACKNOWLEDGEMENT
Project
associates
ABSTRACT
CONTENTS
S.NO
1.
2.
3.
4.
5.
TITLE
ABSTRACT
INTRODUCTION
SYSTEM ANALYSIS
1. Program Interface:
2. Program Execution:
3. Program Structure:
SOURCE CODE
REFERENCE
PAGE.NO
1
2
7
7
7
8
16
INTRODUCTION
Space Complexity:- 1
T(n)wc = O(n2)
Tavg(n) = Twc(n) = O(nlog2n)
It is the fastest known algorithm in practice.
Quicksort is a divide-conquer recursive algorithm.
The basic algorithm to sort an array a consists of the following four easy steps:
1.If the number of elements in a is 0 or 1, then return.
2.Pick any element v in a. This is called the pivot.
3.Partition a- {v}(the remaining elements in s) into two disjoint groups . a1 =
{X a- { v}| x v } and a2 = { x a {v} | x v }
Return { quicksort(a1) followed by v followed by quicksort(a2)}
Picking the pivot:- First /last element
Random number generation
Median of the three Partitioning
Time Complexity :- T(n) = T(i) + T(N-i-1) + cn
i is the no of elements in list a1.
Worst Case :- i =0
T(n) = T(0) + T(n-1) +cn
= T(n-1) +cn
T(n-1) = T(n-2) + c(n-1)
T(n-2) = T(n-3) + c(n-2)
;. :
T(3) = T(2) + c. 3
T(2) = T(1) + c.2
T(n) = T(1) + c. i = O(n2)
i =2
Best Case:- i =n/2
T(n) = 2T(n/2)+cn
T(n) = T(n/2) + c
n n/2
Similar to that of merge sort
T(n) = O(nlog 2 n)
n-1
1/ n T(j) is the average time for one list.
j=0
Average Case:n-1
T(n)= 2/n T(j) +c .n
j=0
n-1
n.T(n) = 2 T(j) +c .n2 ------I
j=0
n-2
(n-1) T(n-1) = 2 T(j) +c .n-1 2 ----II
j=0
I-II : n.T(n) = (n+!) T(n-1) + 2.cn
T(n-1) = T(n-2) + 2c
n + 1 n-1 n +1
::
::
T(n-1) = T(n-2) + 2c
T(n-1) = T(n-2) + 2c
n n-1 n
T(n-2) = T(n-3) + 2c
n n-1 n-1
.....
T(2) = T( 1) + 2c
3 n-2 3
n+1
T(n) T(1) + 2c i/1
n+1 2 i=3
n+1
T(n) = O(log2n) [ . . = loge(n+1) + r- 3 ]
n+1 2
T(n) = O(n log2n)
System analysis
Program Interface:
Here the program has been developed using C language , so a C
Compiler is needed to execute the program .First the source code will be
written over the editor window and then will be saved .Now the program
is compiled to check for errors if any they are corrected .After finishing
the compilation task the program is then executed.
Program Execution:
The basic input to the program will be numbers and that to limited
to range of ordinary integer values. The program provides the user with
basic operation of sorting
After performing the operations the final result will be
the result with desired changes.
Finally after the display of the result control is used to quit from the program.
This brings the user to the editor window where the programmer can make
necessary changes and re-execute the program.
Program Structure:
1.Preprocessor section
2.Function prototypes
3.Global variable declaration
4.Main function
{
A. Local variables
B. Graphic mode initialization
C. Beginning screen ()
D. Main screen ()
E. User input
F. Processing
G. Display output
H. Further processing
}
SOURCE CODE:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
for(i=1;i<=r;++i)
printf("%c%c%c%c%c%c",rup,rup,rup,rup,rup,rup);
printf("\n");
printf("%c",cbg);
textbackground ( _color );
if ( _color == 15 )
{
textcolor ( 1 );
}
else
{
textcolor ( 5 );
}
textcolor ( 4 );
printf("%2d %c",a[i],cnd); }
printf("\b \b\b%c\n",cnd);
textbackground ( _color );
if ( _color == 10 )
{
textcolor ( 6 );
}
else
{
textcolor ( 9 );
}
//FOR PRINTING LOWER STRAIGHT LINE.
for(i=1;i<=r;i++)
printf("%c%c%c%c%c%c",rdw,rdw,rdw,rdw,rdw,rdw);
printf("\n\n");
void main()
{
int n, opt, a[20],d,m;
char ch;
textbackground ( 0 );
textcolor ( 5 );
clrscr();
printf("\nenter no of elements:");
scanf("%d",&n);
printf("\nenter the elements in the list:");
readlist(a,n);
quick_sort(a,n);
textbackground ( 6 );
textcolor ( 5 );
getch();
}
void quick_sort(int a[],int n)
{
qsort(a,1,n);
}
void qsort(int a[],int lb,int rb)
{
int i,j,pivot,temp;
if(lb<rb)
{
pivot=a[lb];
i=lb;
j=rb+1;
while(1)
{
i++;
while(a[i]<pivot)
i++;
j--;
while(a[j]>pivot)
j--;
if(i>j)
break;
else
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
temp=a[lb];
a[lb]=a[j];
a[j]=temp;
puts("\nTHE MODIFIED LIST IS:");
design(a,lb,rb);
qsort(a,lb,j-1);
qsort(a,j+1,rb);
}
REFERENCES
From the guidance of the senior and assistant lecturer our group
collected the matter from the CSE department and also from the IT department.
We also verified the description given by senior professor sir Alfred lozer in the
oxford university on the graphics codes and also studied the lesson written by the
professor S N fried in the Cambridge University. We mainly searched the
Wikipedia for the basic information and for the applications of the quick sort in
graphics. We also surfed the sites of the IITs to find the usage of the graphics in
c code. We also studied the types of representing the graphics in c code and also
in the c++ code. We also referred to the books named graphics under c from
the library.