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:

    1. Beat one egg.

    2. Add salt and pepper.

    3. Fry the egg.

    4. Place the egg on a plate.

  • Detailed Steps:

    1. Get one egg from the fridge.

    2. Break it into a bowl.

    3. Add 1/4 tsp of salt and a pinch of pepper.

    4. Beat until homogeneous.

    5. Fry in 10g of butter/oil.

    6. 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:

    1. Input radius from user.

    2. Calculate area using formula (Area = π * Radius²).

    3. 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:

    1. Input Length and Width.

    2. Calculate Area (Length * Width).

    3. Calculate Circumference (2 * (Length + Width)).

    4. 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.