Data Structures Lab
Arrays, Iterative and Recursive Methods
Course: [Link] (Computer Science & Engineering)
Year: First Year
Lab Topic: Arrays, Iterative Methods, Recursive Methods
Lab Exercises
Q1 (Easy – Basic Array Handling)
Write a program to:
1. Read n elements into an integer array.
2. Display the elements using an iterative method.
3. Print the sum and average of the array elements.
Q2 (Easy–Moderate – Iterative Processing)
Write a program to:
1. Find the largest and smallest element in an array using an iterative approach.
2. Count the number of even and odd elements present in the array.
Q3 (Moderate – Recursion with Arrays)
Write a recursive function to:
1. Calculate the sum of elements of an array.
2. Count the number of elements in the array that are greater than a given value k.
Q4 (Moderate–High – Iterative vs Recursive Comparison)
Write two separate programs (or functions) to perform linear search on an array:
1. Using an iterative method.
2. Using a recursive method.
For both implementations:
- Display whether the element is found or not.
- Compare the number of function calls/iterations for a given input.
Q5 (High – Decision & Application Based)
Write a program to:
1. Reverse an array using an iterative approach.
2. Reverse the same array using a recursive approach.
3. Display the array after each operation.