Member-only story
YouTube Video Review: Top 7 algorithms for coding interviews explained
In my last blog post, I discussed the top seven data structures, and that post can be found here:- https://medium.com/@tracyrenee61/youtube-video-review-top-7-data-structures-in-interviews-simply-explained-720d26c08041
In this post, I intend to review another video by the same content creator, and this video is entitled, “Top 7 algorithms for coding interviews explained. This is a good video, but it does not include code on how to create those algorithms in code, so I will endeavour to discuss the seven algorithms and provide code in Python to accompany them.
Binary search
Binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.
Binary search is faster than linear search except for small arrays. However, the array must be sorted first to…