1. Homepage
  2. Programming
  3. JC1503 Object-Oriented Programming - Assessment2 - Expression Binary Tree

JC1503 Object-Oriented Programming - Assessment2 - Expression Binary Tree

Engage in a Conversation
JC1503Object-Oriented ProgrammingUniversity of AberdeenAbdn

  CourseNana.COM

Introduction: CourseNana.COM

  CourseNana.COM

In Q1 of JC1503 Practical on Trees (Practical 10), you were given the following expression: CourseNana.COM

  CourseNana.COM

(((5+2)*(21))/((2+9)+((72)1))*8) CourseNana.COM

  CourseNana.COM

and were asked to convert it to a binary tree. CourseNana.COM

  CourseNana.COM

In this assessment, you are asked to design a python program that can automatically convert a mathematical expression into a binary tree after the user enters it as an input. Specifically, the expression must be in the same format as the above, and a valid expression can be recursively defined as follows: CourseNana.COM

It must be in the form of (X?Y) where X and Y are either numbers or valid expressions, and ? stands for operators (*, /, +, -) CourseNana.COM

  CourseNana.COM

For instance, CourseNana.COM

  CourseNana.COM

(4*5) is a valid expression; CourseNana.COM

((2*3)*5) and ((2*4)*(5*6)) are also valid expressions; CourseNana.COM

(4*5*6) is not a valid expression because it has three operands within one pair of brackets; ((4*(5+6) is not a valid expression as the brackets are mismatched (final bracket missing). CourseNana.COM

  CourseNana.COM

To simplify the problem, we assume all numbers are single-digit ones (i.e., ranging from 0 to 9) and all operators are: *, /, +, - CourseNana.COM

  CourseNana.COM

Hint: You may want to use a combination of data structures, for instance, stacks and trees. CourseNana.COM

  CourseNana.COM

Tests CourseNana.COM

Writing test for your code is a good practice. Therefore, some unit tests should be included in your code to show their use, and to confirm that your data structures hold expected values. CourseNana.COM

  CourseNana.COM

Hint: Test the data structures, not output to the screen, as unit testing console output is challenging CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
JC1503代写,Object-Oriented Programming代写,University of Aberdeen代写,Abdn代写,JC1503代编,Object-Oriented Programming代编,University of Aberdeen代编,Abdn代编,JC1503代考,Object-Oriented Programming代考,University of Aberdeen代考,Abdn代考,JC1503help,Object-Oriented Programminghelp,University of Aberdeenhelp,Abdnhelp,JC1503作业代写,Object-Oriented Programming作业代写,University of Aberdeen作业代写,Abdn作业代写,JC1503编程代写,Object-Oriented Programming编程代写,University of Aberdeen编程代写,Abdn编程代写,JC1503programming help,Object-Oriented Programmingprogramming help,University of Aberdeenprogramming help,Abdnprogramming help,JC1503assignment help,Object-Oriented Programmingassignment help,University of Aberdeenassignment help,Abdnassignment help,JC1503solution,Object-Oriented Programmingsolution,University of Aberdeensolution,Abdnsolution,