{"id":"70ca4f43-9e1c-418d-acde-0e9ad911b30d","name":"Infix Conversions","description":"1. You are given an infix expression.\r\n2. You are required to convert it to postfix and print it.\r\n3. You are required to convert it to prefix and print it.","inputFormat":"Input is managed for you","outputFormat":"postfix\r\nprefix","constraints":"1. Expression is balanced\r\n2. The only operators used are +, -, *, /\r\n3. Opening and closing brackets - () - are used to impact precedence of operations\r\n4. + and - have equal precedence which is less than * and /. * and / also have equal precedence.\r\n5. In two operators of equal precedence give preference to the one on left.\r\n6. All operands are single digit numbers.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n\n\nusing namespace std;\n\nint main(){\n string str;\n getline(cin, str);\n \n // write your code here\n \n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n \r\n\r\npublic static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n String exp = br.readLine();\r\n\r\n // code\r\n }\r\n}"},"python":{"code":"def infix(exp):\n # write your code here\n\n\n\nexp = list(input()) # taking i/p from user in list['ch']\n\ninfix(exp)"}},"points":10,"difficulty":"easy","sampleInput":"a*(b-c+d)/e","sampleOutput":"abc-d+*e/\r\n/*a+-bcde","questionVideo":"https://www.youtube.com/embed/Nfui0rgbQe8","hints":[],"associated":[{"id":"c1da3c63-7b6e-41d2-a09d-5f1924e984f3","name":"Which of the following Data Structure is used in this problem?(Q- Infix Evaluation)","slug":"which-of-the-following-data-structure-is-used-in-this-problem-q-infix-evaluation","type":4},{"id":"c665f01a-b5e8-44a0-84eb-9ce388ece817","name":"What will be the data type of the two Stack used in this question?(Q- Infix Evaluation)","slug":"what-will-be-the-data-type-of-the-two-stack-used-in-this-question-q-infix-evaluation","type":4},{"id":"ede87d2c-d5c7-4da7-a400-78aea6d988cc","name":"Which operator has the highest preference?(Q- Infix Evaluation)","slug":"which-operator-has-the-highest-preference-q-infix-evaluation","type":4},{"id":"fbf9c9df-d729-41ed-b234-ae6bbc2bc7ed","name":"How many Stack are required in this question?(Q- Infix Evaluation)","slug":"how-many-stack-are-required-in-this-question-q-infix-evaluation","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"82f329e7-6b26-4f02-a76e-4096b34744f4","name":"Infix Conversions","slug":"infix-conversions","type":1}],"next":{"id":"0e46d6d0-c03c-46fa-873e-693f2916724b","name":"Infix Conversions","type":3,"slug":"infix-conversions"},"prev":{"id":"4a22aa10-db4b-4120-8e5c-95bf39f5c737","name":"Infix Evaluation","type":3,"slug":"infix-evaluation"}}}

Infix Conversions

1. You are given an infix expression. 2. You are required to convert it to postfix and print it. 3. You are required to convert it to prefix and print it.

{"id":"70ca4f43-9e1c-418d-acde-0e9ad911b30d","name":"Infix Conversions","description":"1. You are given an infix expression.\r\n2. You are required to convert it to postfix and print it.\r\n3. You are required to convert it to prefix and print it.","inputFormat":"Input is managed for you","outputFormat":"postfix\r\nprefix","constraints":"1. Expression is balanced\r\n2. The only operators used are +, -, *, /\r\n3. Opening and closing brackets - () - are used to impact precedence of operations\r\n4. + and - have equal precedence which is less than * and /. * and / also have equal precedence.\r\n5. In two operators of equal precedence give preference to the one on left.\r\n6. All operands are single digit numbers.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n\n\nusing namespace std;\n\nint main(){\n string str;\n getline(cin, str);\n \n // write your code here\n \n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n \r\n\r\npublic static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n String exp = br.readLine();\r\n\r\n // code\r\n }\r\n}"},"python":{"code":"def infix(exp):\n # write your code here\n\n\n\nexp = list(input()) # taking i/p from user in list['ch']\n\ninfix(exp)"}},"points":10,"difficulty":"easy","sampleInput":"a*(b-c+d)/e","sampleOutput":"abc-d+*e/\r\n/*a+-bcde","questionVideo":"https://www.youtube.com/embed/Nfui0rgbQe8","hints":[],"associated":[{"id":"c1da3c63-7b6e-41d2-a09d-5f1924e984f3","name":"Which of the following Data Structure is used in this problem?(Q- Infix Evaluation)","slug":"which-of-the-following-data-structure-is-used-in-this-problem-q-infix-evaluation","type":4},{"id":"c665f01a-b5e8-44a0-84eb-9ce388ece817","name":"What will be the data type of the two Stack used in this question?(Q- Infix Evaluation)","slug":"what-will-be-the-data-type-of-the-two-stack-used-in-this-question-q-infix-evaluation","type":4},{"id":"ede87d2c-d5c7-4da7-a400-78aea6d988cc","name":"Which operator has the highest preference?(Q- Infix Evaluation)","slug":"which-operator-has-the-highest-preference-q-infix-evaluation","type":4},{"id":"fbf9c9df-d729-41ed-b234-ae6bbc2bc7ed","name":"How many Stack are required in this question?(Q- Infix Evaluation)","slug":"how-many-stack-are-required-in-this-question-q-infix-evaluation","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"9847c2b3-e3ad-4b1c-97d1-00206b1be68d","name":"Stacks And Queues For Beginners","slug":"stacks-and-queues-for-beginners","type":0},{"id":"82f329e7-6b26-4f02-a76e-4096b34744f4","name":"Infix Conversions","slug":"infix-conversions","type":1}],"next":{"id":"0e46d6d0-c03c-46fa-873e-693f2916724b","name":"Infix Conversions","type":3,"slug":"infix-conversions"},"prev":{"id":"4a22aa10-db4b-4120-8e5c-95bf39f5c737","name":"Infix Evaluation","type":3,"slug":"infix-evaluation"}}}
plane

Editor


Loading...

Infix Conversions

easy

1. You are given an infix expression. 2. You are required to convert it to postfix and print it. 3. You are required to convert it to prefix and print it.

Constraints

1. Expression is balanced 2. The only operators used are +, -, *, / 3. Opening and closing brackets - () - are used to impact precedence of operations 4. + and - have equal precedence which is less than * and /. * and / also have equal precedence. 5. In two operators of equal precedence give preference to the one on left. 6. All operands are single digit numbers.

Format

Input

Input is managed for you

Output

postfix prefix

Example

Sample Input

a*(b-c+d)/e

Sample Output

abc-d+*e/ /*a+-bcde

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode