#10 - DS & Algorithms Course | Advance Recursive function | Sorting | Interview Preparation 🔥

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ต.ค. 2024

ความคิดเห็น • 54

  • @akashsaha9366
    @akashsaha9366 3 ปีที่แล้ว +8

    Hello respected suneja vaiya,
    Just to remind you. I am the one who raised concern for this video and you made 1 video to clear our doubts today.
    1) hats off to you vaiya. In my life first time I have seen like you who made 1 video by giving crucial time just for our understanding. And gas taken my Name. Thank you a lot sir/vaiya.
    2) in today's video multiple time my name is taken as "Aman" But my name is "Akash"
    3) I am a professional software developer with 2+ years of experience in many big projects and working in 1 of the top mnc over world.
    4) what ever you did yesterday and today I have done in my local machine and understood the full issue.
    5) problem is with the JavaScript interpreter and not with our code.
    6) if you type this code in any staticly type language like java or python. You won't see the issue.
    7) why? In any compiler except JavaScript the array variable reference in heap memory is same for all time. But in js compiler during recursion the function is always changing its location in memory that's why we are getting undefiend or if it returned first then getting data.
    8) in any other strong language interpreter is quite sharp to handle this scenarios. And it updates all over the same variable and same reference
    9) that's why for data structure and recursion JavaScript is not fully recommend to avoid this type of scenarios.
    10) this is the 1 of the reason for react state and angular is in typescript.
    Vaiya aapka comment jarur dena.

    • @bot_programmer9
      @bot_programmer9 ปีที่แล้ว

      hey, brother, I need some suggestions would you please be available to chat for 10mins.Please share your LinkedIn profile for further connect

  • @TechnicalSuneja
    @TechnicalSuneja  3 ปีที่แล้ว +8

    Support this video series, not by money,but by sharing it with your friend's circle 🙏

  • @devkumarsharma7002
    @devkumarsharma7002 3 ปีที่แล้ว +4

    Suneja bhai aapki video har ek point ko achche se explain karti h🙏😊 Thanks brother for your Fantastic video content and explanation.

  • @AnilSahu-zx6wk
    @AnilSahu-zx6wk ปีที่แล้ว

    Your hard work is so appreciated. But ye wala difficult to h bhaiya. lagta h 10 video se ap difficulty level badhane ka plan kr rhe ho.

  • @suryatejaparvata
    @suryatejaparvata 2 ปีที่แล้ว

    you are explaining problem like cooking videos, i like it.

  • @sarthakagrawal6444
    @sarthakagrawal6444 2 ปีที่แล้ว

    Great Content Sir , please make more videos on questions related topics , make a paid playlist , we'll even buy it.

  • @sarthakagrawal6444
    @sarthakagrawal6444 2 ปีที่แล้ว

    Great Video Bhaiya

  • @Sp-px7gn
    @Sp-px7gn 3 ปีที่แล้ว

    Awesome Video in sort and recursion understand easily.

  • @prabhatkeshari2976
    @prabhatkeshari2976 3 ปีที่แล้ว +3

    Keep going bhaiya

  • @codingwala303
    @codingwala303 3 ปีที่แล้ว +1

    Nice video from Pakistan

  • @rajkamalnehul1581
    @rajkamalnehul1581 3 ปีที่แล้ว

    Please continue this series to 150 questions. 🔥🔥 Great content

  • @iamshravanmeena
    @iamshravanmeena 2 ปีที่แล้ว

    best explaination bhaiyaa

  • @RohitSainiHaryana
    @RohitSainiHaryana 2 ปีที่แล้ว +1

    How about this. Please check if I am doing good.
    var arr = [9,2,5,1,7]
    let done = true;
    function bubbleSort(arr){
    let output = []
    while(done){
    done = false;
    for (let index = 0; index < arr.length; index++) {
    if(arr[index] > arr[index + 1]){
    done = true;
    //swapping
    temp = arr[index+1];
    arr[index+1] = arr[index]
    arr[index] = temp
    }
    }
    }
    return arr
    }
    let sortedMamla= bubbleSort(arr)

  • @xdmotivation
    @xdmotivation 3 ปีที่แล้ว +1

    All good

  • @krishantanwar3388
    @krishantanwar3388 2 ปีที่แล้ว

    @Technical Suneja bhai what would be the time complexity for that problem.

  • @chaayparcharcha
    @chaayparcharcha 5 หลายเดือนก่อน

    else if mein (array[i]

  • @neerajkumarrajpoot909
    @neerajkumarrajpoot909 ปีที่แล้ว

    👍

  • @iamshravanmeena
    @iamshravanmeena 2 ปีที่แล้ว

    agr aap 2 value same provide krwate ho to RangeError: Maximum call stack size exceeded error aata hain.... but it solve if we are changing our else if(array[i]

    • @iamshravanmeena
      @iamshravanmeena 2 ปีที่แล้ว

      function generateSortedArray(array) {
      if (isSorted(array)) {
      finalOutput = array;
      return;
      } else if (array[i]

  • @977328176
    @977328176 2 ปีที่แล้ว

    accha bhai iska advance recursion ka Time complexity kya hoga

  • @hemantpandey4506
    @hemantpandey4506 ปีที่แล้ว

    Here explaination must be tweak with respect to :-
    if(isSorted(array)){ return array}
    here everything works properly bcz above condition will only works if isSorted returns true;
    Soln-
    Note: you just need to add return before sortArr(arr) i,e., calling inside func.
    //Recursion Example
    let myArr = [2,3,1,4];
    let i =0 ;
    let j = 1;
    function isSorted(arr){
    for(let i=0; i< arr.length; i++){
    if(arr[i]> arr[i+1]){
    return false;
    }
    }
    return true;
    }
    function sortArr(arr){
    if(isSorted(arr)){
    return arr;
    }
    if(arr[i] > arr[j]){
    let temp = arr[i];
    arr[i] =arr[j];
    arr[j] = temp;
    i=0;
    j=1;
    }else{
    i++;
    j++;
    }
    return sortArr(arr);
    }
    console.log("Sort It :)",sortArr(myArr));

  • @akshitagg1
    @akshitagg1 3 ปีที่แล้ว

    sir recursion ke through multiplication without using * samjhado agli video me

  • @creatorboy4901
    @creatorboy4901 4 หลายเดือนก่อน

    sir if array is already sorted decrement formate

  • @techpro338
    @techpro338 3 ปีที่แล้ว +1

    ❤️

  • @tasagaming5711
    @tasagaming5711 2 ปีที่แล้ว +1

    ya ap na apna banay han ya kisi sa sekha ha

  • @abdulkarimshaikh9648
    @abdulkarimshaikh9648 3 ปีที่แล้ว

    👏👏👏

  • @prabhatkeshari2976
    @prabhatkeshari2976 3 ปีที่แล้ว +1

    First viewer

  • @kumarsagarmaiti749
    @kumarsagarmaiti749 2 ปีที่แล้ว

    Sir maine ye likha hai par maximum call stack size exceeded dikha raha hai else condition pe.
    function sortNumbers(array) {
    if (isSorted(array)) {
    newList = array;
    return;
    } else if (array[i] < array[j]) {
    i++;
    j++;
    sortNumbers(array);
    } else {
    [array[i], array[j]] = [array[j], array[i]];
    i = 0;
    j = 1;
    sortNumbers(array);
    }
    }
    sortNumbers(arrayOfNumbers);
    console.log(newList);

    • @dishakansal8072
      @dishakansal8072 2 ปีที่แล้ว

      yes, i'am facing the same problem in this code

    • @chaayparcharcha
      @chaayparcharcha 5 หลายเดือนก่อน

      You must be checking it with duplicate value please update your code in if else ====> array[i]

  • @yuvrajbiswas9702
    @yuvrajbiswas9702 2 ปีที่แล้ว

    Bhaiyaa jii pehele to recursion ka naam sunkar hi dar lagta tha. par aap jab aise sikhaye to mera dar khatam ho gaya. ab se is recursion word se nahi darunga.

  • @akashsaha9366
    @akashsaha9366 3 ปีที่แล้ว

    Suneja vaiya. There is a loop hole in your code. Why it is returning undefined. If the checksorted is returning false then It should never enter in the loop.

    • @TechnicalSuneja
      @TechnicalSuneja  3 ปีที่แล้ว +1

      Video ke last me dekho mane proper reason btaya hai . 🙂

    • @akashsaha9366
      @akashsaha9366 3 ปีที่แล้ว

      @@TechnicalSuneja nehi bhaiya aap ne bola jab tak array sort nehi hoga tab tak wo undefined return karega. But loop hole ye hain ki jab tak array sort nehi hoga tab tak wo if wala condition me ghusna nehi chaiye and kuch nehi return karna chahiye.

    • @TechnicalSuneja
      @TechnicalSuneja  3 ปีที่แล้ว +1

      @@akashsaha9366 no issue.
      Iski next video me or ache samaj lenge 🙂👍

    • @akashsaha9366
      @akashsaha9366 3 ปีที่แล้ว

      @@TechnicalSuneja bhaiya samajh ne baat nehi jain. Bohot easy hain. But that concept is not wright fully.

    • @TechnicalSuneja
      @TechnicalSuneja  3 ปีที่แล้ว

      @@akashsaha9366 sure...mane socha mn code review ker hi leta hun..false return ho raha hai .. I know but ab function me dekho mane array return kerwaya tha na ki true or false isliye wo undefined de raha hai..or fir mane reason bhi btaya hai...16:00 se dekh sakte ho aap.. 🙂or one more thing if (true) hota hai by default agar upar se false ayega to wo direct else If me jayega . Kyuki if me humne direct function pass kiya hai(jo it's Boolean value de raha hai but yes in case of false wo else If me jayega ..) .Hope this will help. 🙂

  • @JaspreetSingh-pf1rq
    @JaspreetSingh-pf1rq 3 ปีที่แล้ว +1

    JavaScript solution:- without creating extra array
    let arr = [2,3,1,4,6,9,8,5]
    function sort(arr , i=0){
    if (i == arr.length)
    {
    return arr
    }
    if (arr[i]>arr[i+1])
    {
    let temp = arr[i]
    arr[i] = arr[i+1]
    arr[i+1] = temp
    return sort(arr, i=0);
    }
    else{
    return sort(arr, i+1);
    }
    }
    console.log(sort(arr))
    Python solution :-
    def sort_array(arr ,i=0):
    if i >= len(arr)-1:
    return arr
    if arr[i] > arr[i+1]:
    arr[i] , arr[i+1] = arr[i+1] , arr[i]
    return sort_array(arr , i=0)
    else:
    return sort_array(arr,i+1)

  • @tasagaming5711
    @tasagaming5711 2 ปีที่แล้ว +1

    IS MA ZADA NUMBER DALA TO KAM NAHI KAR RA

  • @trashtalker_tushar
    @trashtalker_tushar ปีที่แล้ว

    function sorter(para1){

    if(para1[i]para1[j]){
    [para1[i],para1[j]]=[para1[j],para1[i]]
    i=0
    j=1
    sorter(para1 )
    }
    else { return para1; }
    }
    sorter(arr)
    console.log(arr)

  • @thakurjaswantsingh148
    @thakurjaswantsingh148 3 ปีที่แล้ว

    package jaswant;
    public class Main {
    public static void main(String[] args) {
    int arr[]= {1,4,3,2,11};
    /* Expected output 1 2 3 4 11 */
    // sortUsingLoop(arr);
    sortUsingRecusion(arr);
    for (int i : arr) System.out.print(i+" ");

    }


    public static boolean isAleadySorted(int arr[]) {
    for (int i = 0; i < arr.length; i++) {
    if (arr[i]>arr[i+1]) {
    return false;
    }
    }
    return true;
    }

    //second way using recursion
    public static void sortUsingRecusion(int arr[]) {
    int i=0;
    int j=1;

    if (isAleadySorted(arr)) {
    return;
    }

    else if (arr[i] < arr[j]) {
    i++;
    j++;
    sortUsingRecusion(arr);
    } else {
    int swap=arr[i];
    arr[i]=arr[j];
    arr[j]=swap;
    i=0;
    j=1;
    sortUsingRecusion(arr);
    }

    }


    //first way using loops;
    public static void sortUsingLoop(int arr[]) {
    for (int i = 0; i < arr.length; i++) {
    for (int j = i+1; j < arr.length; j++) {
    if ( arr[i] > arr[j]) {
    int swap=arr[i];
    arr[i]=arr[j];
    arr[j]=swap;
    }
    }
    }
    }


    }

  • @mahuachanda7008
    @mahuachanda7008 ปีที่แล้ว

    Can anyone help me to understand why undefined is coming when we return array in the isSorted(array) function? @TechnicalSuneja

  • @neerajkumarrajpoot909
    @neerajkumarrajpoot909 ปีที่แล้ว

    👍