You are on page 1of 1

Data Structures and Algorithms

Section-A
The University of Lahore
Assignment-2
Announced: Wednesday 03-10-2018
Deadline: Tuesday 09-10-2018, till 12 at night,
email to: Yasir.niaz@cs.uol.edu.pk
Late Submission: 10% marks deduction per hour.

Problem Statement:
Implement the following functions in C++:
 Linear Search
 Binary Search
 Bubble Sort
 Insertion Sort
 Selection Sort

In each of these functions, make a counter that counts how many times the
statements inside the loop(s) run. Then divide this number by “size” and
tell whether this function takes time O(n), O(log n) or O(n 2)?

Your program should be able to run the following “main” function:

main()
{
float array[1000];
LinearSearch(array, 5.3);
BubbleSort(array);
BinarySearch(array, 8.2);
InsertionSort(array);
SelectionSort(array);
}

You might also like