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
- Generating random Id's in Python
- Mathematics | Generating Functions - Set 2
- Dynamically generating a QR code using PHP
- Generating Word Cloud in Python | Set 2
- Generating numbers that are divisor of their right-rotations
- Generating Strong Password using Python
- Generating Word Cloud in Python
- Generating Lyndon words of length n
- Generating Random id's using UUID in Python
- Generating random strings until a given string is generated
- Generating hash id's using uuid3() and uuid5() in Python
- Reading and Generating QR codes in Python using QRtools
- 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 email@example.com. 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.