Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# Homework 2: From Infix to Postfix Expressions Submiesion instructions cargo ne

ID: 3603546 • Letter: #

Question

# Homework 2: From Infix to Postfix Expressions Submiesion instructions cargo new 2 name your ed 2 Save your program in src/lib.rs git add Cargo.toml erc/lib.re git commit git remote add origin metastasis@gradebot.org:user/username)1/2 git pueh origin master Because postfix expreesione are simpler and faster to evaluate, compilere transform infix expressions in source programe to postfix expressions in executable programs. You will implement this transformation ** Infix expressions An infix expression contains one or more of the following tokens: * operands; integers, such as 1,-23°. * Operators: arithmetic operators-+ , , and with their normal association and Left and right parentheses A valid infix expression must satisfy all the following rules: *An operand or left parentheaia cannot be preceded by an operand or right parentheeis An operator or right parenthesis annot *be the firat token in the expression, or be preceded by an operator or left parentheais *An operator or left parentheie cannot be the last token in the expreasion Each left parenthesis must match a unique right parenthesis, and vice versa Tranaform infix to postfix e expresa1on 1. Create a etack 2. Scan the tokens in the infix expression If the token is an operand, output it If the token is a left parenthesie, push it onto the etac!k If the token ia a right parentheais, pop and output all the operators from the stack until encountering a left parenthesis. Pop and diacard the left parenthesis If the token is an operator If the tack is empty, push the token onto the tack otherwise, if the top of the stack is an operator and its precedence ia greater than or egual to the precedence of the token, pop and output the operator from the atack, and repeat this process. Finall y, push the token in the in Eix expression onto the stack

Explanation / Answer

| 11 | let URL = match Url::parse(matches.value_of("URL")) { | ^^^^^^^^^^^^^^^^^^^^^^^ expected &str, found enum `std::option::Option` | = note: expected type `&str` found type `std::option::Option` = help: here are some functions which might fulfill your needs: - .unwrap() - .unwrap_or_default() error: aborting due to previous error error: Could not compile `example_project`. To learn more, run the command again with --verbose.