CSE100 Algorithm Design and Analysis    Lab #02 Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (2 votes)

Binary Search

Description In this assignment you are requested to implement the binary search algorithm. You can assume that the input sequence is already sorted in ascending order.

Input structure The test file represents one test case (tN-input, oN-correct output). The sequences and the element to search are integers (i.e. you can safely store them into int variables). Each case starts with a number which is the number of integers in the sequence. The following number is the element to search. Then the elements of the sequence follow, one per line. You can assume that the input is correctly structured (i.e. no data are missing).

Output structure All the searching algorithms must return −1 if as is not in the sequence, or its position (i.e. array index) if it is contained. You can assume that all the numbers in the sequence are distinct.

  • Lab02_BinarySearch-e0wpti.zip