Implement a singly linked list with insertion and deletion operations.
A linked list is a linear data structure composed of a sequence of nodes. Each node contains two pieces of information: the data itself and a pointer to the next node in the list. The list is accessed through a pointer to the first node, often called the `head`. The last node in the list has its 'next' pointer set to `nullptr`, indicating the end of the list. Unlike arrays, linked lists do not store elements in contiguous memory locations, which gives them their primary advantage: insertions and deletions can be performed in constant time (O(1)) if you have a pointer to the relevant node, as it only requires redirecting a few pointers. The disadvantage is the lack of direct random access; to find the nth element, you must traverse the list from the `head`, which takes linear time (O(n)). To implement a linked list, you typically start by defining a `Node` class or struct that holds the data and the 'next' pointer. Then, you create a `LinkedList` class that manages the list, keeping track of the `head` pointer and providing methods like `insertAtBeginning`, `deleteNode`, and `displayList`. Implementing a linked list is an excellent exercise in working with pointers and dynamic memory management.