This repo aims to explain a clear process for algorithm problem solving.
It is addressed to programming students who are new to problem solving or experienced software developers who want to strengthen their problem solving skills following a clear and effective process.
This process is created by Nayib Abdala after trying different approaches and studying from several years the best ways to learn how to solve problems.
PACER - Problem Algorithm Code Execution Refactor -
- Define the problem on your own words: this helps you to go through a cognitive process to validate that you understand what needs to get solved.
- Input/Output: Identify the expected input and output data types: this step let you state what data types/structures you get as an input and what data types/structures you need to return from your solution.
- Examples: Write some examples of the expected results based on examples of the input data: use a desk check (manual computing) to understand what output you should get from a solution given a specific input.
- Edge cases: Ask or propose (when not in an interview) the edge cases that the solution should cover: let you identify cases you might cover that are not explicitly shown in the problem statement.
- Restrictions: Write on the restrictions/rules that are given to the problem: to set the boundaries of your solution.
Write in English the step by step you plan to follow so that you transform the input data into the expected output.
Translate the steps of the previous algorithm into a programming language of your choice.
Execute the code to validate that the test cases are returning the expected result.
You are normally given the test cases as part of the problem.
Think about the following:
- How could I make this code more readable.
- How could I make this code more efficient in terms of time complexity - takes less iterations/"time" - and space complexity - uses less memory - Big O Notation
- Think about edge cases that you might not covered yet and apply the PACER process from the Algorithm step to change what is necessary to cover the new cases.
You can check out a complete example here
You can watch this video with the process applied in real time - Audio in Spanish -
If you want a simpler problem pick one form the repositories below or follow through this one - in spanish -
Check out the PACER process repo in Spanish
- Start writing code without having really understood the problem you have to solve.
- Write a solution to a problem without having considered alternative solutions.
- Waste time writing a solution that does not considered edge cases.
- Writing invalid or incomplete solutions to algorithmic problems.
- Writing solutions that return the wrong data type or data structure.
If you have any doubts send me a direct message via LinkedIn and I will get back to you asap.
↩ Big 0 notation It’s a way to describe how the runtime of an algorithm grows as their inputs grow. In other words is a way t describe how the number of operations to execute an algorithm increases as the input of data to the algorithm increase. Some resources you may want to check BigO Notation 101, BigO notation calculator
Note: The programming problem used in this blog post to show case the PACER process was taken from the Edabit
Copyright | Nayib Abdala