10 comments
@marjolica @zens @arnelson bubble sort is great if you only have like 20 items, or the list is nearly sorted already 😃 @marjolica @zens @arnelson also if it's not fast enough it'll show up on the profiler and you'll fix it @JoshJers @zens @arnelson back in 1974 I inherited a large Fortran program (about 2000 punch cards) that ran on IBM370 mainframes. The purpose was to calculate the UK power stations fuel use. It used to take 2 minutes of CPU time to run the entire program. It included a bubble sort to put the list of the power stations into 'merit order'. There were about 3000 items in the list. When I replaced bubble sort by quick sort I reduced the total run time to 2 seconds with big savings to our budget. @marjolica @zens @arnelson Yeah, 3000 is definitely the wrong number of elements for bubble sort to be a good choice, *especially* in 1974 😁 @marjolica @JoshJers @arnelson well, the rule of thumb is “probably” not “definitely”. sometimes we work ourselves up about scaling problems that just never happen @zens @marjolica @arnelson exactly! The ultimate point is "write it the most straightforward way you can to start, then fix performance problems when they become apparent" @JoshJers @marjolica @arnelson and also, once again, these are strategies for when you get stuck, not general rules of thumb |
@JoshJers @zens @arnelson "the naive implementation is probably fast enough" - not when it's bubble sort it isn't.