Algorithms Quiz

1. What is an Algorithm?

2. Which of the following is a real-life example of an algorithm?

3. Why are algorithms important?

4. Why is efficiency important in algorithms?

5. Which flowchart symbol is used for decision-making?

6. Why is pseudocode useful?

7. Which strategy involves solving a simpler version of the problem first?

8. Which statement is correct about variables?

9. Which pseudocode correctly reads a number and prints its square?

10. What will this pseudocode print if x = 0?

If x > 0 then
   Print "Positive"
Else If x < 0 then
   Print "Negative"
Else
   Print "Zero"

11. What is the output of this pseudocode when y = 12?

If y > 10 then
   If y < 20 then
      Print "Between 10 and 20"
   End If
End If
                

12. Which loop will always execute at least once?

13. What does this pseudocode print?

For i = 1 to 3
   Print i
End For
                

14. Which type of loop is best when the number of repetitions is unknown?

15. Which of the following problems is typically solved using recursion?

16. Why is a base case necessary in recursion?

17. Which data structure follows First In, First Out (FIFO)?

18. If an array has 5 elements, what are the valid index positions (0-based indexing)?

19. What is the time complexity of this algorithm?

For i = 1 to n
   Print "Hello"
End For
                

20. If Algorithm A runs in O(n) and Algorithm B runs in O(n²), which one is more efficient for large n?