Algorithm Representation Tools
What does an oval symbol represent in a flowchart?
Convert the following pseudo code into a flowchart:
Optimize the following pseudo code to check if a number is prime:
Write pseudo code to assign a grade based on a score (90-100: A, 80-89: B, below 80: C).
When is a switch/case statement preferred over If-Else?
Answers and Descriptions
Answer: An oval symbol represents the start or end of a flowchart. Description: Flowcharts use standardized symbols to visualize algorithms. The oval marks the entry or exit point, clearly defining the algorithmโs boundaries.
Answer: Start (Oval) โ Input age (Parallelogram) โ Decision (Diamond: age >= 18?) โ Yes: Output "Eligible to vote" (Rectangle) โ No: Output "Not eligible" (Rectangle) โ End (Oval). Description: Converting pseudo code to a flowchart reinforces understanding of both tools. The flowchart visually represents the decision-making process for voting eligibility.
Answer:
Description: Optimizing pseudo code reduces iterations. Checking up to the square root of n and breaking when a divisor is found improves efficiency for prime number checks.
Answer:
Description: The If-Else-EndIf structure evaluates conditions to assign grades, demonstrating selection control structures for multi-condition logic.
Answer: Switch/case is preferred when a single variable is tested against multiple fixed values. Description: Switch/case simplifies code for checking a variable (e.g., day of the week) against constants, improving readability over multiple If-Else statements.