 Today I am going to focus on problem solving on infix to prefix and infix to post-fix notations that is polished notations this is this topic is from discrete mathematical structures. The learning outcome of today's session student will be able to convert the given infix notation into prefix and he will be able to convert the given infix notation to post-fix notations. The contents I am going to cover in this video first of all I will explain what is the precedence of operator then I will focus on example how to convert the given infix expression to prefix and in the further slides I will explain how to convert the given infix to post-fix expression or notations. First of all let us understand the precedence of the operator. Now as we know that there are different types of operators are there we have studied various operators out of that the negation has got the highest priority then and is the next then or conditional and biconditional so in this five operators biconditional has got the least priority whereas the negation has got the highest priority and if suppose the formula has parenthesis then the innermost parenthesis will be evaluated first and in that again the same precedence of operator will be followed and then the outer and the outermost parenthesis will be evaluated for the particular formula. Now let us understand one example is given how the precedence of operator will take place. Okay here we see that p or into bracket there is no bracket actually p or q and r or s and t okay overall there are two operators are there r and and okay we know that and has got the highest priority and out of that and has two times and is appearing okay between q and r and s and t. Now how to resolve this problem which one should be evaluated first for that okay to resolve this okay to resolve this what we do we come to the left side of the formula okay now we will traverse from the left hand side okay whichever n comes first that is q and r so this will be evaluated first that is why it is written as 1. Then secondly s and t okay this comes and comes second okay so this will be evaluated second then r again two operators are same operator okay but in a formula twice the appearing. So that again we will resolve the same problem with the coming to the left hand side of the formula we will traverse from the left hand side whichever r comes first okay that will be evaluated first so this particular r will be evaluated first then this r will be evaluated at the end okay so the priority of this particular formula will be q and r first s and t second then the result of p or into first t1 and result of the entire this r will be evaluated. Let us focus on the problem over one the problem is q and p conditional q or r or s okay now brackets are there so first of all brackets has got the highest precedence okay so innermost bracket is what p conditional q okay the second bracket is r or s both are at the same level both are at the same level so the first p conditional q will be evaluated okay then second r or s will be evaluated and third the result of these two okay will be operated with r operation with operated with r operation okay so this is how the entire bracket is will be evaluated now let us see one by one say this is equation number one first of all convert this into prefix okay as we know that in infix notation operand operator and operand two okay p and q are the operands and conditional is a operator okay so operator will lie between two operands in prefix first of all operand will come followed by the two operands okay so let us convert first of all p conditional q into prefix so it is converted into conditional pq say it is equal to intermediate result t1 now put this t1 in the equation number one so that this will become t1 or in place of this p conditional q I have placed t1 intermediate result or this particular r or s will be written as it is in equation number two this is only one r is there okay then now next time this r or s will be evaluated r or s is equal to convert that into prefix that first of all operator r will come then the two operands r and s will appear in a prefix so this is say equal to t2 as a intermediate result second result okay now substitute this t2 substitute this t2 in the equation number two okay so that equation number one two will become now t1 or t2 t1 or t2 say that is equation number three now what we will do we will we will this is what equation number two okay put the value of t2 okay put the value of t2 in the equation number two t2 is what t2 is r r into bracket r s okay well before that this r okay t1 or t2 t1 or t2 will be converted into prefix that is converted or as r t1 t2 so this equation number four should be considered now equation number four should be considered and in this equation number four t1 and t2 should be substituted what is t1 is conditional pq and t2 is r p r s so if I substitute these values so this will become r conditional pq or r s okay so this is the required prefix notation this is the required prefix notation or will be written as it is t1 is nothing but conditional pq and t2 is nothing but r s so this is the prefix notation from the given infix notation let us go to the second problem okay consider the following expression and convert the following expression into prefix okay take a pause over here in the video and write down the answer the answer is answer is it is first of all p and q will be evaluated then r and s then negation r negation pq so finally it will be conditional and pq or r s now the same example okay that we have taken for the in the first previous slides okay now let us convert this same problem into post fix expression or it is also called as a suffix expression okay now in suffix what we do say this is equation number one suffix first of all the two operands followed by the operator okay so p conditional q will be evaluated first so convert that into suffix that is pq conditional say is equal to intermediate result t1 okay then put this t1 in the equation number one so that becomes t1 or r or s so this is equation number two only one r is there then r or s convert this into post fix that is r s or say this is result t2 so put this t2 in the equation number two so this will become t1 or t2 so this t1 or t2 should be converted into post fix that is t1 t2 or okay so that we will see in the next slide so t1 t2 or in the equation number four okay now we will substitute now what we will do we will substitute the values of t1 okay now what is the value of t1 t1 is what pq conditional pq conditional should be substituted in place of this t1 then r and s or okay this is what t2 okay that should be substituted over here and then the r connective the r connective will be placed as it is so the formula will be now after substituting this t1 and t2 values in equation number four this will become pq conditional pq conditional then this is what r s or r then r okay r s or then r should be should be the answer let us see what is the answer put this values of t1 and t2 in the equation one by one okay first of all for t1 we will put pq conditional okay pq conditional okay then for t2 for t2 what we will do this value of r s or r s or then r will be placed over here okay now if you look at this particular formula if you look at this particular formula this is this is the same formula okay whatever the formula was given to us okay so we have converted into this is a required post fix or suffix expression we have converted into in fix to prefix then in fix to post fix expression okay and we also we also can convert the given prefix to again back to in fix or this particular equation okay this particular equation okay say this equation can be converted back to in fix notation or this can be converted directly to prefix also or prefix can be converted into post fix also okay so all conversion are possible okay so this is what I wanted to explain and I hope you will be able to solve now how to convert the given formula in fix formula into prefix or the same formula can be converted into post fix expression so these are the references and I think you like the videos thank you very much have a good day.