1 / 5

Object Oriented Data Structures

Object Oriented Data Structures. The Polish Notation The Idea Evaluation of Polish Expressions Translation form Infix to Polish Interactive Expression Evaluator. Expression Trees. Evaluate the left subtree Evaluate the right subtree Perform the operator. :=. /. x. x. +. a. -. 2. b.

masako
Download Presentation

Object Oriented Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Data Structures The Polish Notation The IdeaEvaluation of Polish ExpressionsTranslation form Infix to PolishInteractive Expression Evaluator Kruse/Ryba ch13

  2. Expression Trees • Evaluate the left subtree • Evaluate the right subtree • Perform the operator Kruse/Ryba ch13

  3. := / x x + a - 2 b 0.5 - x b 2 c x a 4 Kruse/Ryba ch13

  4. Error_code Expression::evaluate_prefix(Value & result){ Token t; Value the_argument, first_argument, second_argument; if( (get_token(t) ==fail) return fail; switch (t.kind() ) { case unaryop: if(evaluate_prefix(the_argument) == fail) return fail; else result = do_unary(t, the_argument); break; case binaryop: if(evaluate_prefix(first_argument) == fail) return fail; if(evaluate_prefix(second_argument) == fail) return fail; else result = do_binary(t, first_argument, second_argument); break; case operand: result = get_value(t); break; } return success Kruse/Ryba ch13

  5. Thus Ends Chapter 13and the Book Kruse/Ryba ch13

More Related