Infix to Postfix using stack

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

  • @ThePalkiaTrainer
    @ThePalkiaTrainer 5 ปีที่แล้ว +397

    6 years after this video has been published , still it saves engineering students

    • @CorporateGamer
      @CorporateGamer 4 ปีที่แล้ว +19

      @walkman 12/June/2020 computer science student saved!

    • @johnvick8861
      @johnvick8861 4 ปีที่แล้ว +7

      True m alive

    • @aadershchaubey1399
      @aadershchaubey1399 4 ปีที่แล้ว

      @walkman who was killing you in lockdown

    • @aadershchaubey1399
      @aadershchaubey1399 4 ปีที่แล้ว +2

      @@CorporateGamer who was killing you in lockdown

    • @aakashgoswami2356
      @aakashgoswami2356 4 ปีที่แล้ว +1

      31 Dec 2020 , another engineering student saved |

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

    The real beauty of the video starts around the 12 minute mark with the parentheses. I couldn't, for the life of me, find a way to work with parentheses, but when he did his excellent job explaining it I was finally able to work it out.

  • @AbhishekRavalfuntwixt
    @AbhishekRavalfuntwixt 10 ปีที่แล้ว +82

    i just wonder , if you wouldn't have made this videos , then i would have been literally ended up just cramming the stack , que ,etc from any local author! but the flow of your explanation is indeed dulcet ! thanx a lot for employing your time to help students like us !

  • @gabrielferrin
    @gabrielferrin 7 ปีที่แล้ว +43

    Congratulations on your videos. I'm studying in an university and your videos are much easier to understand. Thumbs up!

  • @AmiraFahad-us7bf
    @AmiraFahad-us7bf 2 หลายเดือนก่อน +2

    Its 10 years and it still save lives

  • @dipanshusomeshwar
    @dipanshusomeshwar 7 ปีที่แล้ว +363

    For those who disliked, you can not get better then this.

    • @rajenkumar6212
      @rajenkumar6212 7 ปีที่แล้ว +5

      Dipanshu Someshwar
      Are you getting the solution... subtitle is distributing it is at wrong location

    • @AshwiniSingh27
      @AshwiniSingh27 6 ปีที่แล้ว +15

      than*
      .............

    • @mbogniruvic9796
      @mbogniruvic9796 6 ปีที่แล้ว +1

      I agree with you

    • @abhishek-solutions-website
      @abhishek-solutions-website 5 ปีที่แล้ว +15

      true, but people dont value free things, they will like half this quality if they have to pay a hefty fee for it, and regarding location of subtitles, one can just switch them off if they distract...

    • @saireddybonthu985
      @saireddybonthu985 5 ปีที่แล้ว +1

      At 9:21
      In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration

  • @petarkovachovski
    @petarkovachovski 4 ปีที่แล้ว +64

    Just to note, combining this lesson with the previous lesson you can make a working calculator.

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

      what previous video

  • @Илья-щ6й2я
    @Илья-щ6й2я ปีที่แล้ว +1

    duude such a great clear explanation, still helpfull 9 years later, thanks a lot 👍

  • @kajal091s
    @kajal091s 6 ปีที่แล้ว +28

    You just saved me from jumping off a building.
    Thanks mate.

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

      people jumping off cuz they didn't understood a topic,awesome

  • @alceguy
    @alceguy 4 ปีที่แล้ว

    By far the best infix/prefix/postfix series on TH-cam

  • @aviralagarwal5871
    @aviralagarwal5871 5 ปีที่แล้ว

    I am speechless by your understanding of data structures , so clean apt and to the point , a huge thank you really

  • @yeniaraserol
    @yeniaraserol 5 ปีที่แล้ว +1

    @mycodeschool, please make more videos! I haven't seen a better explanation to this conversion. By far the best!

    • @saireddybonthu985
      @saireddybonthu985 5 ปีที่แล้ว

      At 9:21
      In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration

    • @siddharthmagadum16
      @siddharthmagadum16 4 ปีที่แล้ว

      @@saireddybonthu985 That case is handeled at the last else condition where we append all teh leftover operators to the string form the stack.

  • @debadiptobiswas5611
    @debadiptobiswas5611 5 ปีที่แล้ว +117

    the USA hav Stanford
    India has mycodeschool

    • @rjk368
      @rjk368 5 ปีที่แล้ว +25

      But, thankfully, the whole world has mycodeschool!

  • @徐宏杰-i6w
    @徐宏杰-i6w 6 ปีที่แล้ว

    omg,teacher,you are so much better than my professor,i become more confident after seeing your videos

  • @shubhamk840
    @shubhamk840 5 ปีที่แล้ว

    intelligence of the guy teaching is very well visible through his lectures

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

    You are doing the Lord's work, even in 2021

  • @danielokeefe8130
    @danielokeefe8130 10 ปีที่แล้ว +13

    Thanks. This was a terrific explanation of the conversion.

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

    This lesson is going to live forever helping future students! Thanks.

  • @Shivamyadav-xb7vg
    @Shivamyadav-xb7vg 5 ปีที่แล้ว +2

    Thank u Sir, my school teacher just made me to cram this, nut now i really understand the concept.
    MAY GOD BLESS YOU..

  • @SizzlerWA
    @SizzlerWA 5 ปีที่แล้ว +1

    Well done! This is the clearest explanation of this topic that I have ever seen. Thanks so much for sharing.

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

    these videos are GOAT on data structures

  • @amanvijayvargiya3468
    @amanvijayvargiya3468 4 ปีที่แล้ว

    this video was uploaded on 2013 but still in 2020 this is the best explanation

  • @abhigyanraha5620
    @abhigyanraha5620 5 ปีที่แล้ว +1

    Clear, crisp, precise and concise. You and your content are amazing! Thanks!

  • @vkhanhvy8330
    @vkhanhvy8330 9 ปีที่แล้ว +10

    Thank you! This lesson was very clear and easy to understand.

  • @jayjagtap7873
    @jayjagtap7873 5 ปีที่แล้ว +6

    RIP Sir, You are not with us but your legacy will live forever.

    • @antojosu
      @antojosu 5 ปีที่แล้ว

      @@zuhail339 what happened how??

    • @gigachadkartik
      @gigachadkartik 5 ปีที่แล้ว

      What??? Did he die????? how????

    • @MohamedHossam-in1yn
      @MohamedHossam-in1yn 4 ปีที่แล้ว +1

      @@antojosu That's his friend (the co-founder of this channel) not him

    • @antojosu
      @antojosu 4 ปีที่แล้ว

      @@MohamedHossam-in1yn Oh

  • @lambdalearner7670
    @lambdalearner7670 5 ปีที่แล้ว +1

    even in 2019 your maths is still appreciated. THANK YOU !!

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

    mycodeschool has the best videos on DS and Algo in the entire youtube (or even Internet as whole)

  • @oneeyedeagle549
    @oneeyedeagle549 4 ปีที่แล้ว +2

    I remember watching this video when I was in 11th and now I am watching this again in my second year . DAMN

  • @AdarshSingh-gx7si
    @AdarshSingh-gx7si 4 ปีที่แล้ว

    simple and outstanding ,cant have better videos on infix and postfix than this.

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

    Best explanation ever STILL 🙏🙏🙏

  • @mrinaldhawan3959
    @mrinaldhawan3959 7 ปีที่แล้ว

    Great Explanation man. Everything explained in one video concisely!

  • @harshverma5873
    @harshverma5873 4 ปีที่แล้ว

    Such a quality content!!! ❤️... Undoubtedly it deserves more views and likes!

  • @prasannakumarz
    @prasannakumarz 5 ปีที่แล้ว

    wow..! what an explanation it is! Really great.if this video doesn't exist i might have left stack topic for sure.

  • @madhav3444
    @madhav3444 4 ปีที่แล้ว

    How someone can dislike these gem videos

  • @shriyasingh1542
    @shriyasingh1542 7 ปีที่แล้ว

    perfect explanation...one more thing your voice is just awesome sir...

  • @channelname9468
    @channelname9468 7 หลายเดือนก่อน

    Great video, random indian guy always comes in clutch 😤😤😤😤

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

    24/03/22 and it still saved me

  • @xUnic31x
    @xUnic31x 4 ปีที่แล้ว

    I understand what to do with my project now. Thank you for explaining it well!

  • @zeke2161
    @zeke2161 6 ปีที่แล้ว

    Excellent video, couldn’t ask for a better explanation!

  • @simplymade7802
    @simplymade7802 6 ปีที่แล้ว +4

    I like yr accent... really very helpfull...
    Thanku soo mch sir..for yr valuable time....

  • @zahirjacobs716
    @zahirjacobs716 7 ปีที่แล้ว

    I needed to brush on this stuff recently, thank you so much for posting this clear example.

  • @kdineshreddy3254
    @kdineshreddy3254 6 ปีที่แล้ว

    @ 7:42 what it mean? there r 2 ways in which we can find the end of the right operand for an operator a)If we get an operatoer of lesser precedence

  • @fahadhassan8749
    @fahadhassan8749 5 ปีที่แล้ว +1

    these are quite difficult but you made them easier for all of us !! Thanks for such kind effort but I'm still struggling with this algorithm since morning.Somehow my mind is muffed :(

  • @OliverJoshuaJacob
    @OliverJoshuaJacob 9 ปีที่แล้ว

    Your videos are worth Watching. Thanks for uploading them.

  • @iosonoi.7132
    @iosonoi.7132 6 ปีที่แล้ว

    This is the best video for infix to postfix

  • @aakstatic
    @aakstatic 4 ปีที่แล้ว

    no one can teach better than this!!!

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

    2024 - still the best tutorial for infix to postfix
    Like if you agree ❤

  • @alanalmeida7887
    @alanalmeida7887 4 ปีที่แล้ว +2

    R.I.P! Your videos will survive

  • @ahmedboukhousse1152
    @ahmedboukhousse1152 5 ปีที่แล้ว

    Excellent explanation ----> 5 STARS

  • @prasannakumar6008
    @prasannakumar6008 10 ปีที่แล้ว

    Stupendous explanation and great illustration

  • @muneebshahid5833
    @muneebshahid5833 10 ปีที่แล้ว

    very nicely and smoothly explained.Thanks

  • @manasadeevi3275
    @manasadeevi3275 10 ปีที่แล้ว

    thank u sir for making my exam more simplest

  • @Frook10yty
    @Frook10yty 10 ปีที่แล้ว +4

    This is really helpful! Great explanation.
    Thanks a lot.

  • @samikshadutta2536
    @samikshadutta2536 4 ปีที่แล้ว

    pseudocode was very tough nd explained so quickly..however logical view was gud

  • @abocidejofa9686
    @abocidejofa9686 11 ปีที่แล้ว

    you are simply the best at explaining!!!! thank you

  • @satyampandey5584
    @satyampandey5584 5 ปีที่แล้ว +1

    here is the correct code in c++ :
    /*
    Infix to postfix conversion in C++
    Input Postfix expression must be in a desired format.
    Operands and operator, both must be single character.
    Only '+' , '-' , '*', '/' and '$' (for exponentiation) operators are expected.
    */
    #include
    #include
    #include
    using namespace std;
    // Function to convert Infix expression to postfix
    string InfixToPostfix(string expression);
    // Function to verify whether an operator has higher precedence over other
    bool HasHigherPrecedence(char op1, char op2);
    // Function to verify whether a character is operator symbol or not.
    bool IsOperator(char C);
    // Function to verify whether a character is alphanumeric chanaracter (letter or numeric digit) or not.
    bool IsOperand(char C);
    int main()
    {
    string expression;
    cout

  • @Amar-fun-vlogs
    @Amar-fun-vlogs 3 ปีที่แล้ว

    2014 Passed out, still remembered

  • @kausachan4167
    @kausachan4167 4 ปีที่แล้ว +1

    working c code:
    #include
    #include
    #include
    struct stack
    {
    char data;
    struct stack *link;
    };
    struct stack *top=NULL;
    void push(char x)
    {
    struct stack *temp=(struct stack*)malloc(sizeof(struct stack));
    temp->data=x;
    temp->link=NULL;
    temp->link=top;
    top=temp;
    }
    void pop()
    {
    if(top==NULL) return;
    struct stack *temp=top;
    top=top->link;
    free(temp);
    }
    char top1()
    {
    if(top==NULL) return 0;
    return top->data;
    }
    int isoperand(char c)
    {
    if(c>=65 && c0)
    {
    if(topprior(top1(),A[i])>0)
    {
    while(top!=NULL)
    {
    arr[j++]=top1(); pop();
    }
    }
    push(A[i]);
    }
    }
    while(top!=NULL)
    {
    arr[j++]=top1(); pop();
    }
    printf("Postfix:%s",arr);
    }
    void main()
    {
    char arr[100];
    printf("Infix:");
    int n; scanf("%s",arr);
    n=strlen(arr);
    compute(arr,n);
    }

  • @mbogniruvic9796
    @mbogniruvic9796 6 ปีที่แล้ว

    Really nice work the best I've found I can now start with my project Thank you

  • @KanagaveluSugumar
    @KanagaveluSugumar 8 ปีที่แล้ว

    Wow!! Really awesome explanation :) Lots of thanks!

  • @saisrisai9649
    @saisrisai9649 6 ปีที่แล้ว

    Omg I now understand hurray! All credits to u sir 😊

  • @EyadMohammedOsama
    @EyadMohammedOsama 7 ปีที่แล้ว +5

    thanks sir...i wish you were my professor

  • @noraamer3666
    @noraamer3666 8 ปีที่แล้ว

    Thanks a lo0Oo0Oo0Oo0Oo0Oo0Oo0Ot for your great videos :)
    Note: breaks are missed in switch case in GetOperatorWeight function which leads to ignoring arithmetic precedence - Because returned weight will be 3 in the all cases -

  • @arbitrarii
    @arbitrarii 9 ปีที่แล้ว +1

    I was working on figuring out what I did wrong after following this. Make sure your hasHigherPrecidence returns true if they are equal. Took me a while to figure out

    • @moreorless6523
      @moreorless6523 8 ปีที่แล้ว

      +GBpackerfan95 will only work with operators of left to right associativity but will produce incorrect results for operators that are right to left associativity: exponents. test it with x ^ y ^ z w/c should produce x y z ^ ^.

  • @surajchavan1000
    @surajchavan1000 10 ปีที่แล้ว

    easy to understand nd hard to 4gt....awsmmm xplaintn :)

  • @anpiobaire8943
    @anpiobaire8943 6 ปีที่แล้ว

    Most excellent teaching. Thank you.

  • @guoweili9367
    @guoweili9367 5 ปีที่แล้ว

    Well explained, saved my due day! Thank you!

  • @sawyermcbride1522
    @sawyermcbride1522 9 ปีที่แล้ว

    thanks my man!! This is super clear your a great teacher!

  • @inter-
    @inter- 6 ปีที่แล้ว

    big thanks, this has helped me so much in short amount of time!

  • @shamofengbao
    @shamofengbao 7 ปีที่แล้ว

    GREAT! now my code works! THANK YOU!

    • @shamofengbao
      @shamofengbao 7 ปีที่แล้ว

      different from how i did it, but your explanation has clarified and helped me successfully debug!

  • @Zoonice
    @Zoonice 5 ปีที่แล้ว

    Thank you for this awesome and straight forward video!

  • @technowilliams480
    @technowilliams480 7 ปีที่แล้ว +1

    thank you bro your a real life saver

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

    thnx for uploading such video. very helpful

  • @mr-shady
    @mr-shady 9 ปีที่แล้ว

    Super understandable! Thanks, this video really helped me with my project :).

  • @nouru6856
    @nouru6856 7 ปีที่แล้ว

    You're the best Dude!!! Keep up

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

    Best video for explanation :)

  • @ravishankarsabhajityadav9187
    @ravishankarsabhajityadav9187 5 ปีที่แล้ว

    I was stucked with DS and you are boon for me

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

    great explanation as always .... Lots of thanks for your videos.

  • @pavankmv
    @pavankmv 10 ปีที่แล้ว

    At 10:04 the code says ..
    If s.top() has higher precendence than exp[i], then it has to enter into while loop. So, why '+' is popped out from stack even though + and - have same priority?

    • @fengshirley3016
      @fengshirley3016 10 ปีที่แล้ว

      *****
      I agree with you.
      The code in this vedio would get the postfix as '3 2 1 + -'.
      However, manually conversion result should be ' 3 2 - 1 +'.
      Please correct if there's any mistake of my understood.

    • @sm.i.t
      @sm.i.t 6 ปีที่แล้ว

      that because the precedence(+,-) is same and when that happens, rightmost value would have the highest precedence as the code is executed from right to left. so precedence would return true.

  • @GAMINGLORDS398
    @GAMINGLORDS398 10 ปีที่แล้ว

    its very clear. its easy to understand. Thanks

  • @jonidaalimadhi7371
    @jonidaalimadhi7371 9 ปีที่แล้ว

    Found it really helpful!! Thank you :)

  • @nightfuryacoustic2954
    @nightfuryacoustic2954 5 ปีที่แล้ว

    Thank you so much from Vietnam

  • @ahmadziasayeedy8186
    @ahmadziasayeedy8186 8 ปีที่แล้ว

    Thanks a lot for your great and helpfull vedios

  • @cassj7
    @cassj7 4 ปีที่แล้ว

    Thank you! I really understand this now!

  • @HenryDarnell
    @HenryDarnell 10 ปีที่แล้ว

    Excellent lecture, thanks so much

  • @mukarramhaq3663
    @mukarramhaq3663 4 ปีที่แล้ว

    Who's still watching this masterpiece in 2020?

  • @friend1310
    @friend1310 9 ปีที่แล้ว +5

    Hello, are you sure the code is correct? Let's say the infix exp is A+B*C-D*E. When postfix is ABC and we have +* in stack and exp[i] = -, then I think the condition (!s.empty() && HasHigherPrec(s.top(), exp[i])) in the while loop will prevent + from being appended to the postfix expression. I think the reason is when you append *, then the condition is validated again and + in stack will not have higher precedence than exp[i] = -. Can somebody please confirm if I am correct or not. Thanks.

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

      it should be like if we have the same preference then also it will be popped as it is coming for associativity as from left to right.

    • @SreeragNairisawesome
      @SreeragNairisawesome 7 ปีที่แล้ว

      Exactly..... we can use a flag which checks if the current operator is of lower precedence than the top of the stack. If it is , then just keep popping till the stack is empty and push the current operator in the stack

    • @piotrm587
      @piotrm587 7 ปีที่แล้ว

      agree, the solution for that issue is to check whether the operator has !LOWER(negation) precedence or HIGHER_EQUAL.

    • @luoyumo9492
      @luoyumo9492 6 ปีที่แล้ว

      Yes,i have the same question as you.You can see the Dipanshu Someshwar's comment above you.In the java code (about line 51)." (precedenceLevel(exp.charAt(i))

  • @sadhusundardas2079
    @sadhusundardas2079 9 ปีที่แล้ว +4

    Sir I dont understand . plz explain - if(op == "$") . in your code ...

  • @HeyThereGuy
    @HeyThereGuy 4 ปีที่แล้ว

    Subscribed. Great video.

  • @nju415
    @nju415 7 ปีที่แล้ว +1

    Really clearly explained

  • @rohithmanda7348
    @rohithmanda7348 8 ปีที่แล้ว +1

    amazing video !! good explanation..

  • @Morning92StarX
    @Morning92StarX 10 ปีที่แล้ว

    Nice one, clearly stated everything

  • @saireddybonthu985
    @saireddybonthu985 5 ปีที่แล้ว

    At 9:21
    In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration

    • @Drwildy
      @Drwildy 5 ปีที่แล้ว

      Since we are doing Postfix, operators(+,-,*,/) will come after operands(numbers) if it is valid. For example, If you have *+-456 you will start the for loop. Since exp[0] is an operator (* in this case) you enter the else statement. Currently the stack is empty so it will exit. If you had a valid scenario 45*, for exp[0] and exp[1] you will enter the numbers on the stack and when you hit the operator the stack won't be empty.

  • @smanipasu
    @smanipasu 5 ปีที่แล้ว

    really i have understood how to convert infix to postfix.

  • @rameshsake3953
    @rameshsake3953 8 ปีที่แล้ว

    Really Awesome Video its helped a lot thanx :-)

  • @seathroma2290
    @seathroma2290 10 ปีที่แล้ว

    Thanks for clearing my confusion

  • @abhinavbatra8557
    @abhinavbatra8557 9 ปีที่แล้ว

    very good explanation.

  • @sagardafle
    @sagardafle 7 ปีที่แล้ว

    Well Explained!
    Thank you sir :)

  • @NaomiMisora1000
    @NaomiMisora1000 9 ปีที่แล้ว

    Thank you so much! This is very useful.

  • @vallimayilnsit5013
    @vallimayilnsit5013 5 ปีที่แล้ว

    very easy to understand,thank you