0% found this document useful (0 votes)
15 views13 pages

Itcsp 01

Uploaded by

Sincat
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)
15 views13 pages

Itcsp 01

Uploaded by

Sincat
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
You are on page 1/ 13

ADAM MICKIEWICZ UNIVERSITY IN POZNAŃ

Faculty of English

Introduction to Computer
Science and Programming
class 01

Robert Dyzman, M.Sc.Eng.

wa.amu.edu.pl
ORGANIZATIONAL ISSUES

[email protected]
Syllabus
Start your computers
Stay where you are
Communication (Teams)
WHAT WILL WE DO IN THIS
COURSE ?

• Fundamentals of programming (Python)


• You will learn computational mode of thinking
• You will try make computers do what you want them to
do
OUR GOAL

• You will learn basics of programming


 Python 3
 C++ (class 14, fundamentals)
• You will get acquainted with iteration (iterative alorithms)
• You will learn computational problem-solving techniques
TERMINOLOGY

• COMPUTER SCIENCE (acc. Wikipedia) is the study of


algorythmic processes, computational machines and
computation itself… Algorithms and data structures
have been called the heart of computer science.
TERMINOLOGY

• ALGHORITM (acc. Wikipedia) is a finite sequence of


well-defined, computer-implementable instructions,
typically to solve a class of specific problems or to
perform a computation.
 …..
 …..
 …..
ALGORITHM

What does it mean


???
ALGORITHM

• ALGORITHM IS A RECIPE
Getting a dinner
1. Open fridge
2. Take out leftovers
3. Test -> Smell okay ?
4. If yes -> Eat them -> STOP
5. If no - > Put them back in fridge -> Order takeout
FLOWCHARTS

Open fridge

Take out
leftovers
Flow of control
Yes Smell No
OK ?

Eat them Put them back


in fridge

Order takeout
ALGORITHM

• What is a recipe ?
1. Sequence of simple steps;
2. Flow of control, test to specify when
each step is executed
3. Include tests for deciding when the
process is complete (STOP process |
EXIT process)
BRUTE FORCE ALGORITHMS

• it goes through all possible choices until a solution is


found. Brute force algorithms are simple but slow.
• e.g.,you have a 4-digit PIN. The digits to be chosen from
0-9. The brute force will be trying all possible
combinations one by one like 0001, 0002, 0003, 0004,
0005, and so on until we get the right PIN
• This is also called Exhaustive Enumeration.
Task:
How many tries you need to guess the PIN (4-digit)?
The answer is permutation with repetition

11
NUMERICAL EXAMPLE (and
simultaneously iterative algorithm)

• Heron of Alexandria was first to document a way to


compute the square root of a number
1. Start with a guess „g”
2. If g*g is close enough to x, stop and say that g is the
answer.
3. Otherwise create a new guess by averaging „g” and
„x/g” that is (g+x/g)/2
4. Use the new guess, again call it „g” and repeat until g*g
is close enough to x
NUMERICAL EXAMPLE

Let’s calculate square root (25)


x = 25
g g*g x/g (g+x/g)/2
3 9 8.3 5.65
5.65 31.9225 4.4248 5.0374
5.0374 25.3754 4.9629 5,00015

5.00015 is close enough !!!

You might also like