Algorithms: Difference between revisions
From Pumping Station One
No edit summary |
No edit summary |
||
| Line 89: | Line 89: | ||
while first <=last and not found: ### this is a while loop that runs the logarithmic structure of the heap sort until the indicated element is found | while first <=last and not found: ### this is a while loop that runs the logarithmic structure of the heap sort until the indicated element is found | ||
midpoint = (first + last)// 2 ### this is the logic equation of the python code to run, this finds the midpoint element of the array by adding the first and last integer of that array and diving it by 2 | midpoint = (first + last)// 2 ### this is the logic equation of the python code to run, | ||
###this finds the midpoint element of the array by adding the first and last integer of that array and diving it by 2 | |||
if alist[midpoint] == item ### if the midpoint from the previous equation equates to the indicated integer, then element is found | if alist[midpoint] == item ### if the midpoint from the previous equation equates to the indicated integer, then element is found | ||
found = True | found = True | ||