{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Binarysearch_sorting

# Binarysearch_sorting - Analysis of Binary Search algorithm...

This preview shows pages 1–3. Sign up to view the full content.

Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to solve the problems, and compute the time complexity of the algorithms. The two problems, one related to searching and the other related to data sorting are very common in many real world situations. Binary Search Method: Suppose we are given a number of integers stored in an array A, and we want to locate a specific target integer K in this array. If we do not have any information on how the integers are organized in the array, we have to sequentially examine each element of the array. This is known as linear search and would have a time complexity of O(n ) in the worst case. However, if the elements of the array are ordered, let us say in ascending order, and we wish to find out the position of an integer target K in the array, we need not make a sequential search over the complete array. We can make a faster search using the Binary search method .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document