Q1: Given an unsorted singly linked list, write a function that deletes any duplicate nodes from the list by traversing
Posted: Thu Jun 02, 2022 7:44 am
Q1: Given an unsorted singly linked list, write a function that deletes any duplicate nodes from the list by traversing it only once. Example: Input: 5 -> 3>4->2 -> 5->4->1 -> 3 -> null Output: 5 -> 3 -> 4 —> 2 —> 1 -> null Q2: Given the object dllArray, which is an array object of 5 doubly linked lists of integers, each contains at least 4 nodes, using the usual linked list operations, write the proper code segments to do the following: a) Display the data field of the head node of each linked list in the array. b) Remove the first node of the linked list at index 2 c) Insert a node with the value 5 after the tail node of the linked list at index 1 d) Delete the first linked list in dllArray Q3: The diagram below shows a linked list of characters, along with two variables that each stores a reference/pointer to one of the nodes in the list. 'B' 'A' 'S' head 'E' null The nodes in the linked list are implemented using the following class: 1 class Node { 2 char val; Node next; 3 4} a) On the diagram, circle the node specified by the expression head.next.next b) What is the value of val of the node in the expression from part a? c) Write one or more lines of code that remove the node containing the character 'S' from the list. d) Modify the diagram above to reflect the results of executing the following lines on the original version of the list (before the 'S' was removed): 1 q = q.next; 2 q.next = head; Q4: Write the ADT Stack as a new stack class, where the stack is represented as a queue and the operations of the stack are implemented in terms of the operations of the queue.