Algorithms: Difference between revisions
From Pumping Station One
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 66: | Line 66: | ||
---- | ---- | ||
'''Binary Sort''' (aka half-interval search/logarithmic search) is a search algorithm that finds a target value within a sorted array by comparing the target to the middle element, if unequal, the half of integers where the target cannot lie is unlimited. This process is continued unless target is identified. | '''Binary Sort''' (aka half-interval search/logarithmic search) is a search algorithm that finds a target value within a sorted array by comparing the target to the middle element, if unequal, the half of integers where the target cannot lie is unlimited. This process is continued unless target is identified. In other words, this function will look for an item in an array by dividing the list in half every time it searches. | ||
EX: 1, 7, 27, 33, 45, 57 , 66, 77, 89, 99, 101, 129, 156, 234 | EX: 1, 7, 27, 33, 45, 57 , 66, 77, 89, 99, 101, 129, 156, 234 | ||
| Line 104: | Line 104: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Python Binary Sort Example 2 | |||
<syntaxhighlight lang="cpp"> | |||
</syntaxhighlight> | |||
'''Heap Sort Algorithm''' | '''Heap Sort Algorithm''' | ||
| Line 115: | Line 119: | ||
=== Writing Your Own Algorithms === | === Writing Your Own Algorithms === | ||
Reference: | |||
----- | |||
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-854j-advanced-algorithms-fall-2005/ | |||