Professional Documents
Culture Documents
DAA Cat-3
DAA Cat-3
PRESENATATION FOR
CAT-3
PRESENTED BY –
INTRODUCTION
Course Code: BTCS9211 Course Name: Analysis And Design
ItAlgorithm
is used on the principle of divide-and-conquer. Quick sort is an algorithm of choice in
many situations as it is not difficult to implement. It is a good general purpose sort and it
consumes relatively fewer resources during execution.
A large array is partitioned into two arrays one of which holds values smaller than the specified value,
say pivot, based on which the partition is made and another array holds values greater than the pivot
value. Quicksort partitions an array and then calls itself recursively twice to sort the two resulting
subarrays.
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design Algorithm
Working
The variable you want to predict is called the dependent variable. The variable you are
using to predict the other variable's value is called the independent variable.
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Quick Sort Algorithm
Analysis-
To find the location of an element that splits the array into two parts, O(n) operations are required.
This is because every element in the array is compared to the partitioning element.
After the division, each section is examined separately.
If the array is split approximately in half (which is not usually), then there will be log(n) splits.
Therefore, total comparisons required are f(n) = n x log(n) = O(nlog(n)).
Worst Case-
Quick Sort is sensitive to the order of input data.It gives the worst performance when
elements are already in the ascending order.
It then divides the array into sections of 1 and (n-1) elements in each call.
Then, there are (n-1) divisions in all.
Therefore, here total comparisons required are f(n) = n x (n-1) = O(n2).
Advantages :
• It is in-place since it uses only a small auxiliary stack.
perform badly.
• It is not stable sort i.e the order of equal elements may not be preserved.
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Algorithm
CodeWord Data Structure :
1) Architecture-Independent Features:
The codewordbased routines require a slightly smaller number of
comparisons, the comparisons are on shorter entities, and the
number of swaps is also reduced. Moreover, the elements
to be compared, the codewords, can be accessed directly
rather than indirectly, as in the case of keys accessed
through pointers to records.
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Algorithm
CodeWord Data Structure :
1) Architecture-Independent Features:
The codewordbased routines require a slightly smaller number of
comparisons, the comparisons are on shorter entities, and the
number of swaps is also reduced. Moreover, the elements
to be compared, the codewords, can be accessed directly
rather than indirectly, as in the case of keys accessed
through pointers to records.
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Algorithm
CodeWord Data Structure :
2) Architecture-Dependent Features:
The codewordbased routines increase the spatial locality of the
program and thus take better advantage cf caches and TLB’s. The
improvement increases with the sophistication of the architecture
(copy-back cache and large block size).
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Algorithm
CodeWord Data Structure :
2) Architecture-Dependent Features:
The codewordbased routines increase the spatial locality of the
program and thus take better advantage cf caches and TLB’s. The
improvement increases with the sophistication of the architecture
(copy-back cache and large block size).
SCHOOL OF COMPUTING SCEINCE
Course Code: BTCS9211 Course Name: Analysis And Design
Algorithm
CodeWord Data Structure :
3) Compiler Optimization:
In-line expansion of short procedures and hints for register allocation
have a beneficial effect (although this benefit is also present for
pointer-based routines).
SCHOOL OF COMPUTING SCEINCE
Conclusion:
Quick Sort method sorts the elements using the Divide and Conquer approach and has an average
O(nLogn) complexity.
It can be implemented in both recursive and iterative way. It is in-place, cache-friendly and also a tail-
recursive algorithm.
SCHOOL OF COMPUTING SCEINCE
THANK YOU