morse code help

Hello everyone
I am not able to understand the question and need help with the code.

Last edited on
well we can't fix the code until we understand the question, can we?
what do you not understand about the question? It looks to me like they want (for some insane reason) to make a tree of the dots and dashes that *presumably* one would traverse to spew out the transmitted morse code over your telegraph machine.

So you get a letter, you break it into 3 symbols, and put those into the tree, apparently.

I think the key that isnt stated is that you (again, presumably?) need to figure out which traversal gives back the data in a coherent format and what algorithm should be used to insert the data so that it happens. (I don't know this exactly either, likely some scheme will insert to make an 'in-order' traversal correct).

Last edited on
This is some really odd code. Were you given this or did you write it? Can you post the rest of the assignment. As Jonnin said, the question doesn't make much sense. It tells you what the parameters are but doesn't really say what the function does.

Some comments on the code:
table.h: It's always a bad idea to define data in header files. If you #include that file in two .cpp files, you'll end up with doubly-defined data.

telegraph.h: struct Tnode contains only one data element. In that case there's no need for a struct. It would be better to just typedef the data.

Why is TELEGRAPH::buildTree() defined in two different files? And the two definitions have different code.

The question implies that there's a tree structure here but I see no data with a tree structure at all. Perhaps Tnode should have left and right pointers?

I'm sorry to say that without the details of the whole assignment and with the code in its current state, I can't tell what the code is supposed to do. If we don't know what the code should do, then we can't tell if it's right or wrong.

Topic archived. No new replies allowed.