Order and Conquer: Binary Search

  Рет қаралды 3,252

SithDev

SithDev

Күн бұрын

Пікірлер: 5
@TheDarkOne629
@TheDarkOne629 Жыл бұрын
Very nice video! Here's what I think of when I hear of binary search: When I took a course on functional programming in haskell, a student walked up to the professor and asked "Why is binary search in Haskell so slow?" The professor couldn't explain and the lecture soon ended. Investigation continued until late into the night. In short: It's O(nlogn). If you use an algorithm, check your data types. If something works great on arrays (or rather, an ordered, random-access structure), it is probably horrible for linked lists. Even simple operations like getting the length can be O(n). Of cause there are linked list implementations which get around these issues. But there's more issues specific to lists in Haskell and other "purely" functional languages.
@thiernondiaye7781
@thiernondiaye7781 2 жыл бұрын
Incredible explanation precise and clear
@TECHN01200
@TECHN01200 Жыл бұрын
I ultimately have 2 criticisms, the first about looking for duplicates and the second about applying theory to practice. With looking for duplicates, there is an algorithm, albeit, not in-array, of which is O(n) complexity: - initialize a hash set - iterate over the array - check the hash set if the current array element exists, if so, there is a duplicate, otherwise, continue - add the current element to the hash set - repeat until you find the first duplicate, all the duplicates, or nothing else exists. I know this isn't in-array, however, it is a single loop with constant time instructions. Given the caveat of the algorithm having to be in-array, yes, the video is otherwise accurate. Second criticism is about how fast binary search is in practice as most of the time, your data is not ordered, or if it is ordered, you asked for it to be ordered, and therefore, the time sorting the set must still be taken into account. In some cases, yes, you can sort the data either at build/compile time or during start time, however, if you have to sort at runtime for some reason, given a time complexity for a sorting algorithm, there is an inequality for an array of a given size which tells you the minimum number of times you search that data, given it doesn't change between searches, where binary search is always better than linear search. Again, the caveat with this is that the array must not be mutated from one search to the next.
@imperatoreTomas
@imperatoreTomas Жыл бұрын
You rock
@aze4308
@aze4308 Жыл бұрын
yoooo
Sorting Values with Selection and Bubble sort
8:14
SithDev
Рет қаралды 4,8 М.
Comparing Algorithms: Big O Notation
17:17
SithDev
Рет қаралды 6 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Lab 09 - Assembly Language for x86 Processors by KIP R. IRVINE
13:56
Abdul Qadeer Bilal (AQ)
Рет қаралды 202
How Binary Search Makes Computers Much, Much Faster
6:51
Tom Scott
Рет қаралды 1,4 МЛН
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 835 М.
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 900 М.
Big O Strikes Back
19:07
SithDev
Рет қаралды 9 М.
AVL Trees & Rotations (Self-Balancing Binary Search Trees)
20:38
Back To Back SWE
Рет қаралды 352 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН