The document provides a list of 24 operations to implement on a singly linked list of integers, such as adding nodes to the head/tail, deleting nodes, searching for nodes, and sorting. It also asks the reader to write Java programs for a singly linked list of strings with 1-10 of the operations, a doubly linked list of integers with the operations, and a circular linked list of integers with the operations.
The document provides a list of 24 operations to implement on a singly linked list of integers, such as adding nodes to the head/tail, deleting nodes, searching for nodes, and sorting. It also asks the reader to write Java programs for a singly linked list of strings with 1-10 of the operations, a doubly linked list of integers with the operations, and a circular linked list of integers with the operations.
You can select and do some questions according to your ability. We would like to note you that the more questions you do the better for you in doing final practical and writing exams.
Question 1. Write a Java program to implement a singly linked list of integer
values with the following operations:
1) void addToHead(int x) - add a node with value x at the head of a list.
2) void addToTail(int x) - add a node with value x at the tail of a list. 3) void addAfter(Node p, int x) - add a node with value x after the node p. 4) void traverse() - traverse from head to tail and dislay info of all nodes in the list. 5) int count() - count and return number of nodes in the list. 6) int deleteFromHead() - delete the head and return its info. 7) int deleteFromTail() - delete the tail and return its info. 8) int deleteAter(Node p) - delete the node after the node p and return its info. 9) void delete Node(int x) - delele the first node whose info is equal to x. 10)Node search(int x) - search and return the reference to the first node having info x. 11)void delete(Node p) - delete node p if it exists in the list. 12)void delete Node2(int i) - delete an i-th node on the list. Besure that such a node exists. 13)void addBefore(Node p, int x) - add a node with value x before the node p. 14)void sort() - sort the list by ascending order of info. 15)Reverse a singly linked list using only one pass through the list. 16)int [] toArray() - create and return array containing info of all nodes in the list. 17)Merge two ordered singly linked lists of integers into one ordered list. 18)Attach a singly linked list to the end of another singly linked list. 19)int max() - find and return the maximum value in the list. 20)int min() - find and return the minimum value in the list. 21)int sum() - return the sum of all values in the list. 22)int avg() - return the average of all values in the list. 23)boolean sorted() - check and return true if the list is sorted, return false if the list is not sorted. 24)void insert(int x) - insert node with value x into sorted list so that the new list is sorted. 25)Check whether two singly linked list have the same contents.
Question 2. Write a Java program to implement a singly linked list of string
values with 1 - 10 operations in the above list.
Question 3. Write a Java program to implement a doubly linked list of integer
values with the above operations.
Question 4. Write a Java program to implement a circular linked list of integer