This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
haas:fall2018:data:projects:sln0 [2018/08/20 15:42] – wedge | haas:fall2018:data:projects:sln0 [2018/09/02 12:03] (current) – wedge | ||
---|---|---|---|
Line 9: | Line 9: | ||
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 |
=====Objective===== | =====Objective===== | ||
Line 30: | Line 30: | ||
For starters, our " | For starters, our " | ||
- | * a data field called **contents** | + | * a data field called **info** |
- | * an arrow pointing to the next neighboring node to our immediate right, called **to** | + | * an arrow pointing to the next neighboring node to our immediate right, called **right** |
If we do not have another node to point an arrow at, we'll want to point it at a specific value indicating nothing. In our case, that value is **NULL** (must be all caps). | If we do not have another node to point an arrow at, we'll want to point it at a specific value indicating nothing. In our case, that value is **NULL** (must be all caps). | ||
Line 72: | Line 72: | ||
<code c> | <code c> | ||
- | tmp -> contents | + | tmp -> info = 57 |
</ | </ | ||
Line 87: | Line 87: | ||
<code c> | <code c> | ||
- | start -> to = tmp2 | + | start -> right = tmp2 |
</ | </ | ||
- | (as tmp was also pointing to the same node, we could just as easily have said "tmp -> to = tmp2", and we may have wanted to use that approach instead, as the idea behind **start** is to use it as an anchoring reference point only). | + | (as tmp was also pointing to the same node, we could just as easily have said "tmp -> right = tmp2", and we may have wanted to use that approach instead, as the idea behind **start** is to use it as an anchoring reference point only). |
The result of that assignment results in the following: | The result of that assignment results in the following: | ||
Line 108: | Line 108: | ||
<code c> | <code c> | ||
- | tmp3 -> to = start | + | tmp3 -> right = start |
</ | </ | ||
Line 137: | Line 137: | ||
The longer you hold out and resist from drawing pictures, the longer a lot of this may be difficult or frustrating. | The longer you hold out and resist from drawing pictures, the longer a lot of this may be difficult or frustrating. | ||
====Creating a node==== | ====Creating a node==== | ||
- | To create a node, in pseudo-code, | + | To create a node, in pseudo-code, |
**mknode()** returns the location of this new node, so in order to prevent it from getting lost, we need to assign a variable to it (much as our start, tmp, tmp2, tmp3 variables do). | **mknode()** returns the location of this new node, so in order to prevent it from getting lost, we need to assign a variable to it (much as our start, tmp, tmp2, tmp3 variables do). | ||
Line 220: | Line 220: | ||
<code c> | <code c> | ||
start = tmp = mknode(2) | start = tmp = mknode(2) | ||
- | tmp -> to = mknode(4) | + | tmp -> right = mknode(4) |
- | tmp = tmp -> to | + | tmp = tmp -> right |
- | start -> to -> to = mknode(8) | + | start -> right -> right = mknode(8) |
- | tmp = tmp -> to | + | tmp = tmp -> right |
- | tmp -> to = mknode(16) | + | tmp -> right = mknode(16) |
</ | </ | ||
Line 236: | Line 236: | ||
====Displaying the list==== | ====Displaying the list==== | ||
- | Assuming you do not know the composition of the list, write the code to display the list contents from start to end (end is defined as when a node's 'to' pointer points to NULL) | + | Assuming you do not know the composition of the list, write the code to display the list contents from start to end (end is defined as when a node's 'right' pointer points to NULL) |
====Appending to the list==== | ====Appending to the list==== |