Algorithm for working on a new question
January 28, 2020 by Jane
Below are the steps to take when faced with a problem that is foreign and not straightforward to crack. Consider this a template to use.
- Clarify the question - lowercase vs uppercase, how big is the characterset or number set? Are there negative numbers, duplicates etc?
- If an algorithm doesn't come to mind, use examples to clarify and digest the information given
- More examples, and try to see a pattern in the relationship between input and output
- Generalize the pattern for other values of N and other variations of the question. If stuck, consider looking at hints perhaps.
- Write the algorithm in pseudocode
- Check it over with the examples from above
- Implement in a few common languages of choice
- Test and check for correctness
- Look at the solution and compare your answer
- Revise and improve your answer as needed
- Summarize learnings:
- Where else can I apply the algorithm?
- What would happen if the dataset changed to comething simpler or more complicated? (To include duplicates, negatives, characters other than ASCII... )
- What if the requirements on space and time were more strict or less strict?
- How would you rate the code in terms of efficiency (time and space) and readability?
- What language(s) were easier for this question and what language(s) were more difficult to do correctly?
- What new concepts/optimizations have you learned from reading the solution and what are the implications towards future problem solving?