This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2015:data:projects:dlt0 [2015/04/26 17:15] – [node library] wedge | haas:spring2015:data:projects:dlt0 [2015/05/03 13:58] (current) – [Errata] wedge | ||
---|---|---|---|
Line 11: | Line 11: | ||
This section will document any updates applied to the project since original release: | This section will document any updates applied to the project since original release: | ||
- | * __revision | + | * __revision |
+ | * __revision 2__: unit tests for **cptree_r()** and **rmtree()** now available (20150502) | ||
+ | * __revision 3__: unit tests for **grabnode_r()** now available (20150503) | ||
+ | |||
=====Objective===== | =====Objective===== | ||
Line 21: | Line 25: | ||
Truth be told, the simplest tree is merely a list- the underlying data structure we've worked with all semester. But now, under this new light, we can start to look at a list as merely a procession of singled childed nodes. The more things are different, the more they are the same... | Truth be told, the simplest tree is merely a list- the underlying data structure we've worked with all semester. But now, under this new light, we can start to look at a list as merely a procession of singled childed nodes. The more things are different, the more they are the same... | ||
- | The simplest conceptual tree is one which has a minimum | + | The simplest conceptual tree is one which has a maximum |
- | + | ||
- | The premise behind a tree is that of a parent-child relationship. Each node can be a parent (of up to two child nodes), and each child can in turn be its own parent (of up to two child nodes). This creates a connection between relationships of nodes (ie a parent and its descendants), | + | |
+ | The premise behind a binary tree is that of a parent-child relationship. Each node can be a parent (of up to two child nodes), and each child can in turn be its own parent (of up to two child nodes). This creates a connection between relationships of nodes (ie a parent and its descendants), | ||
====conceptualizing a tree==== | ====conceptualizing a tree==== | ||
It is common to think of a tree as a vertical structure, upside-down from the item we commonly think of in nature. Here we will have the tree's " | It is common to think of a tree as a vertical structure, upside-down from the item we commonly think of in nature. Here we will have the tree's " | ||
Line 37: | Line 39: | ||
* an important action that will be taking place is the traversal of the tree- ie walking it in certain orders to achieve desired results (sorting/ | * an important action that will be taking place is the traversal of the tree- ie walking it in certain orders to achieve desired results (sorting/ | ||
- | As we will be placing nodes in the tree according to their stored values (lesser values go to the left, or prior; greater values go to the right, or after), our tree will naturally sort our data for us. As such, the tree we will be implementing | + | As we will be placing nodes in the tree according to their stored values (lesser values go to the left, or prior; greater values go to the right, or after), our tree will naturally sort our data for us, allowing us to search through its contents quite advantageously. As such, the tree we will be implementing |
====tree height can matter==== | ====tree height can matter==== | ||
Line 103: | Line 104: | ||
Figure out what is going on, the connections, | Figure out what is going on, the connections, | ||
+ | ===Suggested Implementation Order=== | ||
+ | To make your life easier, I recommend implementing tree library functions in the following order: | ||
+ | |||
+ | - **mktree()** | ||
+ | - **addnode()** | ||
+ | - **searchtree()** | ||
+ | - **traverse_r()** | ||
+ | - **grabnode_r()** | ||
+ | - **cptree_r()** | ||
+ | - **rmtree()** | ||
- | ====Node Library unit tests==== | + | You will really want the later functions to make use of the earlier functions to facilitate implementation (ie **cptree_r()** will likely want to make use of **traverse_r()** and **addnode()**, and **rmtree()** could take advantage |
- | As a result | + | |
- | Be sure to run the various node unit tests and verification scripts to see which functions have fallen out of compliance with the node struct specification changes issued in this project. The **verify-node.sh** script | + | Note that **grabnode_r()** can be implemented earlier, as it only really needs **mktree()**, |
====Tree library unit tests==== | ====Tree library unit tests==== | ||
In **testing/ | In **testing/ | ||
Line 119: | Line 129: | ||
* **unit-traverse.c** - unit test for **traverse_r()** library function | * **unit-traverse.c** - unit test for **traverse_r()** library function | ||
- | **NOTE**: At the time of project release, unit tests are not yet available; so they will be released as they are developed. | + | **NOTE**: At the time of project release, |
There are also corresponding **verify-FUNCTION.sh** scripts that will output a " | There are also corresponding **verify-FUNCTION.sh** scripts that will output a " |