1.2.1 Writing algorithms using:

Cards (92)

  • What is an algorithm designed to accomplish?
    Solve a specific problem
  • One step in making toast according to the given algorithm is to plug in the toaster.

    True
  • What is the purpose of decomposition in algorithm design?
    Break down complex problems
  • Decomposing problems makes algorithms more efficient and easier to understand.
    True
  • A sequence structure ensures that steps are executed in a specific order.
  • Why is decomposition an essential skill in algorithm design?
    Tackle problems step-by-step
  • A sequence structure executes steps one after the other in the order they appear.
    True
  • Selection structures in algorithm design allow for decision-making.
  • The if-else structure executes a different set of instructions depending on whether the condition is true or false.

    True
  • The if structure checks a condition and executes instructions if the condition is true
  • What keyword is used in the if structure to check a condition?
    if
  • Arrange the following steps in the correct order to determine the larger of two numbers using an if-else structure.
    1️⃣ Check if num1 > num2
    2️⃣ If true, print "The larger number is " + num1
    3️⃣ Else, print "The larger number is " + num2
  • A for loop is used when the number of iterations is known in advance
  • What are the three characteristics of an algorithm?
    Clear, ordered, and sequenced
  • What is the process of breaking down a complex problem into smaller parts called?
    Decomposition
  • A sequence structure ensures that steps are executed in the order they appear in the algorithm.

    True
  • What is the most basic type of control structure in algorithm design?
    Sequence structure
  • Steps in a sequence structure to calculate the area of a rectangle
    1️⃣ Input the length of the rectangle
    2️⃣ Input the width of the rectangle
    3️⃣ Calculate the area by multiplying length and width
    4️⃣ Display the calculated area
  • The 'if' structure executes instructions only if the condition is true.

    True
  • Match the selection structure with its definition:
    if ↔️ Executes instructions if condition is true
    if-else ↔️ Executes one set of instructions if condition is true, another if condition is false
  • A 'for' loop is used when the number of iterations is known in advance
  • Steps in a 'for' loop
    1️⃣ Initialization
    2️⃣ Condition
    3️⃣ Execution
    4️⃣ Increment
  • Functions reduce code redundancy and improve readability.
    True
  • Using functions allows code to be reused multiple times
  • Good comments should explain the purpose of the algorithm, its logic flow, and key variables.

    True
  • What is the process called that involves breaking down a complex problem into smaller sub-tasks?
    Decomposition
  • The 'if-else' structure executes a different set of instructions based on whether a condition is true or false.

    True
  • When is a 'for loop' typically used in algorithms?
    Number of iterations is known
  • Match the loop type with its description:
    for loop ↔️ Number of iterations is known
    while loop ↔️ Number of iterations is unknown
  • An algorithm can be compared to a recipe for making toast
  • An algorithm is a set of clear, ordered instructions
  • Steps in decomposing a problem
    1️⃣ Identify the overall goal
    2️⃣ Break down the goal into sub-tasks
    3️⃣ Arrange sub-tasks in logical order
    4️⃣ Repeat breakdown for complex sub-tasks
  • A sequence structure ensures steps are executed in sequential
  • What are the most common selection structures in algorithm design?
    If and if-else
  • What are iteration structures also known as in algorithm design?
    Loops
  • Loops reduce code duplication and automate repetitive tasks.

    True
  • A function has a unique identifier called its name
  • What is one key aspect to comment in an algorithm?
    Purpose of the algorithm
  • One benefit of commenting is improved readability
  • Match the purpose of commenting with its corresponding benefit:
    Purpose of the algorithm ↔️ Improved Readability
    Logic flow ↔️ Enhanced Maintainability
    Key variables and constants ↔️ Better Collaboration
    Assumptions and limitations ↔️ Knowledge Transfer