Safari
Safari
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.
Best Case :
Average Case:
23CE130
Worst Case :
Best Case :
Average Case :
23CE130
Worst Case :
23CE130
2. How does insertion sort outperform selection sort when the elements are already
sorted? Justify your answer.
23CE130
Conclusion: