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] 
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Generating all possible Subsequences using Recursion
- Reading and Generating QR codes in Python using QRtools
- Generating Random id's using UUID in Python
- Generating hash id's using uuid3() and uuid5() in Python
- Dynamically generating a QR code using PHP
- Generating Strong Password using Python
- Generating all divisors of a number using its prime factorization
- Differences between number of increasing subarrays and decreasing subarrays in k sized windows
- Generating random Id's in Python
- Generating random strings until a given string is generated
- Generating Word Cloud in Python
- Mathematics | Generating Functions - Set 2
- Generating Word Cloud in Python | Set 2
- Generating numbers that are divisor of their right-rotations
- Generating Lyndon words of length n
- Generating random number list in Python
- Generating Random Numbers in Golang
- Generating Random Integers in Pandas Dataframe
- Generating Basic Discrete Time Signals
- Decimal to Binary using recursion and without using power operator
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.