0% found this document useful (0 votes)
14 views7 pages

LAB15 DSA W23 Open Ended

Y

Uploaded by

alisharafique433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

LAB15 DSA W23 Open Ended

Y

Uploaded by

alisharafique433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

LABORATORY MANUAL

Subject Name: CS09204 Data Structures and Algorithms


Student Name Laraib batool
Reg. No. 70138114
Date May 17, 2024

MAPPING OF LAB TO CLOs & PLOs


CLO 3: Implement commonly used data structures and PLO 5: Modern Tool Usage
algorithms using programming software. Cognitive Domain: C3

Rubric for Modern Tool Usage


Criteria Attainment Score
Excellent Very good Good Fair Poor
(100-85%) (84-71%) (70-61%) (60-50%) (49-0%)
Understanding Demonstrates Demonstrates a Demonstrates Demonstrates Demonstrates
of Engineering skillful ability to very good ability good ability to some ability to minimal or no
Tools describe and to describe and describe and/or describe ability to describe
explain the explain the explain the and/or explain and/or explain the
principles behind principles behind principles behind the principles principles behind
and applicability and applicability and applicability behind and and applicability
of engineering of engineering of engineering applicability of engineering
tools. tools. tools. of engineering tools.
tools.
Ability to Demonstrates Demonstrates a Demonstrates Demonstrates Demonstrates
perform skillful ability to very good good ability to some ability to minimal or no
experiment identify and use ability to identify identify and use identify or use ability to identify
using the most relevant and use relevant tools for an tools for an or use tools for an
Engineering
tools for a range of tools for an engineering engineering engineering
Tool (Dev C++)
engineering engineering activity, but may activity. activity.
activities. activity. not identify the
most relevant
tool.
Generation and Demonstrates Demonstrates a Demonstrates Demonstrates Demonstrates
Interpretation skillful ability to very good ability good ability to some ability to minimal or no
of results using generate results to generate generate results generate ability to generate
modern tools using modern results using using modern results using results using
(Dev C++)
tools. modern tools. tools. modern tools. modern tools.
Ability to Demonstrates Demonstrates a Demonstrates Demonstrates Demonstrates
relate skillful ability to very good ability good ability to some ability to minimal or no
experiment understand to understand understand understand ability to
with theory significance of significance of significance of significance of understand
and its experiment and its experiment and experiment and its experiment significance of
relation to the its relation to the relation to the and its relation experiment and its
significance
theory theory theory. to the theory relation to the
theory
Lab 15: Open ended lab
The objective of this open-ended lab is to analyze and compare the performance of various
sorting algorithms on different datasets. You will implement and evaluate the efficiency of
different sorting algorithms, consider their time and space complexity, and analyze their behavior
on different input sizes and data distributions.

Requirements:

 Proficiency in a programming language C++ to implement sorting algorithms.


 Understanding of different sorting algorithms.
 Knowledge of time and space complexity analysis of algorithms.
 Ability to generate and work with different input datasets, including random, sorted,
partially sorted, and reversed arrays.
 Proficiency in data collection and analysis, including measuring execution time and space
usage.
 Draw conclusions based on the performance analysis and discuss which sorting
algorithms are better suited for specific scenarios or data distributions.
 Discuss potential optimizations or modifications that could improve the performance of
the sorting algorithms.
 Summarize the findings in a comprehensive report, including the experimental setup,
results, analysis, and conclusions.

Lab work:-

Overview
This lab aims to analyze and compare the performance of various sorting algorithms on different datasets.
The goal is to implement, evaluate, and understand the efficiency of these algorithms in terms of time and
space complexity, and their behavior on varying input sizes and data distributions.

Requirements
Proficiency in C++
Implement sorting algorithms using C++.

Understanding of Sorting Algorithms

Familiarize yourself with the following sorting algorithms:

 Bubble Sort
 Selection Sort
 Insertion Sort
 Merge Sort
 Quick Sort
 Heap Sort
 Radix Sort
 Counting Sort
 Time and Space Complexity Analysis

Analyze the time and space complexity of each algorithm:

Lets run the code containing differents sorting algorithms:-

Implementation of bubble sortting:


Implementation of Insertion sortting:-

Implementation of selection sortting:-


Applications and Comparison of Sorting Algorithms
 Bubble Sort
Applications:
1. Educational Use: Bubble Sort is often used to introduce the concept of sorting algorithms
due to its simplicity and ease of understanding.
2. Small Datasets: It can be used for sorting small datasets where the overhead of more
complex algorithms is not justified.
3. Nearly Sorted Data: It is efficient for nearly sorted datasets where the number of swaps
needed is minimal.
Time Complexity:
1. Best Case: ( )O(n) (when the array is already sorted)
2. Average Case: ( 2)O(n2)
3. Worst Case: ( 2)O(n2)
4. Space Complexity:
5. Space Complexity: (1)O(1) (in-place sorting)
 Reliability:
1. Bubble Sort is not recommended for large datasets due to its poor performance in average
and worst cases.
Insertion Sort
Applications:
1. Small Datasets: Like Bubble Sort, it is efficient for small datasets.
2. Nearly Sorted Data: Insertion Sort performs very well on nearly sorted data, making it useful
for situations where data is incrementally updated.
3. Real-Time Systems: It can be used in real-time systems where the array is sorted with each
new addition.
 Time Complexity:
1. Best Case: ( )O(n) (when the array is already sorted)
2. Average Case: ( 2)O(n2)
3. Worst Case: ( 2)O(n2)
4. Space Complexity:
5. Space Complexity: (1)O(1) (in-place sorting)
 Reliability:
Insertion Sort is more efficient than Bubble Sort for small and nearly sorted datasets.
However, it is still not suitable for large datasets due to its quadratic time complexity
in the average and worst cases.
 Selection Sort
Applications:
1. Small Datasets: Useful for small arrays and lists.
2. Memory-Constrained Environments: Due to its (1)O(1) space complexity, it is
suitable for environments where memory usage is a critical factor.
 Time Complexity:
1. Best Case: ( 2)O(n2)
2. Average Case: ( 2)O(n2)
3. Worst Case: ( 2)O(n2)
4. Space Complexity:
5. Space Complexity: (1)O(1) (in-place sorting)
 Reliability:
Selection Sort is less efficient compared to Insertion Sort on small and nearly sorted
datasets because it always performs ( 2)O(n2) comparisons. It is not recommended
for large datasets.
 Comparison and Conclusions

Best Sorting Algorithm:


Efficiency: Among the three, Insertion Sort generally performs better on small and
nearly sorted datasets due to its best-case time complexity of ( )O(n).
Stability: Bubble Sort and Insertion Sort are stable, meaning they preserve the
relative order of equal elements. Selection Sort is not stable.
Simplicity: Bubble Sort and Selection Sort are simpler to understand and implement
compared to Insertion Sort.
Overall Recommendation:
For Small and Nearly Sorted Datasets: Insertion Sort is the best choice due to its
( )O(n) best-case performance.
For Teaching and Learning: Bubble Sort is ideal for introducing sorting algorithms
due to its simplicity.
For Memory-Constrained Environments: Selection Sort is useful due to its
constant space complexity, despite its ( 2)O(n2) time complexity.
For larger datasets or scenarios where performance is critical, more advanced
algorithms like Quick Sort, Merge Sort, or Heap Sort should be used due to their
superior time complexities.

Lab Assessment
Understanding Ability to perform Generation and Ability to relate
of Engineering experiment using Interpretation of experiment with
Tools Engineering Tool results using theory and its
(Criteria 1) (Dev C++) modern tools significance Total
2 (Criteria 2) (Dev C++) (Criteria 4) 15
6 (Criteria 3) 3 Marks
4
Task 1

Average
Marks

Lab Engineer Name: M. Saqib Niaz Signature: ___________________

You might also like