How to improve the Algorithm Development Process?

Yvonne Chen
3 min readMar 19, 2021

Today, algorithms are a very common topic in the software development industry. It’s a subject that requires deep understanding and problem solving skills. For most people, algorithms probably don’t seem that easy. It takes time and practices to train our brain to be good at it.

How do we improve our problem solving?

Here are the steps I personally find helpful!

  1. First, read the problem twice. First time is to see what the problem is asking, and the second time is to rephrase the problem in our own words so that we can make sure we understand the problem thoroughly (aka analyzing the problem). This step will also help us identify inputs, outputs and edge cases in the problem.
  2. Second, describe our approach to the solution at a high level. This can be a sentence or two without listing all the details.
  3. Third, write out our pseudocode. Pseudocode doesn’t have to in a long completed sentence. It can be done in a few key words to briefly describe what each step is to solve the problem. Personally, I think pseudocoding is a great way to help us break down the problem in smaller pieces by steps without implementing our actual code. It’s also easier to spot problems in our thought process and fix our logic through pseudocode than the actual code. As we get better at solving algorithmic problems, eventually we might be able to skip this step in easier challenges.
  4. Fourth, implementing our code, but testing it as we go. Don’t wait until we finish the whole problem to run the code. If it’s not working, it could take us back to square one, double our work and time.
  5. Lastly, assuming our last solution is working, let’s try to make our code DRYer and solve the problem in a different way but following the same steps. Or, even more, look at how other people solve the same problem. This can only benefit us to excise our brain more and improve our problem solving. As a software developer, we generally don’t just write code, we also read others’ code. Therefore, being able to read others’ code and understand how their solutions work in each step will expand our knowledge.

Finally, let me demonstrate a simple algorithm coding problem I have done in the past. The problem has to do with manipulating string cases. I also show two different solutions: one is using the array conversion method while the other is using the string concatenation method. If you are interested in learning and looking for more coding practice with various difficulty levels, you can certainly check out edabit, LeetCode, codewars, and coderbyte.

// Write a function toggleCase which takes in a string and returns a new string where all the lowercase 
// letters are changed to uppercase and all the uppercase letters are changed to lowercase
toggleCase('ZaCh'); //'zAcH'
toggleCase('APPLE'); //'apple'
toggleCase('Good morning, everyone!'); //'gOOD MORNING, EVERYONE!'
// Using array conversion method function toggleCase(string) {
var splitString = string.split(""); // array
var result = [];
for (var i = 0; i < splitString.length; i ++) {
if (splitString[i] === splitString[i].toLowerCase()) {
splitString[i] = splitString[i].toUpperCase()
result.push(splitString[i]);
} else {
splitString[i] = splitString[i].toLowerCase()
result.push(splitString[i]);
}
}
return result.join("");
}
// Using string concatenation methodfunction toggleCase(string) {
var newString = "";
for (var i = 0; i < string.length; i ++) {
if (string[i] === string[i].toLowerCase()) {
newString += string[i].toUpperCase();
} else {
newString += string[i].toLowerCase();
}
}
return newString;
}
www.simpsonsworld.com

Hope you find some useful algorithm tips from my blog in solving coding problems and feel beneficial from this strategy in improving the algorithm development process.

Thanks for reading!

--

--

Yvonne Chen

Full Stack Software Engineer with Finance Background