Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

include comments. Attachment below. thank you. 6. [10 Points] Programming assignment (Lab 15.8): Finding the first occurrence. This program is to be submitted both as

include comments. Attachment below. thank you.

image text in transcribed
6. [10 Points] Programming assignment (Lab 15.8): Finding the first occurrence. This program is to be submitted both as Lab 15.8 in the zyBook and as a listing on GradeScope. You are to write the code of a Python function binsearch first (ordered_list, target) that, given a nonempty ordered list of items and a target item, all of the same type, returns the index of the first occurrence of the target in the list, if the target is in the list, and None otherwise. For example, the call binsearch first ([1, 3, 3, 7, 9], 3) should return 1 since the first 3 is at index 1. Similarly, the call binsearch first ( [1, 3, 3, 7, 9], 9) should return 4, and the call binsearch first ( [1, 3, 3, 7, 9], 5) should return None. You may not assume anything about the type of the items, other than that they are orderable. For example, items could be strings and the call binsearch first (["Alice", "Bob", "Chloe", "Chloe", "Dave"], "Chloe") should return 2. Your program will be evaluated for efficiency and style. For full credit, it may only make a single test for equality (it may only have a single "==" comparison which, additionally, may not be within any loop). That is, the only equality test happens at the end of execution, just before returning. Restrictions: Recursion is not allowed for this problem. Furthermore, you are not allowed to use any operations other than + , - , / /, x ,

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_2

Step: 3

blur-text-image_3

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What factors must be present for a strong family business?

Answered: 1 week ago