Q. How do you insert a node at the beginning of the list? (Solved)

1. public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(node);head.setnext(node);size++;}

2. public class insertfront(int data){node node = new node(data, head, head);node.getnext().setprev(node);head.setnext(node);size++;}

3. public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(head);head.setnext(node);size++;}

4. public class insertfront(int data){node node = new node(data, head, heagetnext());node.getnext().setprev(node);heasetnext(node.getnext());size++;}

  • a. public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(node);head.setnext(node);size++;}
Subscribe Now

Get All Updates & News