Brute force search on a sorted list

preview_player
Показать описание
Can you figure out what's wrong with Richard's code?

Note all videos were encoded using Pied Piper's lossless compression algorithm, and were verified to have a Weissman score of 5.2 before uploading.

From HBO's Silicon Valley
Рекомендации по теме
Комментарии
Автор

Brute force searching the room is such a good gag

tomaspabon
Автор

Dinesh is a good friend he didn't laugh and he knows what Richard is capable of

vadapallichaitu
Автор

I haven't heard a programmer say "subroutine" in 30byears.

miblish
Автор

linear search can be faster if the list is smaller. around 100 elements is when binary search starts to win

reifrei
Автор

This is not that bad. All depends on the array size. If this is a small routine which isn't called that much then it's better to keep code concise and just do a linear search (albeit with clearer code than this). Not every line of code in a program needs optimization. Focus on bottlenecks.

EpicVideos
Автор

Silicon Valley is usually pretty based in its jokes but this one is just dumb. It's totally fine (and even expected) to brute force search a sorted list, especially if the list is relatively small. A more advanced algorithm would take more overhead and be harder to read.



The only real crime that Hendrix made was how unreadable that code is, jesus. The show runners were really playing code golf with this one.

poketopa
Автор

The code is super unreadable in my honest opinion. It's good for competitive coding though. I had to read the while loop three times and then I understood that he's looping until he found the element or array has exhausted. Once either condition reached, then either return index of found if found or return -1. All this has been compressed in just 3 lines. Omg. I would had written atleast 8-10 lines for all that logic.

shankysays
Автор

All of you guys replying this could also be C++: Yes, it could, but it obviously isn’t. The method names are dead giveaways. It‘s Java.

xhelloselm
Автор

Is this Java or C/C++? Or not enough info to tell?

rileyfletch
Автор

seriously dont get the problem there...

SixCoreSecond
Автор

Shame is the only way that the programmers will learn.

Lots and lots of shame, ridicule and jokes at their expense.

This is the most effective strategy to achieve highest levels of performance. Everyone knows this.

ChrisAthanas