195k views
1 vote
In this one you'll need to: (Python code)

Read a transaction file of U.S. presidents
Separate the input lines into a transaction part and name part
Create a Node class to be used to build a Linked List of presidents
Build a partial list one node at a time
Traverse the list using a 'while' loop
Build a complete list using a 'for' loop that includes all names

1 Answer

6 votes

Final answer:

To complete this task in Python, separate the lines, create a Node class, build a Linked List, and traverse the list.

Step-by-step explanation:

In this Python code, you will be reading a transaction file of U.S. presidents. To separate the input lines into a transaction part and name part, you can use the string split() method to split each line into two parts based on a common delimiter, such as a comma. You can then store the transaction part in a variable and the name part in another variable.

To build a Linked List of presidents, you can create a Node class that represents each president and has a reference to the next president. You can use this Node class to construct a Linked List by assigning the next reference of each node to the next node in the list.

You can build a complete list of presidents using a 'for' loop that iterates over each name and creates a node for it. Finally, you can traverse the list using a 'while' loop that starts at the head of the list and navigates through each node until the end of the list is reached.

User Mark Fellner
by
9.0k points