07_linked_list_stack_queue
07_linked_list_stack_queue
1. Initialize a Node from a given integer 9. Remove node(s) after the node(s) with the speci-
Node* createNode(int data); fied val value in a linked list
void removeAfter(List &L, int val);
2. Initialize a List from a give Node
List createList(Node* pNode); 10. Insert an integer at a specific position of a liked list
void addPos(List &L, int data, int pos);
3. Insert an integer to the head of a linked list
void addHead(List &L, int data); 11. Remove a node at a specific position of a linked list
void removePos(List &L, int pos);
4. Insert an integer to the tail of a linked list
void addTail(List &L, int data);
12. Insert an integer before the node(s) with the spe-
cific val value in a linked list
5. Remove the first node of a linked list
void addBefore(List &L, int data, int val);
void removeHead(List &L);
6. Remove the last node of a linked list 13. Insert an integer after the node(s) with the specific
1
16. Create a new linked list by reversing the given keeping the first occurrence of each one
linked list void removeDuplicate(List &L);
List reverseList(List L);
18. Remove all nodes that have a value equal to key
17. Remove all duplicate elements from a linked list, bool removeElement(List &L, int key);
Part 2 – Stack-Queue
Utilize the existing linked list to define the stack and queue data structures. Next, implement functions for the
following operations:
1. Stack 2. Queue
• Initialize a stack from a given key. • Initialize a queue from a given key.
• Pop an element out of a stack, the key’s value will • Dequeue an element out of a queue, the key’s
be returned. value will be returned.
• Count the number of elements in a stack. • Count the number of elements in a queue.