In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem.
Why are Algorithms Important to Understand?
Algorithmic thinking, or the ability to define clear steps to solve a problem, is crucial in many different fields. Even if we’re not conscious of it, we use algorithms and algorithmic thinking all the time. Algorithmic thinking allows students to break down problems and conceptualize solutions in terms of discrete steps. Being able to understand and implement an algorithm requires students to practice structured thinking and reasoning abilities.
This article originally appeared on junilearning.com
First off, what is a Palindrome?
A palindrome is a word, number, phrase, or another sequence of characters that can be read backward and forwards, like a kayak or racecar.
Write a function isPalindrome that will receive one argument, a string. Your function should return true if the string is a palindrome (that is, if it reads the same forwards and backwards, like "kayak" or "racecar"), and return false if it is not a palindrome.
In our exercises, we were given recommended steps as follows:
- Rewrite The Problem in Your Own Words
I love this part since we're able to write the problem the way we understand it.
/I need to make an isPalindrome function() that returns either true or false. When the input string is the same forwards and backwards, I should return true. That means that if the input string is the same after I reverse it, I should return true. For instance, "kayak" in reverse is also "kayak", and "racecar" in reverse is also "racecar", so my solution should return true for these cases. "hello" in reverse is "olleh", so my solution should return false for this case./
- Write Your Own Test Cases
This to me is identifying what input your code should handle and what output you expect to return. Like a trial and error. This way will help you build the model to solve the problem.
Examples From Our Lecture:
How do you effectively write a Pseudocode and What are its advantages? So many questions.
Pseudocode is a simple way of writing programming code in English. Pseudocode is not an actual programming language. It uses short phrases to write code for programs before you create them in a specific language. Once you know what the program is about and how it will function, then you can use pseudocode to create statements to achieve the required results for your program.-Alisa Perry
It is like writing your code on your terms and rules in short statements. I'm learning slowly but surely.
- Make It Clean And Readable
I'd say make your solution organized and simple as much as possible and prevent it from being redundant 'Don't Repeat Yourself. Try to develop a basic structure and strive for readability.
It means coming up with a new way to reverse a string that involves fewer steps or coming up with another solution that doesn't involve reversing a string. For instance, using for loop.
I still have a lot to learn and a long way to go. The first thing I need to get better at is understanding the fundamentals and data structures. Read books and watch tutorials. Be more resourceful and have fun practicing algorithms using the steps on Coderbyte and HackerRank or simply write them down on my notepad. One step at a time.