IAP-Lecture_1
AIU Faculty of Informatics and Communication Engineering
Introduction
Focus on studying the course: Introduction to Algorithms and Programming.
Course Topics and Schedule
Week 1: What are algorithms?
Week 2: What is pseudo code?
Week 3: Using if statements.
Week 4: Using while loop.
Week 5: Other loops.
Week 6: Nested loops.
Week 7: Using flowcharts.
Week 8: Midterm Exam (C++ programming).
Week 9: Variables and data types.
Week 10: Input / Output.
Week 11: Selection using if..else.
Week 12: Nested if and switch.
Week 13: Using while & do while loops.
Week 14: Using for loop.
Week 15: Nested loops.
Assessment Distribution
Midterm exam: 20%
Quizzes and homework: 5%
Practical activity: 25%
Final exam: 50%
Understanding Algorithms
Definition: An algorithm is a sequence of steps to solve a specific problem, applicable in computer science and cooking.
Historical Context: The term "algorithm" is derived from Algorithmi, a Persian mathematician from the 9th century.
Algorithm Example: Scrambled Egg
Basic Steps:
Beat one egg.
Add salt and pepper.
Fry the egg.
Place the egg on a plate.
Detailed Steps:
Get one egg from the fridge.
Break it into a bowl.
Add 1/4 tsp of salt and a pinch of pepper.
Beat until homogeneous.
Fry in 10g of butter/oil.
Stir regularly until cooked, then serve.
Properties of Good Algorithms:
Complete (no necessary steps omitted).
Precise (accurate results).
Unambiguous (clear instructions).
Cooking Analogy to Algorithms
Comparison: The computer processes data like a kitchen processes food.
Variables as Dishes: Dishes (variables) hold raw, unprocessed food (data).
Algorithm to Calculate Area of a Circle
Steps:
Input radius from user.
Calculate area using formula (Area = π * Radius²).
Output the area.
Variables needed: Radius, Area (both are real numbers).
Algorithm to Calculate Area and Circumference of a Rectangle
Variables: Length, Width, Area, Circumference (all real numbers).
Steps:
Input Length and Width.
Calculate Area (Length * Width).
Calculate Circumference (2 * (Length + Width)).
Output both results.
Key Elements of an Algorithm
Major Structures:
Sequences: Ordered steps (e.g., cooking directions).
Branching: Decision points (if statements).
Loops: Repeating actions until a condition is met.
Homework Assignment
Write an algorithm to calculate the area and circumference of a square, considering a circle inscribed within it. Modify it to calculate the difference in area and circumference between the square and the circle.