1. | What is a stack-linked list? |
|
2. | How does a stack-linked list differ from a linked list? |
|
3. | What is the benefit of using a stack-linked list? |
|
4. | Where is the front of the stack in a stack-linked list? |
|
5. | What is the maximum number of nodes that you can have on a stack-linked list? |
|
6. | Can a node on a stack-linked list have more than one data element? |
|
7. | Why does the StackLinkedList class inherit the LinkedList class? |
|
8. | Why is the constructor of the StackLinkedList class empty? |
|
9. | Why is the destructor of the StackLinkedList class empty? |
|
10. | What happens when you push a new node onto a stack? |
|
Answers
1. | A stack-linked list is a data structure that uses a linked list to create a stack. |
2. | A stack-linked list accesses data last in, first out; a linked list accesses data first in, first out. |
3. | The benefit of using a stack-linked list is that the number of nodes on the stack can increase or decrease as needed while the program runs. |
4. | The front of the stack in a stack-linked list is at the back of the linked list. |
5. | There can be a nearly unlimited number of nodes on a stack-linked list, restricted only by the amount of available memory in the computer. |
6. | Yes, a node on a stack-linked list can have more than one data element, which is also true of a node on a linked list. |
7. | The StackLinkedList class inherits the LinkedList class because the StackLinkedList class uses attributes and member functions of the LinkedList class. |
8. | The constructor of the StackLinkedList class is empty because the constructor of the LinkedList class is called when an instance of the StackLinkedList class is declared. The constructor of the LinkedList class initializes the node and attributes that are later used by the StackLinkedList class. |
9. | The destructor of the StackLinkedList class is empty because the destructor of the LinkedList class is called prior to the destructor of the StackLinkedList class. This is because the LinkedList class is inherited by the StackLinkedList class. |
10. | When you push a new node onto a stack, the new node is placed at the front of the linked list. |