Infix Evaluation | Solution

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

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

  • @sayakatta1836
    @sayakatta1836 4 ปีที่แล้ว +48

    I literally just cried after understanding the logic,very smooth logic and very smooth code sir..

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว +11

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

    • @kanwarkajla
      @kanwarkajla 4 ปีที่แล้ว +5

      lol

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

    Jitni taarif ki jaye utni kam hai ! What an explanation. You are the best.Thanks.

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

      Glad to know that you liked the content and thank you for appreciating.
      The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
      So, keep motivating, keep learning and keep loving Pepcoding😊

  • @agamjain8976
    @agamjain8976 4 ปีที่แล้ว +16

    Sir ek feedback hai
    Apka content bhot acchaa hai
    Sb questions ka bhot bdiya explanation hai
    Bs sb question m ek kami lgti hai
    Aap jo code krate ho uski time complexity and space complexity kese nikale vo bhi analyse kra diya kre.
    Uske baad koi kami nhi bachegi.

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว +13

      hanji beta. agle saal sare questions ko redo karunga, tab karta chla jaunga.

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

    thanks , sir i spent whole day to solve this problem before I found your video , now i am clear about this problem.

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

    Best explanation of this problem so far 🙌

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

      Glad you think so! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @NavneetKumarSingh-xy1kt
    @NavneetKumarSingh-xy1kt 3 ปีที่แล้ว +1

    you r the best sir unfortunately got to know about ur channel a bit late but i got the best , thanku sir

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

    1st time apka video dekha
    Mast he video sir
    Well understood infix expression evaluation

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

    Legendary Explanation Of The Logic !!

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

    How your program will solve the expression "-2+1"?

  • @hey.mishaaa
    @hey.mishaaa 2 ปีที่แล้ว +2

    thank you sir for the wonderful explanation,always pro you are✨

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

      Glad you liked it!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

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

    Hello sir,
    mera, char optor = optors.pop(); line pe
    error: cannot initialize a variable of type 'char' with an rvalue of type 'void'
    dikhara he....kaise solve karu?

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

      brother cpp me pop() void return type ka hota h, so first top() use kro then bad me pop() use kro
      char optor = optors.top();
      optors.pop();

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

    amazing and best video course

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

    Excellent would be an understatement to say for this explanation!

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

      Glad that you love the explanation.
      For better experience & well organised content visit- nados.pepcoding.com
      Don't forget to follow us on Instagram. instagram.com/pepcoding

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

    It does not handle unary operator " -1 + 4" or " -4 * 2", please suggest the edit in code that can handle these cases too.

  • @jahnavic.h9299
    @jahnavic.h9299 2 ปีที่แล้ว

    Great Explanation!!!!!!!. Is there any video for infix evaluation for multiple digits ?

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

    There is one issue in this logic, let's say you are in the position where you get the operator and the previous item in the operator stack would not be the "(" (Closing bracket) and according your logic you get find the previous (peek) and check iterate them using while if peek have "(" then do the manupulation but if you not found then your program will fail. here is the example question:
    ((3+1)*2)

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

      No it will not be the case ..as expression is balanced and valid given in question. For ((3+1)*2) it will be working fine with o/p = 8

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

    Any more explaination can be better than this ♥♥♥

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

      Hope you like the video but for better experience and well-organised content
      visit - nados.pepcoding.com
      Don't forget to follow us on Instagram instagram.com/pepcoding/

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

    @Pepcoding - is this question asked in any company?

  • @ShubhamSingh-iq5kj
    @ShubhamSingh-iq5kj 2 ปีที่แล้ว

    What a beautiful code 🥳🥳

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

    sir pls provide also code of solution in description box. this can also add in description box sir

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

    Sir please provide video on implementation of stack using linked list with code in c language

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

      Java wala ye rha
      www.pepcoding.com/resources/online-java-foundation/linked-lists/linkedlist-to-stack-adapter-official/ojquestion
      C mei khud bnaie

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

      @@Pepcoding sir doubly linked list ka bhi milega ??

    • @AbhishekKumar-id2nt
      @AbhishekKumar-id2nt 4 ปีที่แล้ว +2

      @@ronaksharma5 DS and Algo is language independent, you just see the implementation in one language and you can itself write in any, just the matter of syntax. Mai bhi java me dekh ke c me likhta hu.

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

    Thanks for amazing explanation . whats the time comp. ?

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

    isn't it we need store result in double. for example 3 / 2 = 1. will cause type casting issue

  • @Karthik-kt24
    @Karthik-kt24 3 ปีที่แล้ว

    Thank you very much. understood in one go🙏

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

    i did on my own but i think with the same logic like you but instead of 2 i was managing the only one stack

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

    can we use the same logic for an expression with multiple-digit numbers ?

    • @sneha-qn4jn
      @sneha-qn4jn 2 ปีที่แล้ว

      no it won't work.

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

    Sir my right solution and even yours and editorial solution is not working on the new nados IDE please see that only 2 test cases are passing, Thank you for such nice explanations 🤟

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

      Glad to know, that you love the explanation, for better experience and precisely arranged videos.
      Visit - nados.pepcoding.com and sign up to NADOS.
      Don't forget to follow us on Instagram instagram.com/pepcoding/

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

    is this question available on leetcode

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

    Fabulous explanation brother! Thank you!

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

      Thank you so much Bhai. Keep learning, Keep growing and keep loving Pepcoding!😊

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

    absolute legend!

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

      Thankyou beta!
      I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem.

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

      @@Pepcoding yes sir, I understood it very well. Also implemented by myself. Thank you ❤️.

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

    Hii sir, i Think we also have to check the operator presedence when character is ')' and poping until '('
    i mean to say that between ( ) we also chcked the precedence of operator . right?

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

      yes we did check the the precedence even in the () it looks like we dont but we do for eg a + (c * d / e - f) here we check precedence until f and then we see the brackets ) so we dont have to evaluate again its already checked til f
      i know this is not the best explanation for sure dry run and then you will realise.

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

    sir ji me yahi code c++ me do din se bana raha hoon sala ek hi tc pass ho raha he !!! abi samaj me aayi galti apne jo tc die h apne editor me usme string me characters ke beech me spaces bi hi aur appne wo wali condition to handle ki hi nahi cpp me !!! right ???

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

      if you want the test cases, i can share them

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

      Hey bro for handling space while cin use getline.

    • @AbhishekKumar-id2nt
      @AbhishekKumar-id2nt 4 ปีที่แล้ว +3

      Bro, space wali condition handle karne ki jarurat hi nhi padi kyuki koi bhi default else nhi laga. sab *if* ke (else- if) block hai. To jab bhi space aa rha hai wo kisi bhi if statement ko true nhi kar paa rha to apne aap hi next iteration pe chala jaa rha hai, jaha usse koi, digit, bracket ya operator mil rha hai.

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

      can you pls share your code to me

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

      use
      getline(cin, str) for taking input

  • @DanishKhan-lh3ob
    @DanishKhan-lh3ob 3 ปีที่แล้ว

    awesome explanation!!!!!!!

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

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      th-cam.com/users/Pepcodingabout?view_as=subscriber

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

    sir this is wonderful

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

      Thanks a lot :) For more such content with a better user experience visit nados.pepcoding.com

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

    answer is not submitting showing server error

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

      PepCoding server is shut down.

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

      @@Pepcoding when it start sir ?

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

      shut down for ever.

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

      @@Pepcoding ok sir😞😓. thankyou for this wonderfull playlist.

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

      @@Pepcoding sir please open kijiye server firse

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

    Iss Code ko C language main kaise likh Sakte hain

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

    what if we just write
    import java.io.*;
    import java.util.*;
    class name
    {
    public static void main (String[]args )
    {
    int val= 2+(5-3*6/2);
    System.out.println(val);
    }
    }
    it will give the same output 😂😂.
    but thank u very mush sir , i started learning java & dsa from u only .

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

      For better experience, visit nados.io, where you will get well curated content and career opportunities.
      Also, on community tab you can post your doubts.

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

      Gajab Bhai 😂😂

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

      itna bdha code kese kr liaa bhai

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

    Same question asked in capgimini 6.8 lkhs ke liye but students can't solve this question

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

      If you like my efforts, I request a review
      g.page/Pepcoding/review?rc

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

      @@Pepcoding sir ker diya but capgimini me huwa nhi kyo ki maine ye pda nhi tha nhi ab sir ache se ata hai ager rat me need me puchnge to bhi dunga etna ache se explain kiya hai sir ek bat hai sari comepny sir questions sidhe repeat ker rhi hai sir

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

      @@farazahmad9734 bhai 1000 question ker lega to bhai sari company whi question puchti hai amezon also wo bnayenge thodi na question

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

    I just realised that this holds good for only single-digit integers. This fails for other cases.

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

      A very small change in filling of the operand stack will sort that when you are filling that stack just check whether next element is operator or operand if operator than push in stack else keep creating the number till you have found the operator or end of string.

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

      @@akshatgoyal9113 How would this be implemented? Please respond 🙏🏾

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

      ​@@temiariyibi8505 since a number if followed by a number would mean that say
      we keep creating the number till the operator is not coming and when operator is there we push operatolr in operator stack and start new counter for our next number.

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

    yes sir sun rhe han

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

    thanks

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

      Keep on learning.
      And for better experience and well organised content visit nados.pepcoding.com

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

    perfectooooooooooooooo
    aakhir 1 ghata lagaka ho hee gayyaa sawalll

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

      keep motivating, keep learning and keep loving Pepcoding😊

  • @56_shivanshrahangdale10
    @56_shivanshrahangdale10 3 ปีที่แล้ว

    answer is -2 . 😊

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

      Glad you liked it!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

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

    //Source Code:
    package com.soham.PrepCoding; //This line can be ignored
    import java.util.Scanner;
    import java.util.Stack;
    public class InfixEvaluation {
    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s= sc.nextLine();
    Stackoperands=new Stack();
    Stackoperator=new Stack();
    for (int i = 0; i < s.length(); i++) {
    char ch=s.charAt(i);
    if(ch=='('){
    operator.push(ch);
    }else if(Character.isDigit(ch)) {
    operands.push(ch - '0');
    }else if(ch==')'){
    while(operator.peek()!='('){
    char opr=operator.pop();
    int v2=operands.pop();
    int v1=operands.pop();
    int opVal= operation(v1,v2,opr);
    operands.push(opVal);
    }
    operator.pop();
    }else if(ch=='+' || ch=='-' || ch=='*' || ch=='/'){
    while(operator.size()>0 && operator.peek()!='(' && precedence(ch)

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

      For best experience and precisely arranged content visit on nados.io, even you can solve your doubts by posting it on community tab on NDAOS

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

      Im getting output 6/3-1 is 0

  • @sachintiwari-ye5sq
    @sachintiwari-ye5sq 2 ปีที่แล้ว

    How your program will solve the expression "-2+1"?