Section 20.4 Check Point Questions14 questions 

20.4.1
If a linked list does not contain any nodes, what are the values in head and tail?
20.4.2
If a linked list has only one node, is head == tail true? List all cases in which head == tail is true.
20.4.3
When a new node is inserted to the head of a linked list, will the head pointer and the tail pointer be changed?
20.4.4
When a new node is appended to the end of a linked list, will the head pointer and the tail pointer be changed?
20.4.5
When a node is removed from a linked list, what will happen if you don't explicitly use the delete operator to release the node?
20.4.6
Under what circumstances would the functions removeFirst, removeLast, and removeAt throw an exception?
20.4.7
Discuss the pros and cons of using arrays and linked lists.
20.4.8
If the number of elements in the program is fixed, what data structure should you use? If the number of elements in the program changes, what data structure should you use?
20.4.9
If you have to add or delete the elements anywhere in a list, should you use a vector or a linked list?
20.4.10
If you change the function signature for printList in line 6 in Listing 20.1 to
void printList(const LinkedList<string> list)
will the program work? So, what is the difference between the two signatures?
20.4.11
What will happen when you run the following code?
#include <iostream>
#include <string>
#include "LinkedList.h"
using namespace std;

int main()
{
  LinkedList<string> list;
  list.add("abc");
  cout << list.removeLast() << endl;
  cout << list.removeLast() << endl;

  return 0;
}
20.4.12
Show the output of the following code:
#include <iostream>
#include <string>
#include "LinkedList.h"
using namespace std;

int main()
{
  LinkedList<string> list;
  list.add("abc");
  
  try
  {
    cout << list.removeLast() << endl;
    cout << list.removeLast() << endl;
  }
  catch (runtime_error& ex)
  {
    cout << "The list size is " <<  list.getSize() << endl;
  }

  return 0;
}
20.4.13
What would be the time complexity for the getSize() function if the size data field is not used in LinkedList?
20.4.14
Note that the get(int) function is delcared as T& get(int index) const. What is the output of the following code?
  LinkedList<string> list;
  list.add("abc");
  list.get(0)[0] = 'T';
  cout << list.get(0) << endl; 
If the get(int) function is redeclared as T get(int index) const, what would be the output of the preceding code?