Computer Science, asked by roshankumar9903, 10 months ago

Optimal binary search tree example problem to draw based on given articles do, if, while, int

Answers

Answered by rajisaisahasra
0

Answer:this is a program in python(since we learn python)

def bin_search(a,s):

   q='Element is not found in the given list'

   l=len(a)-1

   f=0

   while f != l:

       m=(f+l)//2

       if a[m]>s:

            f=m

       elif a[m]<s:

            l=m

       else:

            q= str('Element is found at',m+1,'position')

   return q

a=[<the list>]

a.sort

s=int(input('Enter elemnt to be searched'))

print(bin_search(a,s))

#note:

#      The given list should be of numbers(not strings)

Similar questions