Can a Node class have multiple pieces of data?


#1

Question

For this exercise, can a Node class have more than one data item?

Answer

A Node is a unit of storage for data used by different data structures. In this exercise, the Node class has a single data value. However, a Node can store whatever is needed by the program using it. In the code provided for this exercise, the Node class stores a value which could be a list or a dictionary - either of which can contain multiple items. If the program required it, a new type of specialized node class could be created which had multiple fields to store data.