- Write a C code which does the following:
- Your program will read a file named txt
- txt contains single line text. The text describes a tree structure. It follows the Newick format rules. But there are simplifications and/or modifications:
- Each node is represented by a single character. They are separated by comma. Branching is described by matching parentheses.
- The length of the text will not be greater than 250
- Below is an example of a tree description:
(A,(c,B,e),K,D,e,(f,(d,F))) This tree can be visualized as follows:
-A
c
B
e
-K
-D
-e
f
d
F
- Another example:
(A,(A,A,(A),A),A)
- Visualization:
-A A
A
A
A
-A
- Another example:
A,(A,A,(A),A),A
- Visualization:
A
-A
-A
A
-A
A
- Your program will read the simplified newick formatted tree description from a file and write the visualization of the described tree to txt.
- Core part of your implementation (parsing and creating visualization) should utilize recursion otherwise you will get 0pts. For this problem, coding without recursion is significantly easier.
- Pay attention to the structure of the output. If your program prints something slightly different or anything extra, you will loose at least 30pts. Dont print any debug messages or greeting texts. Dont add extra spaces, newlines, commas etc
Turn in:
- Source code of a complete C program. Name of the file should be in this format: <full_name>_<id>.c.
- Example: c. Please do not use any Turkish special characters.
- You dont need to use an IDE for this assignment. Your code will be compiled and run in a command window.
- Your code will be compiled and tested on a Linux machine(Ubuntu). GCC will be used.
- Make sure that your program does not require specific encodings/markings/line-ending-chars. Make sure it works with a file created in a linux environment.
- Make sure you dont get compile errors when you issue this command : gcc <full_name>_<id>.c.
- A script will be used in order to check the correctness of your results. So, be careful not to violate the expected output format.
- Provide comments unless you are not interested in partial credit. (If I cannot easily understand your design, you may loose points.)
- You may not get full credit if your implementation contradicts with the statements in this document.
- If your program requires additional compile and link options, state that requirement at beginning of your source code as a comment.
Reviews
There are no reviews yet.