L6. Recursion on Subsequences | Printing Subsequences

preview_player
Показать описание

In case you are thinking to buy courses, please check below:

---------------------------------------------------------------------------------------------------------------------------------------------------- Please check out the entire channel for other sets of series on tougher and complex topics. Also do consider subscribing :)

Рекомендации по теме
Комментарии
Автор

Man i usually don't comment on Youtube videos, but i just solved 3 medium level questions in under 20 mins. i have no words to express. but this video specifically is a gem to solve most of the recursion sub-seq problem.
Thank you so much 😄
Edit : i have watched this video 2-3 months back(December) for dynamic programming, till this day i remember every detail of the video.

jaimitkumarpanchal
Автор

Best thing is you have very deep understanding of the topics and you code your own way. While other videos mostly pick code from GFG and explain which goes above head. Thanks for lovely explanation.

ashwanisharma
Автор

after watching 3 times, now understood. Those who are not able to understand, it's okay, retry, you will get it, and after that you will feel good.

AbhinavKumar-tgil
Автор

JAVA CODE FOR THE SAME WILL BE ::-
public static void main(String[] args) {
int[] arr = { 3, 1, 2 };
ArrayList<Integer> list = new ArrayList<>();
printSub(0, arr, list);
}

private static void printSub(int i, int[] arr, ArrayList<Integer> list) {
if (i == arr.length) {

return;
}
list.add(arr[i]);
printSub(i + 1, arr, list);
list.remove(list.size() - 1);
printSub(i + 1, arr, list);
}

ShubhamSinghMr.s
Автор

Best series on recursion in the internet. Thanks alot for your time and effort.

dgvj
Автор

JAVA Code-
public static void sub(ArrayList<Integer> al, int arr[], int i){
if(i == arr.length){

return;
}
al.add(arr[i]);
sub(al, arr, i+1);
al.remove(al.size()-1);
sub(al, arr, i+1);
}

jayeshbangar
Автор

Finally, the day has come to understand and as well code for the same.

sarathchandra
Автор

02:18 Generate all subsequences for an array using recursion
04:36 Understanding the structure and pattern of code is crucial for solving problems.
06:50 Code implementation to create a subsequence using recursion.
09:16 By making recursive calls with different indices and choosing whether to include the last element, you can generate all possible subsequences of an array.
11:27 Remove elements from an array based on specific conditions.
13:39 Understanding the concept of adding and removing items in a sequence
15:42 Printing the values in a recursion tree
17:46 Printing subsequences using recursion
19:38 Print a data structure to display the subsequence
21:20 The algorithm involves picking or not picking elements from a given array.
23:10 Time complexity is 2^n and space complexity is O(n)

iitimunda
Автор

Amazing man, doesn't even know us, isn't even related to us, but still is doing so much for the students aspiring to be software engineers. People like him are the ones who become inspiration to others to bring change to the society.

sniper_army
Автор

Brilliant explanation! I never quite understood this question before watching this video. The take/not take pattern is going to be in my head forever. Thank you so much! You're an amazing teacher :)

potatocoder
Автор

THANK YOU BRO,
BEST PART: YOU COmpletely connects with your audience and each and every step goes direclty into our brain and we understand everything.
Thank You & keep it up

travelnlearn
Автор

If we want to avoid the remove part, we can first call without adding and then add the element and call function again with the added element in the vector.

visheshwaghmare
Автор

after watching many videos on recursion, i was not able to do dry run of recursion question .Now i can say this is the best explaination for begineers to do dry run and understand recursion.just fantastic bhaiya like how easy you explained .hats off nailed it respect++.

ayushuniyal
Автор

What a explaition strting from base case to dry run to recursion tree, Fully fantastic, even i used to code in java still noone can reach your level of explanation ❤🤘 Best video...

adityadeshbhartar
Автор

indeed, it's a wonderful explanation. thanks for taking time and doing this for community

sureshgarine
Автор

I had to watch this video for more than 5 times.
God bless you bro

habeeblaimusa
Автор

after this video I solved subset sum pretty easily. Thank for your crystal clear explanation

ardhidattatreyavarma
Автор

Amazed by your lessons, i feel like i know recursion better than before, thanks bro.

yotowilliam
Автор

You made it much simple to understand! A true teacher! Thank you 💚

NiyatiShah
Автор

STARTED YESTERDAY, IT CAN BE HELPFUL FOR THOSE WHO STARTED NOW...LIKE ME... PYTHON CODE FOR THE SAME IS: def subseq(index, current, arr):
if index >= len(arr):
print(current)
return

current.append(arr[index])
subseq(index+1, current, arr)

current.pop()
subseq(index+1, current, arr)

arr = [3, 1, 2]
index=0
subseq(index, [ ], arr)

madhujustin