Code a c/c++ tree implementation

About the client

United Kingdom

Posted on Nov 26, 2011 / Est. budget $ 50 / Project closed

Awarded winner(s):

Driagan
Driagan

REQUIREMENTS

1. c or c++.
2. Minimal code size; ideally excluding .h files there should be no more than 400 lines of c or c++ code.
3. Construct an in-memory tree representation of a simple input text file.
a) The tree implementation must be written from scratch using core c or c++ libs (stdlibs only, no third party or open source libraries please)
b) The input text file will have the following format/input structure

an int, a comma, and then a small set of single characters.

lines in the input file are separated by rn

the input file is completely valid and no error checking of its contents are required

Example Input File

1,BG
2,CGH
10,CH
5,BGH5DZ
100,j9
18,A
3,AB
7,j
9,2
402,BG5DZ

4. When the application is executed from the command line and two command line arguments are provided, argument 1 is the input text filename, argument 2 is the edge transversal.

In this mode:

The application will print out the node value followed by a * if there exists a node in the tree with a value. It will also print out the ints for all other nodes transversing toward the tree leaves. All values printed out should be separated by commas.

For example, if the program is named x and the filename is named x.txt, then

x x.txt BGH5DZ will print out to the console 5*
x x.txt DFDFG will print nothing out to the console
x x.txt ABC will print nothing out to the console
x x.txt j9 will print out to the console 100*
x x.txt J9 will print nothing out to the console
x x.txt BG will print out to the console 1*,402,5 (in any order, ie 1*, 5, 402 or 5, 1*, 402 etc are all acceptable).
x x.txt B will print out 1,5,402 (again, in any order)

6. When the application is executed from the command line and one command line argument, the argument is the input text filename.

In this mode:

The application must print out the tree constructed from the input file. Some very primitive and unstructured output is all that is required and ideally you will use just cout or sprintf. All I need to see is that you have constructed a tree (and to ensure you understand from the input, what type of tree needs constructing).

The formal in-memory tree representation of a tree constructed from the example input file is shown in the attached image.


Project bids (1)

Bids are visible only by project owner and Premium members.