Infix to prefix conversion using stack

preview_player
Показать описание
#Infix to prefix conversion using stack

#Datastructure
#Infix
#prefix

Steps to convert infix expression to prefix

First, reverse the given infix expression.

Scan the characters one by one.

If the character is an operand, copy it to the prefix notation output.

If the character is a closing parenthesis, then push it to the stack.

If the character is an opening parenthesis, pop the elements in the stack until we find the corresponding closing parenthesis.

If the character scanned is an operator

If the operator has precedence greater than or equal to the top of the stack, push the operator to the stack.

If the operator has precedence lesser than the top of the stack, pop the operator and output it to the prefix notation output and then check the above condition again with the new top of the stack.

. After all the characters are scanned, reverse the prefix notation output.

#infixtoprefix #Datastructure

Our App:

1) Aptitude, Reasoning and verbal Quiz App

2)Interview questions and answers app

Social media platforms:

For advertisements:

For more videos, subscribe our channel and don't forget to click on bell icon....
Рекомендации по теме
Комментарии
Автор

-/* => isme /* sath me kese aa skte hai ??? Because we cant placed 2 operators with same precedence so / should be removed I think

shivamtomar
Автор

It's a gud video to understand infix. Well explained

shubhamprakash
Автор

Good explanation but question is hidden after few minutes of the video

manasuvittupesuyoutubechan
Автор

Aap Binod se bhi pyare ho sir
Thank you sir 😊

masihurrehman
Автор

Wow bhaiya very good explanation please do a meet up in kolkata...

souravsuman
visit shbcf.ru