Lab Assignment -3 Date: 18 th & 21st Aug’2023
Subject – Data Structure Lab
Stream – CSE Semester – 3rd Batch – 2
Lab Experiment: Analysis of an Algorithm and Asymptotic Notations
Aim: To understand the concepts of algorithm analysis, asymptotic notations, and the trade-off between
time and space complexity in algorithm design.
Experiment Tasks:
Task 1: Algorithm Analysis
i) Implement the Bubble Sort sorting algorithm.
ii) Generate an array of random integers (e.g., 100 elements).
iii) Record the start time before executing the sorting algorithm.
iv) Execute the sorting algorithm on the generated array.
v) Record the end time after the sorting is complete.
vi) Calculate and print the time taken for sorting.
Task 2: Asymptotic Notations
i) Implement a linear search algorithm to find the same element in the array.
ii) Calculate and print the number of comparisons made by each algorithm.
iii) Discuss the efficiency and time complexity of binary search and linear search.
iv) Use Big O notation to express the time complexity of both search algorithms.
Task 3: Time-Space Trade-Off
i) Implement a recursive function to calculate the nth Fibonacci number.
ii) Implement an iterative function to calculate the nth Fibonacci number.
iii) Compare the time taken by both approaches for calculating Fibonacci numbers up to a specific
value (e.g., n = 30).