Deletion from the Tail Add deletion capability to the project you worked on in Programming Exercise 4. For this you will need to maintain a pointer to the node that tail points to. The interface,...



Deletion from the Tail


Add deletion capability to the project you worked on in Programming Exercise 4. For this you will need to maintain a pointer to the node that
tail
points to. The interface, after node 4 from Figure 12-52 is deleted, is shown in Figure 12-53.


Figure 12-54 shows the deletion process as a progression of steps. A temporary pointer (temp) points to the node preceding the
tail
. Using temp, the node at the end of the list can be deleted (temp->next). Then
tail
can be assigned the value stored in
temp. The trick to this assignment is to find the position for
temp. This can be done using a
while
loop that repeatededly assigns temp the value
temp->next
until
temp->next->next
is the null pointer.


Programming Exercise 4



Insertion at the End of the List


At this point, your program can insert and delete only from the front of the list (the head node). The result is that data values are stored in descending order from the head node. Data could be stored in ascending order if nodes were inserted at the end of the list instead of from the front. This necessitates a list with a pointer to the tail node as shown in Figure 12-51.


Modify your tutorial project (you can make a copy and rename it) so that all insertions take place at the tail. You do not need to implement node deletion. The typical interface display should show an ordered list, as in Figure 12-52:

Nov 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here