Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called modified_binary_search that will take a list, a value, a lower range, and an upper range as arguments. Then, perform the binary

Write a function called modified_binary_search that will take a list, a value, a lower range, and an upper range as arguments. Then, perform the binary search in the specified range (From lower range to upper range) of that list. If the value is found in the specified range of the list, then return the index of the FIRST occurrence of the value If the value is not found in the specified range of the list, then return -99999 You will only search in the specified range; you must not search beyond the specified range.

================================================ Function Call 1: print(modified_binary_search([2,3,5,6,6,11,13,15,19,21,44,49,56],19, 1, 11)) Sample Output 1: 8 ================================================ Function Call 2: print(modified_binary_search( [2,3,5,6,6,11,13,15,19,21,44,49,56], 6, 1, 11)) Sample Output 2: 3 ================================================ Function Call 3: print(modified_binary_search( [2,3,5,6,6,11,13,15,19,21,44,49,56], 56, 1, 8)) Sample Output 3: -99999 ================================================ Function Call 4: print(modified_binary_search([2,3,5,6,6,11,13,15,19,21,44,49,56],48, 1,11)) Sample Output 4: -99999

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions