Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE_120 Sir_it_is_urgent.do_fast._Please_solve_this_code_in_python3_paste_with_proper_intendent_blocks_bypressing(CTRL+SHIFT+V),Also_please_provide_code_screenshot,_Thank_you. Do_not_need_comments. SKIP_BUILT_IN_FUNCTIONS. Just_give_me_solution_as_fast_as_possible._I_am_running_out_of_time._Attach_a_screenshot_with_yoursolve. Question-3: Write a function called modified_binary_search that will take a list, a value, a lower range, and an upper range

CSE_120

Sir_it_is_urgent.do_fast._Please_solve_this_code_in_python3_paste_with_proper_intendent_blocks_bypressing(CTRL+SHIFT+V),Also_please_provide_code_screenshot,_Thank_you.

Do_not_need_comments. SKIP_BUILT_IN_FUNCTIONS. Just_give_me_solution_as_fast_as_possible._I_am_running_out_of_time._Attach_a_screenshot_with_yoursolve.

Question-3: 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

Explanation: In the first function call the first occurrence value was found on the specified range (from index 1 to index 11) at index 5. Therefore 5 was returned. In the second function call the first occurrence value was found on the specified range (from index 1 to index 11) at index 3. Therefore 3 was returned. In the third function call the value 56 is present on the list but not in the specified range (from index 1 to index 8), therefore, -99999 was returned. Again, in the last function call the value was not found in the specified range and hence -99999 was returned.

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

More Books

Students also viewed these Databases questions

Question

How are stress and anxiety the same/different?

Answered: 1 week ago

Question

Communicate your results in a written report.

Answered: 1 week ago