Question: Programming Activity 2 - Guidance = = = = = = = = = = = = = = = = = = = =

Programming Activity 2- Guidance
=================================
As you should do every week, make sure you study this week's programming examples.
The starting contents of a data structure includes both its size and item values.
The expected output is based on the starting contents of theArray.
You are NOT allowed to hard-code an answer to any part.
Two variables are initialized for you in the starter code.
They are named head and tail.
head always references the first node in a linked list.
tail always references the last node in a linked list.
You must use these variables in your code.
Part 1
------
Start at head and traverse (loop) through the linked nodes.
Print each node's data value as you encounter it.
Use a variable named currentNode as you traverse the list.
In your loop, to print the current node's value, use:
print(currentNode.data)
As you loop, you must update currentNode to reference the next item.
Part 2
------
Use tail to add nodes to the end of the list, one-by-one in a loop.
As they are added, you must update tail so it always references the last node.
The variable head should not be used during this step.
Part 3
------
Create the new node.
Then, change tail's next link to reference it.
Part 4
------
Read the comments in the starter code.
Use a variable named currentNode as you traverse the list.
To link the new node in correctly:
the new node's next link must be set to currentNode's next link,
then currentNode's next link must be set to reference th

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!