Recursion - Pattern Questions + Bubble Sort + Selection Sort

In this video we solve some of the pattern problems using #recursion. Using which we implement bubble sort and selection sort with recursion.
Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!
👉 Resources
- Join Replit: join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: • Java + DSA + Interview...
- Code, Assignments, & Notes: github.com/kunal-kushwaha/DSA...
➡️ Connect with me: kunalkushwaha.com
=========================================
Timestamps:
00:00 Introduction
01:19 Q1 : Triangle 1
09:27 Q2 : Triangle 2
13:44 Q3 : Bubble Sort
21:32 Q4 : Selection Sort
34:17 Outro
#placement #dsa #interviews

Пікірлер: 230

  • @Tomharry910
    @Tomharry910 Жыл бұрын

    Recursion is the part where even the most intelligent of folks struggle and give up programming. In India, I have personally seen intelligent people reluctant to share their knowledge out of hyper competetiveness. You don't know how many lives you're building by generously sharing this top level knowledge free of cost. God will always bless you for this selfless noble act, Kunal Sir 🙏

  • @mysteryman2213

    @mysteryman2213

    Жыл бұрын

    good words and nice name though

  • @aakashbhandari9761

    @aakashbhandari9761

    Жыл бұрын

    ​@@mysteryman2213 😂

  • @plutomessi21

    @plutomessi21

    10 ай бұрын

    @@mysteryman2213 🤣

  • @albin6126

    @albin6126

    8 ай бұрын

    i noticed because you said legend @@mysteryman2213

  • @shubhamsemwal5254

    @shubhamsemwal5254

    6 ай бұрын

    hahahha

  • @nikolas8203
    @nikolas82032 жыл бұрын

    Gotta appreciate how you linked the pattern thing to bubble sort and selection sort...at first I was confused about it but then in a moment I was like "woah got it". Top-notch playlist

  • @prasadm3614
    @prasadm3614 Жыл бұрын

    Yes, as you mentioned we r waiting for that course on DP that no-one has created so far !!!

  • @KrishNamaste

    @KrishNamaste

    Жыл бұрын

    Same here!

  • @shantohossain1372

    @shantohossain1372

    Жыл бұрын

    same here but it's more than one and half year gone!!

  • @udaysingh2929

    @udaysingh2929

    5 ай бұрын

    still waiting

  • @prtk2verma

    @prtk2verma

    5 күн бұрын

    @@udaysingh2929 khada hu aaj bhi wohi....

  • @user-kt2uu9qt8l
    @user-kt2uu9qt8l Жыл бұрын

    Kunal, I cannot express my gratitude enough. Your teaching has been exceptional and transformative for me. I have finally grasped the concept of recursion - something that eluded me until now. You are an incredible teacher and mentor. PLEASE PLEASE PLEASE teach us more subjects like Hashmap and Dynamic programming. I am eagerly looking forward to taking those courses as well. 🙏

  • @learnandtravel7722
    @learnandtravel772210 ай бұрын

    so here i completed more than half of the videos of this dsa playlist, day by day dsa is looking easy thanks to kunal for this amazing playlist and waiting for you to complete this playlist

  • @saurabhjaswal21
    @saurabhjaswal212 жыл бұрын

    This playlist helps me a lot, thanks man for providing such a brilliant course

  • @mrwhosetheboss6876
    @mrwhosetheboss68762 жыл бұрын

    kunal beside programming your are really a good teacher like u started with patterns thats simillar to two sorting technique its amazing and really helpfull thanks

  • @aryangupta6335
    @aryangupta633510 күн бұрын

    Must say it is the best playlist for recursion over the internet so far ...

  • @senseiAree
    @senseiAree Жыл бұрын

    I'm not a Java Programmer but Getting inspired by you, I have created a new Hackerank Account and started solving the problem solving questions again but this time I am using Recursion only. I have had six stars in problem solving before but I always struggled on Recursion. Thanks a lot Kunal Sir. You gave me inspiration. My core weakness was permutation and combination... Today after watching your algorithm on Recursion: Subset... I implemented the code in C# and I started jumping out of enthusiasm when it ran successfully.. I also implemented dynamic programming to it so it doesn't repeat on the same characters in the string. I can't elaborate with words how thankful I am.

  • @sidhantgupta64
    @sidhantgupta6411 ай бұрын

    I watch many videos for recursion but your one is the best because the way of teaching is good

  • @ishanvyas2178
    @ishanvyas217815 күн бұрын

    your explaination is so clear i was able to solve the bubblesort and selection sort problem with recursion without looking your solution first. Thanks a lot brother you're really awesome

  • @ronitsharma0352
    @ronitsharma03524 ай бұрын

    Have to say one has to put everything to create a course like this !!! Thanks for the awesome and intuitive course but kunal bhai please complete this playlist. We really need videos on the rest of the topics!!!!!!!

  • @malishagavali9225
    @malishagavali922524 күн бұрын

    Oh gosh, I was banging my head against the wall! I really thought we were going to print the pattern using bubble sort. Now I understand that we're solving bubble sort using recursion, haha

  • @AdityaSingh-nz2if
    @AdityaSingh-nz2ifАй бұрын

    MindBlowing , u just connected a simple pattern question to BubbleSort , gave JEE feel when my teachers used to connect Advance problems to a simple concept. I am eagerly waiting for the DP series.

  • @abirgupta2711
    @abirgupta27112 жыл бұрын

    Hey Kunal, can you share a tentative timeline for this bootcamp? That will be very helpful. Anyways the videos are super awesome !!

  • @keshavdeosharma7222
    @keshavdeosharma722210 ай бұрын

    Thanks Kunal Bhaiya for sharing the knowldege.

  • @shraddhaverma6434
    @shraddhaverma64342 жыл бұрын

    Thanks for the amazing content kunal 🔥 kudos!

  • @vedanta007
    @vedanta0072 жыл бұрын

    Kunal bro on fire 2 videos within 24hrs 🔥🔥

  • @devjoshi7062
    @devjoshi70622 жыл бұрын

    really liked how you changed the intuition of pattern algorithm to make us understand the recursions for both the sorts, kinda makes people get up from all the boring tutorial vibe, haha loved it

  • @khushipurohit8761

    @khushipurohit8761

    2 ай бұрын

    that was really cool

  • @fitnessandscience1575
    @fitnessandscience15752 жыл бұрын

    Thanks for sharing ur beautiful knowledge kunal bro ❤️❤️❤️

  • @ridoychandradey8337
    @ridoychandradey8337 Жыл бұрын

    Recursion guru Kunal Kushwaha. Eagerly waiting for dynamic programming series.

  • @shadowmonarch1432
    @shadowmonarch1432 Жыл бұрын

    After getting a feel of recursions,I'm able to solve all of them before the video🥲 thanks Kunal🙂

  • @rajeevkandpal1880
    @rajeevkandpal1880 Жыл бұрын

    Hey @Kunal, thanks for all the awesome content you are providing for free. This is pure GOLD i must say. Can you point me to some of DP videos you have, I am not able to find anything on DP on your channel?

  • @MegaArvind111
    @MegaArvind1112 жыл бұрын

    Time for a job change... This is best playlists to work thru...

  • @akshaygill4483
    @akshaygill4483 Жыл бұрын

    Man you taught me how to debug a code , and it is very usefull while doing recursion questions thanku so much

  • @Hello_Beasty
    @Hello_Beasty2 жыл бұрын

    Bro make a video on how a new coder start it's journey and when we do internship

  • @aman_mandal
    @aman_mandal2 жыл бұрын

    Although...am lil far from this lecture...but thankyouu for the consistency sir❤️✨

  • @Helly_Patel
    @Helly_Patel2 жыл бұрын

    Thanks for teaching us like no one did till now!! One small request, please make lectures on dynamic programming as well!!

  • @deepanshu5394

    @deepanshu5394

    Жыл бұрын

    ++

  • @KhushiSingh-ft8dk
    @KhushiSingh-ft8dkАй бұрын

    This playlist helps me a lot, thanks sir for providing such an amazing course..😇

  • @dipalitusharvlogs7252
    @dipalitusharvlogs72529 ай бұрын

    As always, simplified and awesome explanation💚

  • @jamespeterson7824
    @jamespeterson78242 жыл бұрын

    Good thought process by making that pattern question relatable to BubbleSort and SelectionSort.. Good knowledge is being grasped from you day by day 🙂

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    You're most welcome

  • @santhosh7042

    @santhosh7042

    2 жыл бұрын

    Can you helpme out find what's wrong with this selection code after debugging i get to know that the zero index value is swapping with it's next value when the before pass is sorted let me explained what i saw on debugging is arr= 4 , 3 , 2 ,1 where s = 0; e = arr.length-1 when s = 0 (index) e = 2(index) arr is sorted i got the desired answer but when s = 0 and e = 1 it again get maximum value as 1 and rather than swapping with it self it is swapping with next index value and resulting in 2 , 1 , 3 , 4 static void selection_sort(int[] arr) { helper(arr,0,arr.length-1,Integer.MIN_VALUE,-1); } static void helper(int[] arr, int s, int e,int max,int max_index) { if(e==0) { return; } if(s

  • @aeroabrar_31

    @aeroabrar_31

    Жыл бұрын

    @@KunalKushwaha Please continue this Bootcamp !!😪😭

  • @akashstark1836

    @akashstark1836

    11 ай бұрын

    ​@@santhosh7042in if condition you have to give like s

  • @aakansha5889
    @aakansha58892 жыл бұрын

    When any pattern question comes in interview what should i use iteration or recursion? could anybody tell

  • @ABHISHEKKUMAR-do7uw
    @ABHISHEKKUMAR-do7uw Жыл бұрын

    Hello Sir bubble sort code is giving stackOver flow error when size of the array is increased . Here is the constrain for the length of an array 1

  • @keshav-ip7vx
    @keshav-ip7vx Жыл бұрын

    in the first program, the stack size is the total number of (*) or O(row^2) so we should return until we start printing the next row for good programming practice.

  • @dankcricket5730
    @dankcricket57302 жыл бұрын

    Kunal bro, is it possible to complete this Bootcamp by November 2nd week? Hope you complete this Bootcamp by mid November!🙏

  • @yogeshyts

    @yogeshyts

    Жыл бұрын

    next year k november a gya abhi tk ni hua🤣🤣🤣🤣🤣🤣

  • @aeroabrar_31

    @aeroabrar_31

    Жыл бұрын

    @@yogeshyts han LOL🤣

  • @yogeshyts

    @yogeshyts

    Жыл бұрын

    @@aeroabrar_31 February m start hoga ab bola h usne

  • @aeroabrar_31

    @aeroabrar_31

    Жыл бұрын

    @@yogeshyts Kidhar bola hai bhai usne.. Mai toh puri tarah usi par depend hua hoon 🥺

  • @yogeshyts

    @yogeshyts

    Жыл бұрын

    @@aeroabrar_31 twitter p active h wo

  • @burhanuddinraja7209
    @burhanuddinraja72092 жыл бұрын

    Kunal a humble request to please start the topics like Dynamic programming, hashing and stuff. It will be very helpful. Your explanations are good that's why.

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    I will

  • @burhanuddinraja7209

    @burhanuddinraja7209

    2 жыл бұрын

    @@KunalKushwaha Thank you for this course

  • @veerendrasaikumar1008
    @veerendrasaikumar10088 ай бұрын

    Kunal, The TC for best case scenario in Bubble sort is 0(n), however using the recursion example it is still o(n2). Is there a way to include an extra flag as parameter and break recusion if the array is already sorted like we did in iteration example.

  • @atulpanda6051
    @atulpanda60512 жыл бұрын

    Thanks for this Recursion video

  • @devendrasolunke4619
    @devendrasolunke46192 жыл бұрын

    Bro you bring back my confidence and intrest in programming..❤️

  • @shubhamshejaval8526
    @shubhamshejaval8526 Жыл бұрын

    cant figure out the space complexity and recurrence relation of recursive bubble sort. Any help will be appreciated!

  • @ekemm
    @ekemm Жыл бұрын

    hi i wanted to ask that fun(4,4) will be called in stack or not ?

  • @srinivasanshankaranarayana3093
    @srinivasanshankaranarayana30932 жыл бұрын

    Awesome content 👏👌

  • @KovidhVSBhati
    @KovidhVSBhati2 ай бұрын

    i think for first if(c < r) it should be if(c

  • @KrishNamaste
    @KrishNamaste Жыл бұрын

    Man, please continue this if it is possible.

  • @DipankarDas-cm1zs
    @DipankarDas-cm1zs2 жыл бұрын

    Bro could you tell any documentation for java from where I could learn it

  • @kritikjain3617
    @kritikjain36172 жыл бұрын

    What an explanation man!

  • @parul8334
    @parul8334 Жыл бұрын

    Today I have done all easy question from the assignment and tomorrow I will try the medium one

  • @dinbandhusharma4568
    @dinbandhusharma45689 ай бұрын

    thanks for this amazing video 🤗👍🏻🔥❤‍🔥

  • @varunsen2802
    @varunsen28022 жыл бұрын

    Thank You so much brother!

  • @priyanshuvettori5179
    @priyanshuvettori5179 Жыл бұрын

    wow this is wonderful really.

  • @mathis-meth4229
    @mathis-meth4229 Жыл бұрын

    Kunal is the OG of DSA teaching

  • @spdwivedi5925
    @spdwivedi59255 күн бұрын

    Great video

  • @malavipande6693
    @malavipande6693 Жыл бұрын

    If I try to execute triangle2 problem in python programming language it is returning the None can anyone help me?

  • @sayanchaudhuri8885
    @sayanchaudhuri88852 жыл бұрын

    can anyone explain why swapping is with a[r-1] and not a[r]

  • @foyzanahmed4091
    @foyzanahmed409110 ай бұрын

    brother, Please start DP series. You are magician.

  • @akashstark1836
    @akashstark183611 ай бұрын

    For selection sort we can start column value from 1 since we assign max as 0 in initial all the time , we don't have to check 0 th position with 0th

  • @Aniket_0314
    @Aniket_0314 Жыл бұрын

    woooooo hoooooooooooooooooooo great video ✨😊

  • @KovidhVSBhati
    @KovidhVSBhati2 ай бұрын

    12:58 why wont f(3,3), f(2,2), f(1,1) be called.... without them i dont think any function call will return at the else statement

  • @kartik7239
    @kartik72393 ай бұрын

    I was hoping you finish this playlist.

  • @tribhuvanmishra7865
    @tribhuvanmishra7865 Жыл бұрын

    Hey Kunal, when will you resume making these videos again.

  • @kanyapandey
    @kanyapandey Жыл бұрын

    Thank you my Guru 👏👏👏👏

  • @krishnanigalye1173
    @krishnanigalye117310 ай бұрын

    Will following solution work for Triangle 1? function logger(r, c) { if(r === 0) return; const arr = []; while( r > c) { arr.push('$'); c++; } console.log(...arr); r -= 1; logger(r,0); } function printTriangle(n) { logger(n, 0); } printTriangle(10);

  • @allaboutgamimg7976
    @allaboutgamimg79762 жыл бұрын

    Awesome 🔥

  • @noorulabdeen5451
    @noorulabdeen54512 жыл бұрын

    You amazing brother thanks

  • @sudhanshukushwaha6351
    @sudhanshukushwaha6351 Жыл бұрын

    In every classroom there are such students who ask like this 😁😁

  • @litheshshetty7839
    @litheshshetty78392 жыл бұрын

    7:23 eagerly waiting for it bhai!!!

  • @nayanmu
    @nayanmu2 жыл бұрын

    Awesome bro..when will you teach us dynamic programming?

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Yes but later

  • @mahajveemahajvee8941

    @mahajveemahajvee8941

    Жыл бұрын

    @@KunalKushwaha ok 🙂🙂🙂🙂

  • @ziadotenv

    @ziadotenv

    3 ай бұрын

    ​@@KunalKushwaha dp 😢

  • @sravanakirtana2787
    @sravanakirtana27873 ай бұрын

    Nice Video

  • @manhoodthinkmanly
    @manhoodthinkmanly2 жыл бұрын

    brooo please bring DP playlist now its enough time im crying for your videos for DP

  • @mudittiwari8615
    @mudittiwari8615 Жыл бұрын

    I love this course

  • @Ayush-bk3rv
    @Ayush-bk3rv2 жыл бұрын

    In the bubble sort, can we use for loop inside the recursion function, and pass a window size as an argument to the recursion function after every sub call to the bubbleSort function

  • @virat7800
    @virat78002 жыл бұрын

    awesome😍😍😍😍

  • @srinjoysom1413
    @srinjoysom14139 ай бұрын

    kunal can you explain what is question

  • @reshihashim4094
    @reshihashim40942 жыл бұрын

    u make things easier and simpler to understand .... thank u so much for this Recursion playlist 🔥🔥🔥... Learnt a lot from you, like how to approach a problem and different ways of solving a particular problem and so on... keep it up brother 🙂🙂🙂 Love from Kashmir ❤️

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    You are most welcome

  • @yogeshkumarpandey2343
    @yogeshkumarpandey23432 жыл бұрын

    *This is my C++ Code. The course is Fantastic.* void buble(int *arr,int n,int end,int itr) { if(end==0) { return; } if(arr[itr]>arr[itr+1]&&itr

  • @amandixit8342
    @amandixit83422 жыл бұрын

    Bhaiya (arrays ,pattern , strings..etc )on recursion topic ki easy ,medi ,hard arrange kar dijiye bhaiya please , aur Assignment mein aur ques practice ke hote toh acha rehta

  • @kishanmadlani1391
    @kishanmadlani1391 Жыл бұрын

    10:00 this is also a one method for print the stars method static void triangle(int r ,int c){ if (c 0) { System.out.print("* "); printStars(n - 1); } }

  • @user-oq3kf8ep3f
    @user-oq3kf8ep3f Жыл бұрын

    when will you upload dp stuff????

  • @santhosh7042
    @santhosh70422 жыл бұрын

    Can any one find what's wrong with this selection code after debugging i get to know that the zero index value is swapping with it's next value when the before pass is sorted let me explained what i saw on debugging is arr= 4 , 3 , 2 ,1 where s = 0; e = arr.length-1 when s = 0 (index) e = 2(index) arr is sorted but when s = 0 and e = 1 it again get maximum value as 1 and rather than swapping with it self it is swapping with next index value and resulting in 2 , 1 , 3 , 4 static void selection_sort(int[] arr) { helper(arr,0,arr.length-1,Integer.MIN_VALUE,-1); } static void helper(int[] arr, int s, int e,int max,int max_index) { if(e==0) { return; } if(s

  • @utkarshkaushik9288
    @utkarshkaushik92885 ай бұрын

    when we wil get dynamic programming videos?????

  • @rahuldev6206
    @rahuldev62062 жыл бұрын

    nice content we love your efforts can you suggest me any course of android development❤❤

  • @vaishnaviummaji321
    @vaishnaviummaji32110 ай бұрын

    @KunalKushwaha when will you start dynamic programming series?

  • @arbindsharma1423
    @arbindsharma1423 Жыл бұрын

    bhai, I can't see dynamic problems video? Can you please upload one .. and bdw loved your content.

  • @eatajerkpal99
    @eatajerkpal99 Жыл бұрын

    i hope i meet you one day and thank you!

  • @mohakhiphop
    @mohakhiphop2 жыл бұрын

    At this stage I'm able to solve given problems before i see your solution 🙌 hats off and huge thanks to you for helping me in developing the approach ❤️💯

  • @dineshmadduru7043
    @dineshmadduru7043Ай бұрын

    Thank You XD

  • @letstry.coding_2816
    @letstry.coding_2816 Жыл бұрын

    thank you so much

  • @feliksbekeshov7668
    @feliksbekeshov7668 Жыл бұрын

    Kunal when we will have Trees and Graphs here in this DSA playlist??????

  • @salerio1890
    @salerio1890 Жыл бұрын

    where are the dynamic programming videos???

  • @nikitajaiswal9112
    @nikitajaiswal91122 жыл бұрын

    Q. 1 solution Def triangle(n) : If n==0: return Print("* "*n) triangle (n-1)

  • @devyanshjoshi485
    @devyanshjoshi485 Жыл бұрын

    static void sort(int[] arr, int r,int c,int max){ if(r == 0){ return; } if(c

  • @ayushverma6019
    @ayushverma60192 жыл бұрын

    Amazing

  • @cindrasenareddy1929
    @cindrasenareddy1929 Жыл бұрын

    asusual kunal rocks!!!!!!!!!!

  • @amaanullah13

    @amaanullah13

    Жыл бұрын

    Bro put space after "as" I've read it asexual Kunal rocks🤣

  • @mymobile6271
    @mymobile6271 Жыл бұрын

    Where are DP video?

  • @akashvadher6724
    @akashvadher67242 жыл бұрын

    Make video on quick sort and mergesort using recursion

  • @anchit1237
    @anchit12372 жыл бұрын

    Kunal, Can I learn C++ and Java together? I know it's difficult but would there be a bigger problem in the future?

  • @prakhar266

    @prakhar266

    2 жыл бұрын

    Learn either java or c++ thoroughly first .other language will take max 15 days for completion

  • @rashidansari4176

    @rashidansari4176

    2 жыл бұрын

    @@prakhar266 Completely agree with with you bro, learn anyone first. then switching is to another is quite easy.

  • @mohammedsuhail8706

    @mohammedsuhail8706

    2 жыл бұрын

    Syntax will screw u If u try to learn it together

  • @amansayer4943

    @amansayer4943

    Жыл бұрын

    @@mohammedsuhail8706 bhai wahi hogaya mere sath .

  • @anukritisingh4479
    @anukritisingh4479 Жыл бұрын

    when will dp series come?

  • @shubhanshukushwaha6150
    @shubhanshukushwaha615010 ай бұрын

    bubble sort gives stackoverflow at line no. 53 in your code , kindly take example as 4872.

  • @Naveen-jl1vz
    @Naveen-jl1vz11 ай бұрын

    ❤...bro linkedlist,graphs,dp videos?

  • @Aakashhoney278
    @Aakashhoney278 Жыл бұрын

    please complete the course sir