In a Link list how do I
1.write a method that returns nth element in the list
2.Search for a specific value in a list
3.Insert an element in front of the list
4. Remove an element by value
These my code so far
public class LinkList_A {
Node head; //---->Creating a variable that
is head which is a reference
public class Node{ ////---->Creating the node
class
int data ; //creating a
variable
Node next; //Creating
anaother variable, Node is just link to the next node,
Node(int d) // a node is just
what ever data we give it
{
data =
d; //the data becomes becomes what ever "d" value is
next =
null; //.next is null at the begining because there is nothing
pointing at it
//because the list is empty
}
}
public void push(int newData) {
Node newNode = new
Node(newData);
newNode.next = head;
newNode = head;
}
public int getItem(int number) {
}
In a Link list how do I 1.write a method that returns nth element in the list 2.Search for a specific value in a list 3.
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
In a Link list how do I 1.write a method that returns nth element in the list 2.Search for a specific value in a list 3.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!