MENU

Problem Analysis and Algorithm Basics

55 viewsG11-01. Programming
0

  1. What are the inputs and outputs in a program that calculates the area of a rectangle?

  2. List two possible ways to calculate the average of three numbers in a program.

  3. For a program that determines the cheapest product among three, identify the inputs, outputs, and two possible process steps.

  4. How would you optimize the solution space for a program sorting a list of numbers?

  5. Why are algorithms important in programming?

Spread the love
Ruwan Suraweera Changed status to publish May 26, 2025
0

Answers and Descriptions

  1. Answer: Inputs: Length and width of the rectangle. Output: Area of the rectangle.
    Description: Identifying inputs and outputs is crucial for problem analysis. For a rectangle area calculation, the program needs length and width as inputs, and it computes the area (length ร— width) as the output, defining the problemโ€™s scope.

  2. Answer: 1. Add the three numbers and divide by 3. 2. Store the numbers in an array, sum the array elements, and divide by the array length.
    Description: Exploring multiple approaches to solve a problem helps understand the solution space. The first method is straightforward, while the array approach is scalable for more numbers, encouraging flexible thinking.

  3. Answer: Inputs: Prices of three products. Output: Name and price of the cheapest product. Process Steps: 1. Compare prices using if-else statements. 2. Store prices in an array and find the minimum.
    Description: This advanced question requires analyzing a multi-variable problem. Identifying inputs and outputs sets the foundation, while exploring process steps encourages students to consider different algorithmic strategies.

  4. Answer: Use a sorting algorithm like QuickSort for efficiency, or Bubble Sort for simplicity if the list is small.
    Description: Optimizing the solution space involves selecting the best algorithm. QuickSort (O(n log n)) is efficient for large lists, while Bubble Sort (O(nยฒ)) is simpler for small lists, balancing complexity and performance.

  5. Answer: Algorithms provide a step-by-step procedure to solve a problem efficiently and consistently.
    Description: Algorithms are essential for systematic problem-solving in programming. They break down complex tasks into manageable steps, ensuring reliability and reusability of code.

Spread the love
Ruwan Suraweera Changed status to publish May 26, 2025
Write your answer.