Given an array, generate all the possible subarrays of the given array using recursion.
Input : [1, 2, 3] Output : , [1, 2], , [1, 2, 3], [2, 3],  Input : [1, 2] Output : , [1, 2], 
We have discussed iterative program to generate all subarrays. In this post, recursive is discussed.
Approach: We use two pointers start and end to maintain the starting and ending point of the array and follow the steps given below:
- Stop if we have reached the end of the array
- Increment the end index if start has become greater than end
- Print the subarray from index start to end and increment the starting index
Below is the implementation of the above approach.
 [1, 2]  [1, 2, 3] [2, 3] 
- Generating all possible Subsequences using Recursion
- Differences between number of increasing subarrays and decreasing subarrays in k sized windows
- Mathematics | Generating Functions - Set 2
- Dynamically generating a QR code using PHP
- Generating random Id's in Python
- Generating Word Cloud in Python
- Generating Lyndon words of length n
- Generating Strong Password using Python
- Generating numbers that are divisor of their right-rotations
- Generating Random id's using UUID in Python
- Generating Word Cloud in Python | Set 2
- Reading and Generating QR codes in Python using QRtools
- Generating all divisors of a number using its prime factorization
- Generating random strings until a given string is generated
- Generating random number list in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.