Finding the smallest and the largest value at the same time. #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

subprocessing the initial problem is a good logic

caio
Автор

I miss you, I wish you make more videos when you have the time, literally the most elegant algo channel (even with so low number of videos)

sandflow
Автор

What if you "merge" the pairs in a divide-et-impera fashion, like a quick-sort?

marcoottina
Автор

I am confused, won't the splitting operation lead to increase in complexity anyway? here the example test case is smaller but what for larger arrays?

yagami-light
Автор

Babe wake up, the best data structure yt channel first reel just dropped

sunvaroya
Автор

The second method is in theory only slightly faster than the first one, but in practice any implementation would end up using a lot more memory and/or taking as much time and maybe even longer.
This is an example of why "optimization" for the sake of optimization shouldn't be done

GalileoCap
Автор

The first method is comparing two numbers to each number in n size array, so 2n computations. The second method is comparing every number to its neighbor, n/2 computations, then comparing the min and max to the min and max of those... which ends up being n computations, totalling n/2 + n, or 3n. I'm not experienced enough to know in what real life or hypothetical scenarios the latter would be more efficient.

maxinac
Автор

What about, call .sort() cause using a list, sort can be in same memory, and O(n*log(n)) < ( n/2 + 2(n/2 - 1)) ?

seboeh