Difference between revisions of "CISC220 F2023 Lab4"

From class_wiki
Jump to: navigation, search
(Notes)
(POSTEVAL: int postOrderEval(root))
Line 7: Line 7:
 
===<tt>INPRINT</tt>: <tt>void inOrderPrint(root)</tt>===
 
===<tt>INPRINT</tt>: <tt>void inOrderPrint(root)</tt>===
  
===<tt>POSTEVAL</tt>: <tt>int postOrderEval(root)</tt>===
+
===<tt>POSTEVAL</tt>: <tt>int postOrderEvaluate(root)</tt>===
  
Treat the tree as an "expression tree" for integer arithmetic.  There are 6 operators (4 binary and 2 unary).  The binary operators are <tt>+</tt>, <tt>-</tt>, <tt>*</tt>, and <tt>/</tt>, and <tt>^</tt> for addition, subtraction, multiplication, and division, respectively.  The 2 unary operators are strings: <tt>fact</tt> and <tt>abs</tt>, for the factorial operation and taking the absolute value, respectively.  
+
Treat the tree as an "expression tree" for integer arithmetic.  There are 6 operators (4 binary and 2 unary).  The binary operators are <tt>+</tt>, <tt>-</tt>, <tt>*</tt>, and <tt>/</tt>, and <tt>^</tt> for addition, subtraction, multiplication, and division, respectively.  The 2 unary operators are strings: <tt>fact</tt> and <tt>abs</tt>, for the factorial operation and taking the absolute value, respectively.
  
 
===<tt>POSTCOUNTCHARS</tt>: <tt>int postOrderCountChars(root)</tt>===
 
===<tt>POSTCOUNTCHARS</tt>: <tt>int postOrderCountChars(root)</tt>===

Revision as of 10:10, 21 September 2023

Requirements

(5 points) A vector-based implementation of a binary tree of strings is provided in [xxx string_binary_tree.cpp]. Your task is to complete the 4 functions below that depend on recursive traversals of a tree read from a file. The main() function expects a single input filename on the command line (reading is taken care of for you) and an output type: PREPRINT, INPRINT, POSTEVAL, or POSTCOUNTCHARS. Each output type triggers a call to one of the functions you must write, as follows:

PREPRINT: void preOrderPrint(root)

INPRINT: void inOrderPrint(root)

POSTEVAL: int postOrderEvaluate(root)

Treat the tree as an "expression tree" for integer arithmetic. There are 6 operators (4 binary and 2 unary). The binary operators are +, -, *, and /, and ^ for addition, subtraction, multiplication, and division, respectively. The 2 unary operators are strings: fact and abs, for the factorial operation and taking the absolute value, respectively.

POSTCOUNTCHARS: int postOrderCountChars(root)

Notes

If there is an error or exception of any kind, print "ERROR\n" and exit with code 1.

Submission

  • Once again, you will submit two files completely through Gradescope: (1) README and (2) your modified string_binary_tree.cpp. As before, the README should contain your name, any AI tool citations/explanations, notes on any limitations or issues with your code, and your interpretation of any ambiguities in the assignment instructions. The code file should also have your name and AI citations per the syllabus.
  • Resubmit as many times as you like until the deadline, but be aware that the submission window is kept open for some students to use late days, so a resubmission 2 days after the deadline is not free.
  • The 5 possible points assigned by the autograder are provisional. They are not final until published and they may be revised if we determine that your code and/or README do not satisfy the assignment requirements even though they pass the tests. In rare cases, we may also revise your grade upward if we believe that the score you received does not reflect the work you put into the assignment.