DAA Lab - Practical No. 01 - AI&DS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Design & Analysis of Algorithm (PCCAD502P)

S. B. JAIN INSTITUTE OF TECHNOLOGY,


MANAGEMENT & RESEARCH, NAGPUR.

Practical No. 01

Aim: Write and implement the menu-driven program for quick sort and merge sort.

Name of Student:
Roll No.:
Semester/Year: V Semester / III Year
Academic Session: 2024 – 2025 (ODD)
Date of Performance: ___ / ___ / 2024
Date of Submission: ___ / ___ / 2024
Design & Analysis of Algorithm (PCCAD502P)

PRACTICAL NO. 01

AIM: Write and implement the menu-driven program for quick sort and merge sort.

OBJECTIVE

● To implement array sorting using quick sort


● To sort the list using the efficient technique called quick sort
● To analyze the time taken by n verses the list of elements
● To implement array sorting using Merge sort

THEORY:
Quick Sort:
Merge sort is
defined as a
sorting algorithm
that works by
dividing an array
into smaller
subarrays, sorting
each subarray,
and then merging
the sorted
subarrays back
together to form
the final sorted
array. Quick sort (sometimes called partition-exchange sort) is an efficient sorting algorithm,
serving as a systematic method for placing the elements of an array in order. Quick sort is a
comparison sort, meaning that it can sort items of any type for which a "less-than" relation
(formally, a total order) is defined. In efficient implementations it is not a stable sort,
meaning that the relative order of equal sort items is not preserved. Quick sort can operate
in-place on an array, requiring small additional amounts of memory to perform the sorting.

Department of Emerging Technologies – B. Tech (AI&DS), S.B.J.I.T.M.R, Nagpur.


Design & Analysis of Algorithm (PCCAD502P)

Merge Sort:
Merge sort is a sorting
technique based on
divide and conquer
technique. Merge sort
is defined as a sorting
algorithm that works
by dividing an array
into smaller subarrays,
sorting each subarray,
and then merging the
sorted subarrays back
together to form the
final sorted array. With
worst-case time complexity being Ο (n log n), it is one of the most respected algorithms.
Merge sort first divides the array into equal halves and then combines them in a sorted
manner.

CODE:

OUTPUT / IMPLEMENTATION / SCREENSHOTS:

DISCUSSION AND VIVA VOCE:

1. Is Quick Sort a Stable Sorting algorithm?


2. What is the best pivot for Quick Sort?
3. What is the Worst-Case Time Complexity of Quick Sort?
4. What is the Best case, Worst Case & average case Time Complexity of merge Sort?
5. Can you explain how the divide and conquer strategy works with merge sort?

CONCLUSION:

Department of Emerging Technologies – B. Tech (AI&DS), S.B.J.I.T.M.R, Nagpur.


Design & Analysis of Algorithm (PCCAD502P)
Successfully executed the Quick sort & Merge sort algorithm and understand sorting process using
divide & conquer strategy.

Department of Emerging Technologies – B. Tech (AI&DS), S.B.J.I.T.M.R, Nagpur.

You might also like