Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are to return the index

image text in transcribed

(40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are to return the index of the specified number, or -1 if the number is not in the input list. Also, even if you pass the tests, the TAS will go through the code and ensure you implemented linear search for linear search and binary search for binary search. For example, searching [0, 5, 10] for 10 should return 2. Searching [0,5, 10] for 12 should return -1. (a) In repl.it implement the linearSearch() method. This method should perform linear search on the given input list, and return an index, or -1 if the element doesn't exist. (b) In repl.it implement the binarySearch() method. This method should perform binary search on the given input list, and return an index, or -1 if the element doesn't exist. inputArray - a passed in array of integers, not necessarily sorted sortedArray - a sorted array of integers searchTarget - the number you are searching for Helpful hints: You are looking to return the index of the found number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago