search.py - import random import math import time...

This preview shows page 1 out of 1 page.

import randomimport mathimport timerandomlist= [*range(0,100)]# Print the listprint(randomlist)def linear_search (target,lyst):if target not in lyst:return Falseelse:return Truedef binary_search(target,lyst):lenghts = len(lyst)mid = lenghts//2if mid >= target:firsth = lyst[:mid]if target not in firsth:return Falseelse:return Trueelif mid < target:second = lyst[mid:]if target not in second:return Falseelse:return Trueelse:return Falsedef jump_search(target,lyst):n= len(lyst)step = math.sqrt(n)prev = 0while lyst[int(min(step,n)-1)]< target:
End of preview. Want to read the entire page?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
CharlesD.Allison
Tags

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture