Write a program to create a singly linked list of integers. Add an integer and delete an integer from the list and display the contents on the screen.
what part do you need help with?
One way to approach this problem would be to think of a singly-linked-list as a collection of Nodes; each Node points only in one direction, to the next Node, since the list is "singly" linked. Based on this concept, we can start by creating a Class to handle the properties and behavior of a Node. We will want each Node to be able to store an Integer value; we will want each Node to point to the next Node in the list; we may also include functions for getting and setting the integer values within each node. We would also want a Class to handle the singly-linked-list itself, and this Class would call upon the Node class and its methods in order to recreate the behavior of a singly-linked-list. In particular, we would want the singlyLinkedList (you could choose to name it something like this, for example) Class to be able to create a new Singly-Linked-List, to be able to add Nodes to the list, to delete Nodes from the list, etc. You could also consider using data structures like Arrays and ArrayLists to support your functions and simplify the coding process, but if you were to build the Singly-Linked-List from scratch, I would approach it similarly to how I described above. I am not sure what programming language you would like to use to build this solution, so I will try to be available if you need more detailed guidance when it comes to the specific coding parts. I mainly use Java myself, but I'll be happy to take a look and help you figure things out, regardless of the language you decide to use
Join our real-time social learning platform and learn together with your friends!