Practice question · True or false
The fastest algorithm for a problem in the abstract is the right choice regardless of the data and constraints in front of you.
Hints
- Consider input that is already nearly sorted, or a machine with little memory.
- Asymptotic speed is one constraint among several.
Show the answer
False
Why
False. Insertion sort beats quicksort on nearly-sorted input; an in-place algorithm beats a faster one that needs O(n) extra memory on a device that has none; a simpler algorithm beats a faster one nobody on the team can maintain. The problem, the data and the constraints together decide.
Practise Integrated Algorithm Design Practice
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Integrated Algorithm Design Practice
- A problem is shown to be NP-complete. Why is that useful news rather than merely bad news?
- For 'find the k most frequent words in a huge text', select every design decision the lesson endorses.
- Given a new problem, an experienced programmer often recognises it as a variant of something known - shortest…
- Order the first five steps of the design workflow the lesson recommends.
- Match each data structure to the hot operation it makes fast.