5 ms·
The “standard library” often isn’t available in early boot scenarios.
by rrdharan 3y ago
The “standard library” often isn’t available in early boot scenarios.
- pjmlp 3y agoTrue, but there are plenty of CS books about algoriths and data structures.
- saagarjha 3y agoConverting those into code is not always trivial.
- pjmlp 3y agoDepends on the quality of the degree. Besides I would assume anyone getting ready for their leetcode assignments goes through them anyway.
- saagarjha 3y agoNah, it’s not. Correctly implementing algorithms is hard; it’s easy to create incorrect behavior on edge cases and performance pitfalls. I’m sure you knew about the Java issue from a while back, for example.
- naniwaduni 3y agoCopying a convenient-looking one out of a CS book is how you end up with a bubble sort. Approximately nobody comes up with a bubble sort from scratch; it's obviously, gratuitously bad in a way that there's no practical reason to think of on your own. The sorts that people come up with without reference are usually insertion and selection sorts—those two were discovered before bubble sort.
- pjmlp 3y agoOnly if they never managed beyond first chapter.
- deleted 3y ago[deleted]
- anikan_vader 3y agoPlenty of children come up with bubble sort as a sorting algorithm. It’s intuitive to go down the list swapping any pairs that happen to be in the wrong order.
- naniwaduni 3y agoIt's also very intuitive to pick out a misplaced item and put it in the right position. In the context of physical objects (e.g. playing cards), it's even more intuitive to come up with a (two-way) insertion sort than a bubble sort.
- tedunangst 3y agoBubble sort occupies a weird space where people assume it's dumb and simple so it'll be the least code, but even insertion sort tends to beat it.
- naniwaduni 3y agoI mean yeah, bubble sort is basically insertion sort but weirdly pessimized in a way that makes negative sense. Giving it a catchy name has probably been a net harm.
- pengaru 3y agoLifting sample code out of an academic text, now there's a winning strategy for rock solid stability, correctness, and performance!
- pjmlp 3y agoIt is at least on the world where being an engineer actually requires a degree, and not just because someone likes the word. The real ones, the ones that write USENIX papers.
- thomastjeffery 3y agoThe standard library can be statically linked...
- xorvoid 3y agoPeople who think this way haven’t written boot code.. I suppose you’re gonna link the c runtime too and it’s assumption of being a “process” under some “operating system”.. oh wait. Compared to the rest of the task, writing a sort is pretty darn trivial.
- tedunangst 3y agoThis is true if we're talking about the first stage bios boot that needs to fit in 512 bytes, but there aren't any particular restraints on kernel size at the point in question. Link in anything you want, including qsort.