Khadija Ilyas Week 5LAB Recursion Implementation
Week
1. Infix to Postfix Expression:
Scenario:
You are working on a calculator application that needs to evaluate mathematical expressions. The input
expressions are provided in infix notation, like A + B * C - D. Write a function to convert these infix
expressions into postfix notation (also known as Reverse Polish Notation) so that they can be easily evaluated.
Implement error handling for invalid expressions.
2. Recursion: Power Calculation
Scenario:
You need to build a scientific calculator that allows users to calculate the power of a number. For instance, if a
user inputs 2 and 3, the program should compute 2^3 using recursion. Write a function that takes two parameters
(the base and the exponent) and returns the result using recursive calls.
3. Recursion: Sum of Previous Values
Scenario:
Design a program that prompts the user to enter a positive integer n. The program should then return the sum of
all previous integers from 1 to n (i.e., 1 + 2 + ... + n). Implement this functionality using recursion, and
ensure that the program handles invalid inputs, like negative numbers or non-integer values.
4. Recursion: Sum of Array Elements
Scenario:
Create a program that accepts an array of integers from the user. The program should compute the sum of all the
elements in the array using recursion. For example, for the array [1, 2, 3, 4], the output should be 10. Include
input validation to ensure the user enters a valid integer array.
5. Recursion: Find Maximum and Minimum in Array
Scenario:
You are tasked with implementing a function that takes an array of integers provided by the user and determines
both the maximum and minimum values within that array using recursion. For example, given the array [4, 2,
9, 1, 5], the program should output Maximum: 9 and Minimum: 1. Ensure the program validates the input to
handle cases where the user might input invalid data types.