Find Jobs
Hire Freelancers

c code tree implementation.. (repost)

$5-10 USD

Cancelled
Posted about 14 years ago

$5-10 USD

Paid on delivery
You are expected to write a C console program capable of constructing a tree (deserialization) from its string representation, and dumping a tree (serialization) to its string representation. Two different notations, (i) fully parenthetic and (ii) parent climbing, for string representation of trees should be supported. Moreover, the program is expected to have some additional functions querying the tree. The additional functions include, tree height (to report the height of a tree), binary tree check (to report whether the tree is a binary tree), mean fan-out (to report the mean value of fan-out for internal nodes), and evaluation (to report the arithmetic tree evaluation result). ## Deliverables SEE ATTACHED DOC FILE TO UNDERSTAND ALL DETAILS.. Problem: Ordered tree serialization, deserialization and evaluation using linked structures Description: In this assignment you are expected to write a C console program capable of constructing a tree (deserialization ) from its string rep- resentation, and dumping a tree (serialization ) to its string representation. Two different notations, (i) fully parenthetic and (ii) parent climbing, for string representation of trees should be supported. Moreover, the program is expected to have some additional functions querying the tree. The addi- tional functions include, tree height (to report the height of a tree), binary tree check (to report whether the tree is a binary tree), mean fan-out (to re- port the mean value of fan-out for internal nodes), and evaluation (to report the arithmetic tree evaluation result). • Three sample trees are illustrated below, along with their respective representations in the considered notations. • The internal nodes have the label from the set {+, -, *, /}, each for the respective arithmetic expression. Note that, since the tree is or- dered the semantics of the operators are well-defined. If the number of operand is one, all operators return the value of the single child. In case, the number of operators are two or more, the operators have the usual semantics. For instance, the first tree evaluates to -9.0, the second to 3.0, and the third to 12.275. • The external nodes have integer values. • The ??x?? in parent climbing notation means to climb to the parent of the current node. > • Average fan-out is computed as the sum of fan-out for all internal nodes divided by the number of internal nodes. So, the result gives 2.0, undefined, and 2.0 for the three trees, respectively. > Program: Your program should accept commands from the command prompt in a loop. Commands: The format is as follows: > • Read tree from file (Assume that the tree is well-formed (no syntax errors). Note that the tree can be in either format, you are expected to distinguish which): > TR filename • Write tree (in fully parenthetic notation): > FPTW filename • Write tree (in parent climbing notation): > PCTW filename • Evaluate tree as an arithmetic expression: > ET • Report tree height: > RTH • Display average fan-out: > DAFO • Check whether the tree is a binary tree: > CBT • Quit the program: > QUIT Important: • Use only C constructs, do not use C++. So, for instance, instead of class, use struct. • Never use ready-made data structures for trees from any library. In case you need, you are allowed to use other data structures (e.g., stack) from libraries. • Use linked structures for implementing the ordered expression tree. You are expected to use pointers. Hence, array based implementations will be awarded marginally. • You are also expected to use record, union, and enumeration data types as appropriate.
Project ID: 3277138

About the project

2 proposals
Remote project
Active 14 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
2 freelancers are bidding on average $8 USD for this job
User Avatar
See private message.
$6.80 USD in 1 day
4.9 (5 reviews)
1.5
1.5
User Avatar
See private message.
$8.50 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of TURKEY
Ankara, Turkey
0.0
0
Member since Feb 8, 2009

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759) & Freelancer Online India Private Limited (CIN U93000HR2011FTC043854)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.