Data Structures Demystified (Demystified)

1.  

What is a linked list index?

2.  

What is the value of the first linked list index?

3.  

What is the difference between the removeNode() and deleteNode() functions?

4.  

What is the return value of the findNode() function?

5.  

What is the difference between the insertNodeAt() and the appendNode() functions?

6.  

What happens if an invalid index value is passed to a function?

7.  

Can a linked list store data other than integers?

8.  

Why would you define a getSize() function instead of having the application access the size of the linked list directly?

9.  

Can the insertNodeAt() function place a node at the front or back of a linked list?

10.  

Why is it important to enhance the functionality of the LinkedList class?

Answers

1.  

A linked list index is an integer that represents the position of a node in a linked list.

2.  

The value of the first index is zero.

3.  

The removeNode() requires a reference to the node that is to be removed, while the deleteNode() function requires the value of the data element of the node that is being removed.

4.  

The return value of the findNode() function is the index position of the node.

5.  

The insertNodeAt() function specifies the index of where to insert the new node into the linked list. The appendNode() function appends the new node to the list without requiring the programmer to specify where to place the new node in the linked list.

6.  

Functions that use an index value always determine if the index passed to  them is valid before using the index value. If an invalid index is received, the function terminates without further processing.

7.  

Yes, a linked list can store data other than integers. Integers were used in this chapter as an example, but you can modify the data type of the data in the definition of the node to change the kind of data stored in the linked list.

8.  

You use the getSize() function instead of having the application access the size of the linked list directly to protect the data from inadvertently being changed by the application. If the application needs to change the data, then the appropriate function is called and the function changes the data.

9.  

Yes, the insertNodeAt() function can place a node at the front or back of a linked list if you pass the appropriate index to this function.

10.  

You enhance the functionality of the LinkedList class to more easily manipulate a linked list.

Категории