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] 
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Generating all possible Subsequences using Recursion
- Differences between number of increasing subarrays and decreasing subarrays in k sized windows
- Generating random Id's in Python
- Dynamically generating a QR code using PHP
- Mathematics | Generating Functions - Set 2
- Generating Lyndon words of length n
- Generating Random Numbers in Golang
- Generating Strong Password using Python
- Generating Random id's using UUID in Python
- Generating numbers that are divisor of their right-rotations
- Generating Word Cloud in Python | Set 2
- Generating Word Cloud in Python
- Generating all divisors of a number using its prime factorization
- Generating random strings until a given string is generated
- Reading and Generating QR codes in Python using QRtools
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.