Just keep the "YourName" portion of it assignment as "YourName", I will change it later.
CIS 26 Assignment CIS 27 Fall 2020 – Homework #5 Update #4 – Page 1 of 10 Turn In: 1. Exercise #1 – Due on Tuesday, November 24, 2020 by 11:00pm Email Submission a) For the assignment, a package must be generated to include the following items: - Copy of your source file (C program)—your source file MUST BE NAMED as cis27Fall2020YourNameHw5.c - Copy of output (copy and paste to the end of your program as PROGRAM_OUTPUT comment block) - Copy of Logic_Code_Output_Issues (as a separate comment block) after the “PROGRAM_OUTPUT” block. b) Emailing each package as follows, - One email message for each exercise. - The SUBJECT line of the message should have the following line: cis27Fall2020YourNameHw5.c - Attaching the source file that was created in part a). 2. Q.E.D. ***************************************************************************** CIS 27 Fall 2020 – Homework #5 Update #4 – Page 2 of 10 1. Coding Assignment Exercise #1 1. Write a menu program to have the display below, CIS 27 – Data Structures Laney College YourName Information – Assignment: HW #4 Exercise #1 Implemented by: YourName Submitted Date: 2020/10/20 Current Number of LEB available: ? Allowed Number of LEB Used: ? Remaining Number of LEB: ? 2. You are going to work with polynomials that have fraction as coefficients and integers as powers/exponents. The polynomials will be created as linked lists with the information and specifications given below (you should attach YourName at the ends of the structures and functions below). // From HW #4 — Types // Types and various typedef struct Fraction { int num; int denom; }; typedef struct Fraction TFraction; typedef struct Fraction* TFractionPtr; struct PolyTerm { int expo; TFractionPtr coeff; }; typedef struct PolyTerm TPolyTerm; typedef struct PolyTerm* TPolyTermPtr; struct PolyNode { TPolyTermPtr data; struct PolyNode* next; }; typedef struct PolyNode TPolyNode; typedef struct PolyNode* TPolyNodePtr; //Additional typedef’s typedef struct PolyNode* TPolyNodeAddr; typedef struct PolyNode* TPolyList; typedef struct PolyNode** TPolyListHeadAddr; // Function Prototypes TPolyNode* createPolyNode(void); TPolyNodePtr addPoly(TPolyNode*, TPolyNode*); TPolyNodePtr multiplyPoly(TPolyNode*, TPolyNode*); CIS 27 Fall 2020 – Homework #5 Update #4 – Page 3 of 10 And for HW #5, newly defined types and typedef’s struct Fraction { int num; int denom; }; typedef struct Fraction TFraction; typedef struct Fraction* TFractionPtr; union ExprTerm { TFractionPtr operandPtr; char* opPtr; }; struct ExpressionTerm { TFractionPtr operandPtr; char* opPtr; }; typedef struct ExpressionTerm TExprTerm; typedef struct ExpressionTerm TExprTerm; typedef TExprTerm* TExprTermAddr; typedef TExprTerm* TExprTermPtr; struct ExpressionListNode { TExprTermAddr termAddr; struct ExpressionListNode* next; }; typedef struct ExpressionListNode TExprNode; typedef struct ExpressionListNode* TExprNodeAddr; typedef struct ExpressionListNode* TExprNodePtr; typedef struct ExpressionListNode* TExprList; typedef TExprList* ExprListAddr; struct OpStack { // To Be Discussed and Defined }; typedef struct OpStack TOpStack; ??? popOpStack(???); // WILL BE IMPLEMENTED ??? pushOpStack(???); // WILL BE IMPLEMENTED 3. And, you are supposed to have worked on previous supportive functions to create polynomials as well as the expressions. Using the above (and other) definitions, functions, and setups, you should have implemented a function named as createInfix() and a conversion function named as convertInfixToPostfix() as described below. The function will have the prototype as follows, // WILL BE IMPLEMENTED TExprList createInfix(void); CIS 27 Fall 2020 – Homework #5 Update #4 – Page 4 of 10 TExprList convertInfixToPostfix(TExprList infixExpr); TFractionPtr evaluateInfix(TExprList infixExpr); TFractionPtr evaluatePostfix(TExprList postfixExpr); A sample hint (from Wikipedia.org) – Example The infix expression "5 + ((1 + 2) * 4) − 3" can be written down like this in RPN: 5 1 2 + 4 * + 3 - The expression is evaluated left-to-right, with the inputs interpreted as shown in the following table (the Stack is the list of values that the algorithm is "keeping track of" after the Operation given in the middle column has taken place): Input Operation Stack Comment 5 Push value 5 1 Push value 1 5 2 Push value 2 1 5 + Add 3 5 Pop two values (1, 2) and push result (3) 4 Push value 4 3 5 * Multiply 12 5 Pop two values (3, 4) and push result (12) + Add 17 Pop two values (5, 12) and push result (17) 3 Push value 3 17 − Subtract 14 Pop two values (17, 3) and push result (14) Result (14) When a computation is finished, its result remains as the top (and only) value in the stack; in this case, 14. 4. Write a menu program to have the above options for the expressions. Your menu program should not use global data; data should be allowed to be read in and stored dynamically. 5. Name your program as cis27Fall2020YourNameHw5.c Make sure that the output is reasonable and detailed enough so that the user would understand the list – Use printf() measurably. Attach the output at the end of your source code (as comment). ****************************** * HW #5 - EXPRESSIONS * * 1. Creating/Updating infix * * 2. Converting to postfix * CIS 27 Fall 2020 – Homework #5 Update #4 – Page 5 of 10 * 3. Displaying infix * * 4. Displaying postfix * * 5. Evaluating expression * * 6. Quit * ****************************** Select the option (1 through 6): 7 You should not be in this class! ****************************** * HW #5 - EXPRESSIONS * * 1. Creating/Updating infix * * 2. Converting to postfix * * 3. Displaying infix * * 4. Displaying postfix * * 5. Evaluating expression * * 6. Quit * ****************************** Select the option (1 through 6): 1 Intializing/Creating Option – ******************************** * Sub MENU – Creating/Updating * * 1. Creating * * 2. Updating * * 3. Displaying * * 4. Returning * ******************************** Select an option (integer only): 2 No infixExpression available! ******************************** * Sub MENU – Creating/Updating * * 1. Creating * * 2. Updating * * 3. Displaying * * 4. Returning * ******************************** Select an option (integer only): 3 No infixExpression available! ******************************** * Sub MENU – Creating/Updating * * 1. Creating * * 2. Updating * * 3. Displaying * * 4. Returning * ******************************** Select an option (integer only): 1 Creating Option – Is there a value (1 : yes, 0 : no)? 1 Enter value: 5 Is there a value (1 : yes, 0 : no)? 1 Enter value: + Is there a value (1 : yes, 0 : no)? 1 CIS 27 Fall 2020 – Homework #5 Update #4 – Page 6 of 10 Enter value: ( Is there a