0% found this document useful (0 votes)
41 views

Cs Lecture 1

Introduction to cs

Uploaded by

adelgomaa2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Cs Lecture 1

Introduction to cs

Uploaded by

adelgomaa2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 102

CS 1– Introduction to Computer Science

Lecture 1:
The Definition of Computer Science
Informal and Formal Definitions of Algorithms

Prof. Dr. Slim Abdennadher,Prof. Dr. Ansgar Meroth,


Dr.Dr. Nada Sharaf
Muhammad Hataba
[email protected]
[email protected]

The German International University

Nada Sharaf (GIU - Engineering) CS 1 1 / 36


Overview

TextBooks

Computer Science: an Overview: J. Glenn Brookshear


Greg Perry, Dean Miller : C Programming Absolute Beginner’s
Guide 3rd Edition
Jeff Szuhay: Learn C Programming: A beginner’s guide to
learning C programming the easy and disciplined way
Bradley Jones, Peter Aitken, Dean Miller:C Programming in One
Hour a Day, Sams Teach Yourself 7th Edition
M K Gooroochurn: Introduction to Digital Logic & Boolean Algebra
David Harris, Sarah L. Harris: Digital Design and Computer
Architecture 2nd Edition

Nada Sharaf (GIU - Engineering) CS 1 3 / 36


Overview

Suggested IDEs

CodeBlocks (Available through


S:\Informatics and Computer Science\Software)
Online IDEs like repl.it and cpp.sh

Nada Sharaf (GIU - Engineering) CS 1 4 / 36


Overview

Acknowledgment

We would like to thank Assoc. Prof. Dr. Georg Jung for his efforts in
providing the different forms of the presented material.

Nada Sharaf (GIU - Engineering) CS 1 5 / 36


Overview Computational Thinking

Main Objective of the Course: Computational Thinking

Nada Sharaf (GIU - Engineering) CS 1 6 / 36


Overview Computational Thinking

What is Computational Thinking?

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What is Computational Thinking?

Computational thinking involves

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What is Computational Thinking?

Computational thinking involves


Solving problems

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What is Computational Thinking?

Computational thinking involves


Solving problems
Designing systems

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What is Computational Thinking?

Computational thinking involves


Solving problems
Designing systems
Understanding human behavior by drawing on the concepts
fundamental to computer science.

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What is Computational Thinking?

Computational thinking involves


Solving problems
Designing systems
Understanding human behavior by drawing on the concepts
fundamental to computer science.
It includes a range of mental tools that reflect the breadth of the
field of computer science

Nada Sharaf (GIU - Engineering) CS 1 7 / 36


Overview Computational Thinking

What are the elements of Computational Thinking?

Logical Thinking
Algorithmic Thinking
Efficient Solutions
Scientific Thinking
Innovative Thinking

Nada Sharaf (GIU - Engineering) CS 1 8 / 36


Overview Contents and objectives

Overview

What is CS1?

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Overview

What is CS1?

Introduction to Computer Science principles

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Overview

What is CS1?

Introduction to Computer Science principles


A course with no prerequisites: no background in computer
science needed

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Overview

What is CS1?

Introduction to Computer Science principles


A course with no prerequisites: no background in computer
science needed
A sort of but not a comprehensive programming course

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Overview

What is CS1?

Introduction to Computer Science principles


A course with no prerequisites: no background in computer
science needed
A sort of but not a comprehensive programming course

What isn’t CS1?

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Overview

What is CS1?

Introduction to Computer Science principles


A course with no prerequisites: no background in computer
science needed
A sort of but not a comprehensive programming course

What isn’t CS1?

A Computer literacy course

Nada Sharaf (GIU - Engineering) CS 1 9 / 36


Overview Contents and objectives

Why should you learn CS1?

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Why should you learn CS1?

To use computers for problem solving

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Why should you learn CS1?

To use computers for problem solving


Acquire new skills that will allow you to create useful and
customized computer-based applications

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Why should you learn CS1?

To use computers for problem solving


Acquire new skills that will allow you to create useful and
customized computer-based applications
Improve your problem solving skills (clarity, precision, logic, . . . )

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Why should you learn CS1?

To use computers for problem solving


Acquire new skills that will allow you to create useful and
customized computer-based applications
Improve your problem solving skills (clarity, precision, logic, . . . )
It is in the curriculum because many courses build up on it

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Why should you learn CS1?

To use computers for problem solving


Acquire new skills that will allow you to create useful and
customized computer-based applications
Improve your problem solving skills (clarity, precision, logic, . . . )
It is in the curriculum because many courses build up on it
Acquire a useful vocabulary that will impress others in geeky
conversations

Nada Sharaf (GIU - Engineering) CS 1 10 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Demonstrate skills in problem solving


1 Express Problem solutions in the form of algorithms using C
2 Analyze algorithms in term of efficiency

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Demonstrate skills in problem solving


1 Express Problem solutions in the form of algorithms using C
2 Analyze algorithms in term of efficiency
Identify basic concepts in data representation and manipulation

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Demonstrate skills in problem solving


1 Express Problem solutions in the form of algorithms using C
2 Analyze algorithms in term of efficiency
Identify basic concepts in data representation and manipulation
Build simple computer circuits using Boolean Logic

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Demonstrate skills in problem solving


1 Express Problem solutions in the form of algorithms using C
2 Analyze algorithms in term of efficiency
Identify basic concepts in data representation and manipulation
Build simple computer circuits using Boolean Logic
Write simple C-Programs

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Course Objectives

At the end of this course, you should be able to:

Demonstrate skills in problem solving


1 Express Problem solutions in the form of algorithms using C
2 Analyze algorithms in term of efficiency
Identify basic concepts in data representation and manipulation
Build simple computer circuits using Boolean Logic
Write simple C-Programs
Identify basic issues related to the software systems

Nada Sharaf (GIU - Engineering) CS 1 11 / 36


Overview Contents and objectives

Applications
Uses of computing machinery

Engineering:
Simulation models of the physical world
Signal and image processing
Graphical tools (CAD)
Control : Cars, Robots, Machinery, Power systems
Nada Sharaf (GIU - Engineering) CS 1 12 / 36
Overview Administration and organization

Organization of the Course

Lectures: 2 hours per week


Tutorials and Labs: You have to attend!
Tutorials: 2 hours per week
Labs: 2 hours per week
Evaluation: Grade is based on
a midterm exam
a final exam
3 in-class quizzes
In-class assignments and lab tests

Nada Sharaf (GIU - Engineering) CS 1 13 / 36


Overview Administration and organization

Tentative grading

The tentative overall weighting for your grade

Assignments (Theoretical): 10%


Assignments (Practical): 10%
Quizzes (Theoretical): 15%
Mid-Term Exam (Theoretical): 25%
Final Exam (Theoretical): 40%

Nada Sharaf (GIU - Engineering) CS 1 14 / 36


Overview Survival guide

Survival guide

Tell me and I will forget;


show me and I may remember;
involve me and I will understand.

Nada Sharaf (GIU - Engineering) CS 1 15 / 36


Overview Survival guide

Survival guide

Tell me and I will forget;


show me and I may remember;
involve me and I will understand.
Keep up with the course material
Attend lectures, tutorials, and labs
Participate in the discussions (be active)
Solve the assignments and understand the model answers
provided

Nada Sharaf (GIU - Engineering) CS 1 15 / 36


Overview Survival guide

Survival guide

Tell me and I will forget;


show me and I may remember;
involve me and I will understand.
Keep up with the course material
Attend lectures, tutorials, and labs
Participate in the discussions (be active)
Solve the assignments and understand the model answers
provided

WWW-page
Visit course home page regularly for announcements and
supplemental material

met.guc.edu.eg
Nada Sharaf (GIU - Engineering) CS 1 15 / 36
Overview Survival guide

Survival guide

Do not copy !!!

Nada Sharaf (GIU - Engineering) CS 1 16 / 36


Overview Survival guide

Survival guide

Keep in touch

Nada Sharaf (GIU - Engineering) CS 1 17 / 36


Overview Survival guide

Survival guide

Keep in touch

E-mail
Office hours

Nada Sharaf (GIU - Engineering) CS 1 17 / 36


Overview Survival guide

Survival guide

Keep in touch

E-mail
Office hours

Ask for help when you need it

Nada Sharaf (GIU - Engineering) CS 1 17 / 36


Overview Survival guide

Survival guide

Keep in touch

E-mail
Office hours

Ask for help when you need it

Professor
TAs

Nada Sharaf (GIU - Engineering) CS 1 17 / 36


Overview Course structure

Structure of this course

The course has the following structure

1 Algorithmic Foundations
2 Software World and
Languages
3 Hardware World
4 Applications

Nada Sharaf (GIU - Engineering) CS 1 18 / 36


Overview Course structure

Structure of this course

The course has the following structure

1 Algorithmic Foundations
2 Software World and
Languages
3 Hardware World
4 Applications

End of Administrative Stuff

Nada Sharaf (GIU - Engineering) CS 1 18 / 36


Introduction What is computer science

What is Computer Science?

Nada Sharaf (GIU - Engineering) CS 1 19 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Computer Science is NOT restricted to

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Computer Science is NOT restricted to


The study of computers: Computers are tools used in the field

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Computer Science is NOT restricted to


The study of computers: Computers are tools used in the field
The study of how to write computer programs: Programming is an
important part of computer science, but primarily as a a tool to
implement ideas.

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Computer Science is NOT restricted to


The study of computers: Computers are tools used in the field
The study of how to write computer programs: Programming is an
important part of computer science, but primarily as a a tool to
implement ideas.
The study of the uses and applications of computers and
software: This only provides competency in tool usage

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science not?

Or, more accurately, what is it not only

Computer Science is NOT restricted to


The study of computers: Computers are tools used in the field
The study of how to write computer programs: Programming is an
important part of computer science, but primarily as a a tool to
implement ideas.
The study of the uses and applications of computers and
software: This only provides competency in tool usage

So, what is Computer Science?

Nada Sharaf (GIU - Engineering) CS 1 20 / 36


Introduction What is computer science

What is Computer Science then?

Computer Science is the study of algorithms, including

Their formal and mathematical properties


Their hardware realizations
Their linguistic realizations
Their applications

Nada Sharaf (GIU - Engineering) CS 1 21 / 36


Introduction What is computer science

What is Computer Science then?

Computer Science is the study of algorithms, including

Their formal and mathematical properties


Their hardware realizations
Their linguistic realizations
Their applications

This definition may seem a little puzzling, until we learn a bit more
about algorithms.

Nada Sharaf (GIU - Engineering) CS 1 21 / 36


Algorithms What is an algorithm

OK, but What is an Algorithm?

Nada Sharaf (GIU - Engineering) CS 1 22 / 36


Algorithms What is an algorithm

OK, but What is an Algorithm?

Consider the following problem: We want to wash our hair twice.

Nada Sharaf (GIU - Engineering) CS 1 22 / 36


Algorithms What is an algorithm

OK, but What is an Algorithm?

Consider the following problem: We want to wash our hair twice.


Algorithm
1 Wet your hair
2 Lather your hair
3 Rinse your hair
4 Lather your hair
5 Rinse your hair
6 Stop, you have finished shampooing your hair

Nada Sharaf (GIU - Engineering) CS 1 22 / 36


Algorithms What is an algorithm

OK, but What is an Algorithm?

Consider the following problem: We want to wash our hair twice.


Algorithm
1 Wet your hair
2 Lather your hair
3 Rinse your hair
4 Lather your hair
5 Rinse your hair
6 Stop, you have finished shampooing your hair

Informally:

Nada Sharaf (GIU - Engineering) CS 1 22 / 36


Algorithms What is an algorithm

OK, but What is an Algorithm?

Consider the following problem: We want to wash our hair twice.


Algorithm
1 Wet your hair
2 Lather your hair
3 Rinse your hair
4 Lather your hair
5 Rinse your hair
6 Stop, you have finished shampooing your hair

Informally:
An algorithm is a step by step method for solving a problem

Nada Sharaf (GIU - Engineering) CS 1 22 / 36


Algorithms What is an algorithm

Algorithms

Algorithms are not necessarily limited to simple tasks.

We use algorithms all the time in our daily life, for example:
Cooking recipes
Directions how to get to places
Performing mathematical tasks such as:
Calculate the students’ GPA
Calculate the interests for invested money in a bank
...

Nada Sharaf (GIU - Engineering) CS 1 23 / 36


Algorithms What is an algorithm

An Algorithm for Calculating the area of a square

Nada Sharaf (GIU - Engineering) CS 1 24 / 36


Algorithms What is an algorithm

An Algorithm for Calculating the area of a square

Step 1. Get the value of Side

Nada Sharaf (GIU - Engineering) CS 1 24 / 36


Algorithms What is an algorithm

An Algorithm for Calculating the area of a square

Step 1. Get the value of Side


Step 2. Area = Side × Side

Nada Sharaf (GIU - Engineering) CS 1 24 / 36


Algorithms What is an algorithm

An Algorithm for Calculating the area of a square

Step 1. Get the value of Side


Step 2. Area = Side × Side
Step 3. print the value of Area

Nada Sharaf (GIU - Engineering) CS 1 24 / 36


Algorithms Purpose of an algorithm

Why is this important?

Nada Sharaf (GIU - Engineering) CS 1 25 / 36


Algorithms Purpose of an algorithm

Why is this important?

If we can specify an algorithm to solve a problem, then we can


automate its solution.

Nada Sharaf (GIU - Engineering) CS 1 25 / 36


Algorithms Purpose of an algorithm

Why is this important?

If we can specify an algorithm to solve a problem, then we can


automate its solution.

Definition (Computing agent)


A computing agent is an entity capable of performing the steps
described in the algorithm, that is, execute the algorithm

Nada Sharaf (GIU - Engineering) CS 1 25 / 36


Algorithms Purpose of an algorithm

Why is this important?

If we can specify an algorithm to solve a problem, then we can


automate its solution.

Definition (Computing agent)


A computing agent is an entity capable of performing the steps
described in the algorithm, that is, execute the algorithm

This could be
a person
a robot
a living cell (of an organism or a bacteria)
a computer

Nada Sharaf (GIU - Engineering) CS 1 25 / 36


Algorithms Purpose of an algorithm

Why is this important?

If we can specify an algorithm to solve a problem, then we can


automate its solution.

Definition (Computing agent)


A computing agent is an entity capable of performing the steps
described in the algorithm, that is, execute the algorithm

This could be
a person
a robot
a living cell (of an organism or a bacteria)
a computer

In our case, typically a computer.


Nada Sharaf (GIU - Engineering) CS 1 25 / 36
Algorithms Purpose of an algorithm

Why use a computer?

Nada Sharaf (GIU - Engineering) CS 1 26 / 36


Algorithms Purpose of an algorithm

Why use a computer?

Computers are fast: they can perform operations without errors at


speed unattainable by human beings.

Nada Sharaf (GIU - Engineering) CS 1 26 / 36


Algorithms Purpose of an algorithm

Why use a computer?

Computers are fast: they can perform operations without errors at


speed unattainable by human beings.
They can store very large amount of information: Human beings
have a difficulty managing and keeping track of a large number of
objects.

Nada Sharaf (GIU - Engineering) CS 1 26 / 36


Algorithms Purpose of an algorithm

Why use a computer?

Computers are fast: they can perform operations without errors at


speed unattainable by human beings.
They can store very large amount of information: Human beings
have a difficulty managing and keeping track of a large number of
objects.
They are not task specific: they can be programmed to perform
different tasks. Most other tools can do only one thing.

Nada Sharaf (GIU - Engineering) CS 1 26 / 36


Algorithms Purpose of an algorithm

Why use a computer?

Computers are fast: they can perform operations without errors at


speed unattainable by human beings.
They can store very large amount of information: Human beings
have a difficulty managing and keeping track of a large number of
objects.
They are not task specific: they can be programmed to perform
different tasks. Most other tools can do only one thing.
Their tasks can be automated: computers are excellent at
performing the same task over and over again on similar pieces of
data (i. e., preparing payment bills for every mobile phone user)

Nada Sharaf (GIU - Engineering) CS 1 26 / 36


Algorithms Purpose of an algorithm

Is this a computer?

Nada Sharaf (GIU - Engineering) CS 1 27 / 36


Algorithms Purpose of an algorithm

Are these computers?

Nada Sharaf (GIU - Engineering) CS 1 28 / 36


Algorithms Purpose of an algorithm

How many computers run in a car?

Nada Sharaf (GIU - Engineering) CS 1 29 / 36


Algorithms Purpose of an algorithm

How many computers run in a car?

Nada Sharaf (GIU - Engineering) CS 1 30 / 36


Algorithms Purpose of an algorithm

Is this a computer?

At least, it helps computing

Nada Sharaf (GIU - Engineering) CS 1 31 / 36


Algorithms Purpose of an algorithm

Is this a computer?

At least, it helps computing


It is rather a storage

Nada Sharaf (GIU - Engineering) CS 1 31 / 36


Algorithms Purpose of an algorithm

Is this a computer?

At least, it helps computing


It is rather a storage
The algorithm and the control flow go
manually

Nada Sharaf (GIU - Engineering) CS 1 31 / 36


Algorithms Purpose of an algorithm

Is this a computer?

At least, it helps computing


It is rather a storage
The algorithm and the control flow go
manually
So, it is at least a part of a computer

Nada Sharaf (GIU - Engineering) CS 1 31 / 36


Algorithms Purpose of an algorithm

Definition of Computer Science

Computer Science is the study of algorithms, including

Their formal and mathematical properties

Their hardware realizations

Their linguistic realizations

Their applications

Nada Sharaf (GIU - Engineering) CS 1 32 / 36


Algorithms Purpose of an algorithm

Definition of Computer Science

Computer Science is the study of algorithms, including

Their formal and mathematical properties


How to design algorithms to solve a wide range of problems
How to determine whether problems are (efficiently) computable
Studying the behavior of algorithms
Their hardware realizations

Their linguistic realizations

Their applications

Nada Sharaf (GIU - Engineering) CS 1 32 / 36


Algorithms Purpose of an algorithm

Definition of Computer Science

Computer Science is the study of algorithms, including

Their formal and mathematical properties


How to design algorithms to solve a wide range of problems
How to determine whether problems are (efficiently) computable
Studying the behavior of algorithms
Their hardware realizations
Designing and building computer systems
Their linguistic realizations

Their applications

Nada Sharaf (GIU - Engineering) CS 1 32 / 36


Algorithms Purpose of an algorithm

Definition of Computer Science

Computer Science is the study of algorithms, including

Their formal and mathematical properties


How to design algorithms to solve a wide range of problems
How to determine whether problems are (efficiently) computable
Studying the behavior of algorithms
Their hardware realizations
Designing and building computer systems
Their linguistic realizations
Designing programming languages and translating algorithms so
they can be executed by the hardware
Their applications

Nada Sharaf (GIU - Engineering) CS 1 32 / 36


Algorithms Purpose of an algorithm

Definition of Computer Science

Computer Science is the study of algorithms, including

Their formal and mathematical properties


How to design algorithms to solve a wide range of problems
How to determine whether problems are (efficiently) computable
Studying the behavior of algorithms
Their hardware realizations
Designing and building computer systems
Their linguistic realizations
Designing programming languages and translating algorithms so
they can be executed by the hardware
Their applications
Identifying important problems for computers
Designing software to solve these problems

Nada Sharaf (GIU - Engineering) CS 1 32 / 36


Algorithms Defining algorithm

What is an Algorithm?
Definition (Algorithm)
An algorithm is a well-ordered collection of unambiguous and
effectively computable operations that, when executed, produces a
result and halts in a finite amount of time.

Nada Sharaf (GIU - Engineering) CS 1 33 / 36


Algorithms Defining algorithm

What is an Algorithm?
Definition (Algorithm)
An algorithm is a well-ordered collection of unambiguous and
effectively computable operations that, when executed, produces a
result and halts in a finite amount of time.

An algorithm is well-ordered: each step of the algorithm is


executed in the order in which it is written, or else the order is
clearly stated.

Nada Sharaf (GIU - Engineering) CS 1 33 / 36


Algorithms Defining algorithm

What is an Algorithm?
Definition (Algorithm)
An algorithm is a well-ordered collection of unambiguous and
effectively computable operations that, when executed, produces a
result and halts in a finite amount of time.

An algorithm is well-ordered: each step of the algorithm is


executed in the order in which it is written, or else the order is
clearly stated.
An algorithm is unambiguous: The algorithm must be clearly
stated, in terms that the computing agent (e. g., computer)
understands.

Nada Sharaf (GIU - Engineering) CS 1 33 / 36


Algorithms Defining algorithm

What is an Algorithm?
Definition (Algorithm)
An algorithm is a well-ordered collection of unambiguous and
effectively computable operations that, when executed, produces a
result and halts in a finite amount of time.

An algorithm is well-ordered: each step of the algorithm is


executed in the order in which it is written, or else the order is
clearly stated.
An algorithm is unambiguous: The algorithm must be clearly
stated, in terms that the computing agent (e. g., computer)
understands.
An algorithm is effectively computable: It must be possible for the
computing agent to perform the operation and produce a result.

Nada Sharaf (GIU - Engineering) CS 1 33 / 36


Algorithms Defining algorithm

What is an Algorithm?
Definition (Algorithm)
An algorithm is a well-ordered collection of unambiguous and
effectively computable operations that, when executed, produces a
result and halts in a finite amount of time.

An algorithm is well-ordered: each step of the algorithm is


executed in the order in which it is written, or else the order is
clearly stated.
An algorithm is unambiguous: The algorithm must be clearly
stated, in terms that the computing agent (e. g., computer)
understands.
An algorithm is effectively computable: It must be possible for the
computing agent to perform the operation and produce a result.
An algorithm must halt in a finite amount of time: must even if it
would take centuries to finish.
Nada Sharaf (GIU - Engineering) CS 1 33 / 36
Algorithms History

Algorithm: Historic roots

Named after the Persian mathematician


Muhammad Ibn Musa Al-Khwarismi

780-850 in Khwarism (today Khiva), Usbekistan


developed a strategy for calculating heritage proportions for rich
Arabians with four woman using algebraic methods
His name was turned into Algorism and that evolved Algorithm
Nada Sharaf (GIU - Engineering) CS 1 34 / 36
Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36
60 36

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36
60 36
24 36

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36
60 36
24 36
24 12

Nada Sharaf (GIU - Engineering) CS 1 35 / 36


Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36
60 36
24 36
24 12
12 12
Nada Sharaf (GIU - Engineering) CS 1 35 / 36
Algorithms History

Algorithm: Historic occurrence


The oldest known algorithm is probably Euclid’s Algorithm to
determine the greatest common divisor (GCD) of two integers
(circa 365-275 BC)
Method: To find the GCD of two numbers, repeatedly replace the
larger by subtracting the smaller from it until the two numbers are
equal.
Only subtraction and comparison operations are needed.
Example (GCD of 132 and 168)
132 168
132 36
96 36
60 36 ⇒ So the GCD of 132 and 168 is 12.
24 36
24 12
12 12
Nada Sharaf (GIU - Engineering) CS 1 35 / 36
Algorithms Algorithms – notation

Representing algorithms

What language to use?


Expressive
Clear, precise and unambiguous
For example, we could use:
Natural Languages (e. g., English)
Formal Programming Languages (e.g. Java, C++)
Something close?

Nada Sharaf (GIU - Engineering) CS 1 36 / 36

You might also like