
We've all heard the concept of an algorithm, but what exactly is it? Simply, an algorithm is a series of instructions followed by a computer to solve a problem.
We will see an example of an algorithm that converts kilometers to miles. The user simply inputs a value in kilometers, and the algorithm calculates and prints the result.
Why do we have computers solve a problem in the first place instead of solving it ourselves?
It is certain that humans were solving problems long before computers appeared, and continued to do so even after the development of technology. However, many times we choose to assign the computer to solve a problem, instead of solving it ourselves. Why does this happen? We will discuss it in this lecture.
What a computer "understand" ? We will discuss this in detail.
Let's quickly go over some concepts that will help us in the continuation of the lessons.
What are Algorithms? As we've already mentioned, an algorithm is a theoretical concept. It refers to the thought process we follow to solve a problem. To practically represent this thought process, we depict algorithms in the following ways:
free text
natural language step-by-step
diagrammatic techniques
coding
We will only use coding, meaning we will write a program in pseudocode that, when executed, will produce the same results as the algorithm.
In the previous lessons, we introduced the concept of an algorithm and pseudocode, saw the difference between pseudocode and programming, and emphasized why it is important to be familiar with pseudocode before proceeding to learn a programming language. In this chapter, we will see how we start solving a problem, what the basic control structures we use are, and what commands we use. At the same time, we will begin to solve simple, as well as more complex, problems by coding with pseudocode.
In the previous sections/lessons, we discussed what a program written in pseudocode is, its purpose, and how it helps us prepare for programming. We also covered what we define as a problem and the stages of problem-solving. Based on this knowledge, and to move away from the theoretical concept of algorithms and towards their practical application, we will use our own Online interpreter in this url( https://giannisdemertzidis.com/ ). This will help us write pseudocode in a hypothetical programming language by creating our own "Programs." It is important to clarify that normally, a program is written in a programming language, and not in pseudocode. The Online interpreter is used for educational purposes and helps us become familiar with the thought process of programming. All that's left for us to do to write a program is to learn the vocabulary of the programming language we're interested in, such as Python.
In the case where we have a simple problem that is solved in a specific sequence, we use the sequence structure. For example we will create a program that reads two numbers, adds them, and outputs their sum in the pc screen.
If our problem involves a choice, we need to use a selection structure. For example, we need a program that decides whether we will go on a trip or not, depending on the weather. We will create a program and ask the user to tell us what the weather is like outside.
Nested Procedures refer to the possibility of having a case within a case. Here is an example: Create a program that reads the height and hair color of the user. If the height is > 6.2 and the user is blonde-haired, it displays “tall and blonde-haired”; if the height is < 6.2 and the user is blond, it displays “average height and blonde-haired”. In this case, we have two "if" statements, i.e., one "if" is nested within another. So, we have to write a program that roughly has 4 cases: (if the user is tall and blonde-haired, if the user is tall and dark-haired, if the user is average height and blonde-haired and if the user is average height and dark-haired). We will see now how we would write this program.
When we need to perform a step many times, we use a repetition structure. For example, if we want to display all the integers from 1 to 100. To avoid writing a program that includes all these numbers that is large and tedious, we use one of the 3 repetition structures as we will see in this lecture.
So far, we have studied the basic control structures written in pseudocode. However, there are certain categories of problems that require different types of structures to solve. What are these structures? In both programming and pseudocode, when we need to manage a large volume of data of the same type, we can use arrays instead of variables. In this section, we will see what we define as an array, when we use arrays, what types of arrays there are, and how arrays work in pseudocode.
This is the definition for “arrays”.“Arrays are fundamental data structures in computer science and programming. They provide a way to store and organize multiple elements of the same type in a contiguous block of memory. Arrays offer efficient access to individual elements and enable various algorithms to manipulate and process the data they hold.”
Let's start with one-dimensional arrays and see an example. Suppose we want to create a program based on the array we saw previously, which contains the maximum humidity of a month. We will write a program that reads the humidity of 31 days and calculates the average maximum humidity of the month.
In the case of two-dimensional arrays, we use 2 indices to specify an element. For example, if we wanted to calculate the average humidity for 10 cities over a month and determine how many days the humidity was higher than the corresponding average value.
Sorting an array is a very important operation that arranges the data of an array in ascending or descending order.
Are you ready to unlock the mindset of a programmer and lay a strong foundation for your coding journey? This beginner-friendly course is designed to help you master pseudocode—an essential skill for solving problems and transitioning seamlessly into any programming language.
By the end of this course, you'll confidently write pseudocode to tackle complex problems, equipping you with the thinking process behind successful programming. But why start with pseudocode? It’s simple! Pseudocode bridges the gap between problem-solving and coding by focusing on logic without the distractions of syntax. Once you grasp pseudocode, learning the vocabulary of any programming language becomes a breeze.
Here’s what you’ll explore:
A historical overview of how computers understand and solve problems.
An introduction to problem-solving techniques and strategies.
The fundamentals of pseudocode, including algorithms and arrays, with detailed examples.
Hands-on practice through a guided assignment to apply your new skills.
Whether you’re a complete beginner or someone looking to strengthen your programming basics, this course offers a step-by-step approach to developing the problem-solving mindset critical for coding.
Join us on this exciting journey, and by the end, you’ll have the tools to write "programs" using pseudocode. Enroll now and take the first step toward becoming a confident programmer!