Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: How would I implement the level of each each run like the output below My Code from random import randint def Compare(curr,target): if(curr ==

Python: How would I implement the level of each each run like the output below

image text in transcribed

My Code

from random import randint def Compare(curr,target): if(curr == target): return 0 elif curr  

The output it gives

image text in transcribed

target=37 Sorted: 1 2 4 6 7 8 8 8 9 13 13 14 14 14 14 15 17 18 19 19 19 19 20 22 24 26 26 26 27 28 30 30 31 32 32 33 35 36 36 36 39 40 41 41 41 42 43 44 44 50 53 55 55 57 57 57 58 60 62 64 64 66 67 69 70 70 71 72 72 73 73 73 74 75 77 77 80 80 80 82 82 84 85 85 86 87 88 88 88 89 89 90 90 92 93 94 94 94 97 99 target=75, index=73, level=7 target=53, index=50, level=6 index=-1, level=6 target=64, index=59, level: target=76, index--1, level=7 target-14, index=11, level=3 target=25, index=-1, level=6 target=52, index=-1, level=6 target=58, index=56, level=6 target=11, index=-1, level=6 Binary Search: 0.00051 ms, average level=5.9 Sorted: (1, 1, 1, 7, 8, 8, 8, 9, 13, 14, 14, 15, 15, 15, 15, 17, 17, 17, 19, 21, 21, 22, 24, 25, 27, 28, 28, 28, 29, 30, 30, 31, 32, 35, 35, 36, 36, 37, 38, 39, 40, 44, 4 target = 39, index = 40 target = 9, index = 8 target = 86, index = -1 target = 22, index = 22 target = 73, index = 78 target = 92, index = 94 target = 28, index = 28 target = 100, index = 99 target = 82, index = 86 target = 30, index = 31 Process finished with exit code o

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions