0% found this document useful (0 votes)
14 views17 pages

Introduction to Algorithms and Programming

This document introduces algorithms and different algorithm notations. It defines an algorithm as a list of computational steps to transform input into output. It provides examples of algorithms for a child's morning routine and calculating the average of 5 math scores. It distinguishes algorithms from programs, noting algorithms are implemented in programs. It also describes different algorithm notations including natural language, flowcharts, and pseudocode. Pseudocode is similar to code but has no standard syntax. Flowcharts use symbols to visually depict a program's flow.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views17 pages

Introduction to Algorithms and Programming

This document introduces algorithms and different algorithm notations. It defines an algorithm as a list of computational steps to transform input into output. It provides examples of algorithms for a child's morning routine and calculating the average of 5 math scores. It distinguishes algorithms from programs, noting algorithms are implemented in programs. It also describes different algorithm notations including natural language, flowcharts, and pseudocode. Pseudocode is similar to code but has no standard syntax. Flowcharts use symbols to visually depict a program's flow.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to

Algorithm

Mira Chandra Kirana


Polibatam-BioTech
Content

• What is Algorithm
• Algorithm vs Program
• Notation of Algorithm
What is Algorithm?
• a procedure that uses some values or set of values as
input to produce an output
• a list of computational steps that transform the input
into the output.
Simple example of an algorithm based on
children weekday morning routine :

1. Start What about you?


2. Get up I convinced that you
3. Shower are capable to make
your own simple
4. Get dressed algorithm.
5. Eat breakfast Give simple example
of algorithm base on
6. If weather is “sunny”
your daily activity!
7. Walk to the school
8. else
9. Go to the school with parents
10. Stop
Algorithm vs program

• The algorithm  process and the programming 


implementation  specific to coding language,
environment, and how the rest of the app works.
• Programming  taking an algorithm and encoding it into
 a programming language  in order to be executed by
a computer
• Algorithm will be translated to be source code.
• Source code  programming language  commonly in High
level Programming, such C/C++, Java, etc

Source code

Translation

Algorithm
• Two kinds of programs process high-level languages into
low-level languages: interpreters and compilers.

Source code
output
Interpreter

output

Executor
Object code

Compiler
Source code
Notation of Algorithm

Human Language
• The most simple ways
• Descriptive and usually use the verbs

Flowchart
• Using symbols.
• Visually describing the flow of program instructions

Pseudocode
• Similar to code
• Doesn’t have any standard  pseudo
Flowchart
(watch the video “what is flowchart”)
Example

How to count the average of five students Math


values?

v1 v2 v3 v4 v5
Human Language

Math average Program


Find the average of the Math values by plugging in Math values of
five students

Declaration:
value1, value2, value3, value4, value5, average : real numbers

Algorithm:
1. Enter value1, value2, value3, value4 and value5
2. Calculate the average equal to sum of value1 to value5 then divide
by five
3. Show average calculation results
Pseudocode
Math average Program
{Find the average of the Math values by plugging in Math values of five
students}

Declaration:
value1, value2, value3, value4, value5, average : real

Algorithm:
Input (value1)
input (value2)
input (value3)
input (value4)
Input (value5)
average = (value1 + value2 + value3 + value4 + value5) / 5
Output (average)
What about flowchart?
Individual Task

• Create an algorithm for calculating the area and


circumference of the rectangle. Create 3 types of algorithm
notation.

Write your task in word named T1_NIM, upload in learning


before 28 August 2021 at 23.59 WIB

Common questions

Powered by AI

An algorithm is the process or set of rules to be followed in problem-solving operations, usually in a step-by-step format, whereas a program is the implementation of that algorithm in a specific coding language designed to be executed by a computer. This difference impacts implementation as algorithms are language-independent and conceptual, while programs are dependent on specific programming languages like C/C++, Java, etc., and include detailed coding specific to these languages. Algorithms are translated into source code, which is then processed into a low-level language by either an interpreter or a compiler .

The calculation of the average math score of five students involves defining the problem, listing inputs, and executing the computation as an algorithm. The steps include: declaring variables for each student's score and the average, inputting the five individual scores, summing the scores, dividing by five to find the average, and then outputting this average. This method showcases how algorithms formalize a sequence of operations to arrive at a solution .

Algorithmic notation influences both the design and communication of computational procedures by providing formal and structured ways to represent algorithms. Notations like pseudocode and flowcharts bridge the gap between human understanding and machine execution, allowing for clear communication of complex processes. Descriptive human language, flowcharts, and pseudocode each offer a method to visualize and detail the steps of an algorithm without ambiguity, thus serving different needs based on the audience's familiarity with technical language .

Interpreters and compilers are essential in processing high-level programming languages into executable machine code. An interpreter translates high-level source code into machine code line-by-line, which can make the program slower but allows for immediate execution and easier debugging. On the other hand, a compiler translates the entire program into machine code before execution, resulting in faster runtime but requiring the entire program to be free from syntax errors before execution. These distinctions affect program execution in terms of speed, efficiency, and flexibility .

Pseudocode aids in the development and testing of algorithms by providing a simplified version of programming concepts without the complexities of syntactical rules. It allows developers to focus on the logic of the algorithm, making it easier to identify logical errors before implementation in a programming language. Since pseudocode is similar to human language, it facilitates communication among team members and serves as a useful intermediate step in translating an idea into a formal program .

The children's weekday routine exemplifies fundamental characteristics of an algorithm by outlining a step-by-step procedure (start, get up, shower, etc.) designed to solve a problem (getting the child to school). The routine takes inputs (current activities and weather conditions) and provides outputs (method of getting to school), illustrating the transformation process inherent in algorithms. This logical sequence and unambiguous steps demonstrate how even simple daily activities can be structured algorithmically .

Distinguishing between high-level and low-level languages is crucial because it affects how programmers interact with the computer hardware and determine the ease and efficiency of writing code. High-level languages, like C/C++ and Java, are more abstract and closer to human language, making them easier to learn, write, and understand, while low-level languages like assembly are closer to machine code and offer more direct control over hardware but are more complex to code. This distinction impacts program portability, execution speed, and the type of applications best suited for each language .

Designing an algorithm for calculating the area and circumference of a rectangle can deepen one's programming skills by requiring the application of mathematical formulas within an algorithmic framework. This task involves identifying the necessary inputs (length and width), applying accurate mathematical operations, and structuring these processes in a clear, logical sequence. By exploring different notations like pseudocode, flowcharts, or human language descriptions, learners gain insight into various methodical approaches to problem-solving, enhancing their adaptability and proficiency in creating versatile algorithmic solutions .

Creating personalized algorithms based on daily activities can enhance educational benefits by fostering critical thinking and problem-solving skills. It encourages students to break down tasks into systematic steps, improves their understanding of algorithmic concepts, and reinforces the importance of logical sequencing. By designing algorithms for familiar contexts, learners can better grasp abstract computational concepts and apply them to practical, everyday situations .

Flowcharts enhance understanding by providing a visual representation of each step in an algorithm, which is beneficial for grasping complex logic quickly. Unlike textual descriptions or pseudocode, flowcharts use standardized symbols to depict decisions, processes, inputs, and outputs, thereby making the flow of execution clear and intuitive. This visual clarity helps in identifying errors and refining processes as stakeholders can more easily follow the logical progression .

You might also like