0% found this document useful (0 votes)
5 views9 pages

Safari

The document outlines a practical assignment for a computer engineering course focused on the design and analysis of algorithms. It includes tasks such as implementing and analyzing search algorithms (linear and binary) and sorting algorithms (insertion sort), along with data tables and line charts for performance metrics. Additionally, it poses questions regarding modifications to binary search and comparisons between sorting algorithms, concluding with a section for grading and teacher's signature.

Uploaded by

Moksh Shah
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)
5 views9 pages

Safari

The document outlines a practical assignment for a computer engineering course focused on the design and analysis of algorithms. It includes tasks such as implementing and analyzing search algorithms (linear and binary) and sorting algorithms (insertion sort), along with data tables and line charts for performance metrics. Additionally, it poses questions regarding modifications to binary search and comparisons between sorting algorithms, concluding with a section for grading and teacher's signature.

Uploaded by

Moksh Shah
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/ 9

Faculty of Technology and Engineering

Chandubhai S Patel Institute of Technology


U & P U. Patel Department of Computer Engineering
Performa for PRACTICAL – 2
Roll no. - 23CE130: Date: / /

Academic Year : 2024-25 Semester : 4

Course code : CE264 Course name : Design and Analysis of Algorithms

AIM:
2.1 Implement and analyze the best case, average case and worst case of the
algorithms for problems given below.

2.1(a) Given a sorted array of integers, find the first occurrence of a target element
x. If the target element is not found, return -1. Explore alternatives of searching
such elements and analyze.

2.1(b) Given an array of integers, use Insertion Sort algorithm to sort the array in
ascending order.

2.1.1 (a) Data table: linear search algorithm

Input Best Case Average Case Worst Case


2 3 6
5
2 5 11
10
2 8 16
15
2 10 21
20
2 13 26
25
23CE130

2.1.1 (b) Line Chart: linear search algorithm


23CE130

2.1.2 (a) Data table: binary search algorithm

Input Best Case Average Case Worst Case


2 4 4
5
2 5 5
10
2 5 5
15
2 6 6
20
2 6 6
25
23CE130

2.1.2 (b) Line Chart: binary search algorithm

Best Case :

Average Case:
23CE130

Worst Case :

2.2.1 (a) Data table: insertion sort algorithm

Input Best Case Average Case Worst Case


4 10 20
5
9 45 90
10
14 105 210
15
19 190 380
20
24 300 600
25
23CE130

2.2.2 (b) Line Chart: insertion sort algorithm

Best Case :

Average Case :
23CE130

Worst Case :
23CE130

Answer the following Questions:


1. How would you modify binary search to find the last occurrence of given target
element?

2. How does insertion sort outperform selection sort when the elements are already
sorted? Justify your answer.
23CE130

3. Can insertion sort be optimized using binary search in terms of number of


comparison, number of shifts and overall time complexity?

Conclusion:

Grade / Marks Sign of Lab Teacher with Date

You might also like