Problem 1 : In the LinkedList class, add a method remove(n) to remove the specified node n from the list and return its element. You may assume the linked list contains the specified node. Then, add a swap_head_tail() method to swap the head and tail nodes (not just elements) in the linked list and a random_remove() method to randomly remove a node from the linked list and return its element.
Problem 2 : Given a LinkedList of letters s, write the following functions: • join(s) to join all the letters together in the linked list and return the joined string. • remove_duplicate(s) to remove all the duplicate letters, join all the unique letters together, and return the joined string, for example, if the input linked list is ‘a’ → ‘c’ → ‘b’ → ‘a’ → ‘a’ → ‘c’ → ‘d’, your method should return “acbd” or “bacd”. • count_vowels(s) to return the number of vowels in the linked list.
Problem 3 : Given two sorted SinglyLinkedList of integers, write a function • merge2lists(linked_list1, linked_list2) to merge the two linked lists into a new sorted linked list and return it For example: Before merging: list1: 2→11→19→21→23→24 list2: 3→9→15→16→22 After merging: 2→3→9→11→15→16→19→21→22→23→24
Problem 4 : In the DoublyLinkedList class, add the following public methods: • get_first() to return the first node (not the header) in the linked list • get_last() to return the last node (not the trailer) in the linked list ▪ contains(e) method to return true if the linked list contains a specified element e, false otherwise ▪ add_before(e, n) to insert the specified element e before that specified node n ▪ add_after(e, n) to insert the specified element e before that specified node n ▪ You may assume the linked list contains the specified node for add_before() and add_after()