Introduction Algorithms and Data Structures - Algorithm means solution, the term of solution in the programming language is solving a problem that must be solved using a computer. What steps are needed to solve the encountered problems. Therefore, the algorithm is the core of a programming, the algorithm must be made successively so that the computer understands and can execute the created programs correctly.
Real example to portray the solution of problems that will be solved, for example, a solution to make instant noodles. The steps to create instant fried noodles are :
- Boil water to boiled and then enter the noodles for 3 minutes.
- Mix seasoning, seasoning oil, soy sauce, and chili powder into the dish.
- Drain the noodles, then mix the noodles into the spice mixture on a plate, mix well
- Fried noodles ready to be served.
As humans, we've certainly understand the steps in the making of instant noodles, but the problem in programming is how we can make computers understand step by step to produce what any results we want. In order to be able run on a computer, then the steps of preferred solution should use reasonable language for computers which are packaged in the form of a computer program.
Algorithmic language (pseudocode) is an intermediate language between humans and computers. Pseudocode is designed to simplify the algorithm by human logic transformed into any programming language that understood by computers. There are many programming languages that recognized by the computer, for example, Pascal, Java, PHP, C#, C++, and so on.
Programs are algorithms coupled with data structures. The data structure is a data storage structure required by program on the computer. If humans have a brain to store the data, the computer also needs a place to store the required data. This is due to the data storage on a computer has limited capabilities than the human brain, therefore require an order or structure so that the stored data can be accessed easily.
Learning for programming means learning to make problemsolving strategies or create a solution. While programming language is a tool for learning the programming. In this lab, we will learn to make program using C++ programming language.
See Also : Introduction to C++
Using the previous example about the making of instant fried noodles. We can make the order in the form of good and structured algorithms.
Task 1 : Declarations, is a step to declare a place that used to make the noodles.
- Step 1 : Declare an empty place used as a place to boil the noodles.
- Step 2 : Declaring a place to put the noodles
- Step 3 : Sample code in a algorithmic language at this declaration step is as follows:
Noodle : integer
Seasoning : integer
Boil_Water : integer
Task 2 : Initialization, this step is preparing that process done to resolve the problem.
- Step 1 : Prepare the amount of noodles, water and spice in a balance.
- Step 2 : Sample code with algorithmic language is as follows:
Noodle <- 1
Boil_Water <- 1
Seasoning <- 1
Task 3 : The process of problem solving, is the step for problem solving to meet the goal of an algorithm we made.
- Step 1 : Boil noodles
Noodle <- Noodle + Boil_Water - Step 2 : Mixing a flavor
Seasoning <- Seasoning + seasoning oil + soy sauce + chili powder
Task 4 : Finalization, is a cleanup stage or final stage for example : removing the allocation of places that no longer needed, or serve the fried noodles.
- Step 1 : Dispose the rest of the cooking water that is not used anymore.
Boil_Water <- 0 - Step 2 : Serving the results of fried noodles.
Output (“ Fried noodles ready to be served”)
Exercise
- Create an algorithm to register in University
- Create an algorithm for adding two numbers
- Make an algorithm to determine the number counted as odd or even
- Create an algorithm to calculate the area of a circle
EmoticonEmoticon