Recursion - Pattern Questions + Bubble Sort + Selection Sort

Sdílet
Vložit
  • čas přidán 21. 07. 2024
  • 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

Komentáře • 230

  • @Tomharry910
    @Tomharry910 Před rokem +160

    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 🙏

  • @nikolas8203
    @nikolas8203 Před 2 lety +22

    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

  • @user-kt2uu9qt8l
    @user-kt2uu9qt8l Před rokem +7

    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. 🙏

  • @prasadm3614
    @prasadm3614 Před rokem +18

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

  • @saurabhjaswal21
    @saurabhjaswal21 Před 2 lety +15

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

  • @mrwhosetheboss6876
    @mrwhosetheboss6876 Před 2 lety +6

    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

  • @learnandtravel7722
    @learnandtravel7722 Před 10 měsíci +1

    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

  • @shraddhaverma6434
    @shraddhaverma6434 Před 2 lety +2

    Thanks for the amazing content kunal 🔥 kudos!

  • @abirgupta2711
    @abirgupta2711 Před 2 lety +17

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

  • @vedanta007
    @vedanta007 Před 2 lety +6

    Kunal bro on fire 2 videos within 24hrs 🔥🔥

  • @ishanvyas2178
    @ishanvyas2178 Před 14 dny

    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
    @ronitsharma0352 Před 4 měsíci +1

    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!!!!!!!

  • @AdityaSingh-nz2if
    @AdityaSingh-nz2if Před měsícem +1

    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.

  • @sidhantgupta64
    @sidhantgupta64 Před 11 měsíci

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

  • @aryangupta6335
    @aryangupta6335 Před 9 dny

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

  • @rajeevkandpal1880
    @rajeevkandpal1880 Před rokem +4

    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?

  • @devjoshi7062
    @devjoshi7062 Před 2 lety +6

    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

  • @keshavdeosharma7222
    @keshavdeosharma7222 Před 10 měsíci +1

    Thanks Kunal Bhaiya for sharing the knowldege.

  • @fitnessandscience1575
    @fitnessandscience1575 Před 2 lety +2

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

  • @senseiAree
    @senseiAree Před rokem +6

    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.

  • @ridoychandradey8337
    @ridoychandradey8337 Před rokem +3

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

  • @aman_mandal
    @aman_mandal Před 2 lety +8

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

  • @malishagavali9225
    @malishagavali9225 Před 23 dny +1

    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

  • @dipalitusharvlogs7252
    @dipalitusharvlogs7252 Před 9 měsíci

    As always, simplified and awesome explanation💚

  • @shadowmonarch1432
    @shadowmonarch1432 Před rokem

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

  • @Hello_Beasty
    @Hello_Beasty Před 2 lety +15

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

  • @MegaArvind111
    @MegaArvind111 Před 2 lety +2

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

  • @Helly_Patel
    @Helly_Patel Před 2 lety +4

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

  • @jamespeterson7824
    @jamespeterson7824 Před 2 lety +18

    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  Před 2 lety +9

      You're most welcome

    • @santhosh7042
      @santhosh7042 Před 2 lety

      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 Před rokem +4

      @@KunalKushwaha Please continue this Bootcamp !!😪😭

    • @akashstark1836
      @akashstark1836 Před 10 měsíci

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

  • @akshaygill4483
    @akshaygill4483 Před rokem

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

  • @atulpanda6051
    @atulpanda6051 Před 2 lety +2

    Thanks for this Recursion video

  • @KhushiSingh-ft8dk
    @KhushiSingh-ft8dk Před měsícem

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

  • @KrishNamaste
    @KrishNamaste Před rokem +2

    Man, please continue this if it is possible.

  • @kritikjain3617
    @kritikjain3617 Před 2 lety +1

    What an explanation man!

  • @srinivasanshankaranarayana3093

    Awesome content 👏👌

  • @keshav-ip7vx
    @keshav-ip7vx Před rokem +1

    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
    @dankcricket5730 Před 2 lety +28

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

    • @yogeshyts
      @yogeshyts Před rokem +3

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

    • @aeroabrar_31
      @aeroabrar_31 Před rokem

      @@yogeshyts han LOL🤣

    • @yogeshyts
      @yogeshyts Před rokem +1

      @@aeroabrar_31 February m start hoga ab bola h usne

    • @aeroabrar_31
      @aeroabrar_31 Před rokem

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

    • @yogeshyts
      @yogeshyts Před rokem

      @@aeroabrar_31 twitter p active h wo

  • @dinbandhusharma4568
    @dinbandhusharma4568 Před 9 měsíci

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

  • @devendrasolunke4619
    @devendrasolunke4619 Před 2 lety +6

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

  • @varunsen2802
    @varunsen2802 Před 2 lety

    Thank You so much brother!

  • @burhanuddinraja7209
    @burhanuddinraja7209 Před 2 lety +6

    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.

  • @mathis-meth4229
    @mathis-meth4229 Před rokem

    Kunal is the OG of DSA teaching

  • @parul8334
    @parul8334 Před rokem +2

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

  • @priyanshuvettori5179
    @priyanshuvettori5179 Před rokem

    wow this is wonderful really.

  • @veerendrasaikumar1008
    @veerendrasaikumar1008 Před 8 měsíci

    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.

  • @foyzanahmed4091
    @foyzanahmed4091 Před 10 měsíci +1

    brother, Please start DP series. You are magician.

  • @akashstark1836
    @akashstark1836 Před 10 měsíci

    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

  • @KovidhVSBhati
    @KovidhVSBhati Před 2 měsíci

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

  • @nayanmu
    @nayanmu Před 2 lety +12

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

  • @spdwivedi5925
    @spdwivedi5925 Před 4 dny

    Great video

  • @kanyapandey
    @kanyapandey Před rokem

    Thank you my Guru 👏👏👏👏

  • @litheshshetty7839
    @litheshshetty7839 Před 2 lety

    7:23 eagerly waiting for it bhai!!!

  • @allaboutgamimg7976
    @allaboutgamimg7976 Před 2 lety

    Awesome 🔥

  • @Aniket_0314
    @Aniket_0314 Před rokem

    woooooo hoooooooooooooooooooo great video ✨😊

  • @mudittiwari8615
    @mudittiwari8615 Před rokem

    I love this course

  • @noorulabdeen5451
    @noorulabdeen5451 Před 2 lety

    You amazing brother thanks

  • @kartik7239
    @kartik7239 Před 3 měsíci

    I was hoping you finish this playlist.

  • @rahuldev6206
    @rahuldev6206 Před 2 lety +1

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

  • @eatajerkpal99
    @eatajerkpal99 Před rokem

    i hope i meet you one day and thank you!

  • @kishanmadlani1391
    @kishanmadlani1391 Před rokem

    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);
    }
    }

  • @aakansha5889
    @aakansha5889 Před 2 lety +1

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

  • @virat7800
    @virat7800 Před 2 lety

    awesome😍😍😍😍

  • @yogeshkumarpandey2343
    @yogeshkumarpandey2343 Před 2 lety

    *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

  • @ABHISHEKKUMAR-do7uw
    @ABHISHEKKUMAR-do7uw Před rokem +1

    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

  • @reshihashim4094
    @reshihashim4094 Před 2 lety +9

    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 ❤️

  • @manhoodthinkmanly
    @manhoodthinkmanly Před rokem +2

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

  • @cindrasenareddy1929
    @cindrasenareddy1929 Před rokem +1

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

    • @amaanullah13
      @amaanullah13 Před rokem +1

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

  • @sravanakirtana2787
    @sravanakirtana2787 Před 3 měsíci

    Nice Video

  • @dineshmadduru7043
    @dineshmadduru7043 Před měsícem

    Thank You XD

  • @anandrengu5806
    @anandrengu5806 Před 4 měsíci

    Hi Kunal, Nice playlist ,it is helping me a lot ,I have a doubt like in triangle2 ,I think so you missed to mention that function call like (3,3) ,(2,2) ,(1,1) will also happen .Anyways thanks man for your amazing playlist.

  • @shubhamshejaval8526
    @shubhamshejaval8526 Před rokem

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

  • @sudhanshukushwaha6351
    @sudhanshukushwaha6351 Před rokem +1

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

  • @ekemm
    @ekemm Před rokem

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

  • @Ayush-bk3rv
    @Ayush-bk3rv Před 2 lety +3

    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

  • @amandixit8342
    @amandixit8342 Před 2 lety

    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

  • @DipankarDas-cm1zs
    @DipankarDas-cm1zs Před 2 lety

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

  • @ayushverma6019
    @ayushverma6019 Před 2 lety

    Amazing

  • @naruhitoabiku9451
    @naruhitoabiku9451 Před 7 měsíci

    you are a legend

  • @rishabhrawat8197
    @rishabhrawat8197 Před 2 lety

    pretty cool pretty cool

  • @letstry.coding_2816
    @letstry.coding_2816 Před rokem

    thank you so much

  • @rudram4534
    @rudram4534 Před 2 lety

    still watching consistently
    😀😀😀

  • @amandixit8342
    @amandixit8342 Před 2 lety

    Wow , recursion ki ek aur video 😁😁

  • @arbindsharma1423
    @arbindsharma1423 Před rokem

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

  • @itshari5489
    @itshari5489 Před rokem

    Video 29 Completed!

  • @shubhanshukushwaha6150
    @shubhanshukushwaha6150 Před 10 měsíci

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

  • @KovidhVSBhati
    @KovidhVSBhati Před 2 měsíci

    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

  • @coder_aditya9567
    @coder_aditya9567 Před 2 lety

    Best❤️❤️

  • @nashville455
    @nashville455 Před 6 měsíci

    amazing

  • @sayanchaudhuri8885
    @sayanchaudhuri8885 Před 2 lety

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

  • @anchit1237
    @anchit1237 Před 2 lety +11

    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 Před 2 lety +9

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

    • @rashidansari4176
      @rashidansari4176 Před 2 lety +1

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

    • @mohammedsuhail8706
      @mohammedsuhail8706 Před 2 lety +5

      Syntax will screw u
      If u try to learn it together

    • @amansayer4943
      @amansayer4943 Před rokem

      @@mohammedsuhail8706 bhai wahi hogaya mere sath .

  • @vaishnaviummaji321
    @vaishnaviummaji321 Před 10 měsíci

    @KunalKushwaha when will you start dynamic programming series?

  • @siddharthk2000
    @siddharthk2000 Před 2 lety

    Supper 🙏

  • @krishnanigalye1173
    @krishnanigalye1173 Před 10 měsíci

    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);

  • @venkatavarunlinga1081

    thank youu;)

  • @aryan4786
    @aryan4786 Před 2 lety

    thank you bhiya

  • @deepaksai3637
    @deepaksai3637 Před rokem

    Nice video,but pls complete the playlist

  • @akashvadher6724
    @akashvadher6724 Před 2 lety

    Make video on quick sort and mergesort using recursion

  • @mohakhiphop
    @mohakhiphop Před 2 lety

    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 ❤️💯

  • @nikitajaiswal9112
    @nikitajaiswal9112 Před 2 lety +2

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

  • @Naveen-jl1vz
    @Naveen-jl1vz Před 11 měsíci

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