Wednesday, April 24, 2019

Binary and Linear Searches

Write down a list of instructions for someone who is not in the class to tell them how to perform a linear and binary search.


Linear sort, this is when you sort through a list of ordered numbers until you find what you need.
Binary sort, this is wen you cut the list in half and the sort through the unordered nubers


Linear

-Look at people
-Ask for their names
-Compare to register item
-If a name isn't called but is on register, they aren't in


Mylist = (1,2,3,4,5,6,7)
i = 7
i - 1 until = 7


Binary
Mylist = (1,3,2,9,7,8,5)
i = 7
i - i/2
  if mylist is in i stop sort
  else ,loop















No comments:

Post a Comment