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.

  1. Clarify the question - lowercase vs uppercase, how big is the characterset or number set? Are there negative numbers, duplicates etc?
  2. If an algorithm doesn't come to mind, use examples to clarify and digest the information given
  3. More examples, and try to see a pattern in the relationship between input and output
  4. Generalize the pattern for other values of N and other variations of the question. If stuck, consider looking at hints perhaps.
  5. Write the algorithm in pseudocode
  6. Check it over with the examples from above
  7. Implement in a few common languages of choice
  8. Test and check for correctness
  9. Look at the solution and compare your answer
  10. Revise and improve your answer as needed
  11. 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?