-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecursion question - Easy.txt
36 lines (26 loc) · 1.86 KB
/
Recursion question - Easy.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1- Question: Find Maximum Element in an Array Using Recursion
Write a recursive function to find the maximum element in an array of integers.
int findMax(int arr[], int n);
2- Question: Reverse an Array Using Recursion
Write a recursive function to reverse an array of integers.
void reverseArray(int arr[], int start, int end);
3- Question: Check if an Array is Sorted Using Recursion
Write a recursive function to check if an array of integers is sorted in non-decreasing order.
bool isSorted(int arr[], int n);
4- Question: Merge Sort Using Recursion
Implement merge sort algorithm using recursion to sort an array of integers.
void mergeSort(int arr[], int left, int right);
5- Question: Generate All Subsets of an Array Using Recursion
Write a recursive function to generate all subsets of elements in an array.
void generateSubsets(int arr[], int index, vector<int>& subset);
6- Question: Check if Array Contains a Subset Sum Using Recursion
Write a recursive function to check if there exists any subset of elements in the array that adds up to a given sum.
bool subsetSumExists(int arr[], int n, int sum);
7- Question: Find All Permutations of Array Elements Using Recursion
Write a recursive function to generate all permutations of elements in an array.
void generatePermutations(int arr[], int start, int end);
8- Question: Find All Paths in a Maze (Matrix) Using Recursion
Given a matrix representing a maze where 1 represents a path and 0 represents a wall, write a recursive function to find all possible paths from the top-left corner to the bottom-right corner.
void findPathsInMaze(int maze[][N], int x, int y, int sol[][N]);
9- Question: Find All Connected Components in a Grid Using Recursion
Given a 2D grid of 0s and 1s where 1 represents a connected cell, write a recursive function to find all distinct connected components in the grid.