Find Jobs
Hire Freelancers

c code tree implementation..

$5-10 USD

Cancelado
Publicado há aproximadamente 14 anos

$5-10 USD

Pago na entrega
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.
ID do Projeto: 3276052

Sobre o projeto

2 propostas
Projeto remoto
Ativo há 14 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
2 freelancers estão ofertando em média $8 USD for esse trabalho
Avatar do Usuário
See private message.
$6,80 USD em 1 dia
4,9 (40 avaliações)
3,7
3,7
Avatar do Usuário
See private message.
$8,50 USD em 1 dia
5,0 (5 avaliações)
2,3
2,3

Sobre o cliente

Bandeira do(a) TURKEY
Ankara, Turkey
0,0
0
Membro desde fev. 8, 2009

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.