Posts

Showing posts from January, 2019

implementation of link list

Image
implementation of link list import java.util.Scanner; class Node{ public int data;//data public Node next;//next Node()//constructor { data=0; next=null; } Node(int data,Node next)//constructor { this.data=data; this.next=next; } //set data public void setData(int val) { data=val; } public Node setNext(Node n) {return next=n;} public int getData() {int val=data;return val;} public Node getNext() { return next;} public String toString() { return "data="+data; } }//end of node //class link list class LinkList{ public Node start; //starting node for reference public int size; //size of link list. LinkList(){start=null;size=0;} //empty public boolean isEmpty() { return start==null; } //size public int getSize() { return size; } //3 view list public void viewList() { Node temp; if(isEmpty()) { System.out.println("List is empty."); } else { temp=start; for(int i=1;i<=size;i++) { System.out.println(temp.g...

add three node at specific position

add three node at specific position Scanner in=new Scanner(System.in); //insert 3 node at a position public void add3Node() { System.out.println("enter postion:"); int position=in.nextInt(); if(position>0&&position<=size+1) { System.out.println("enter value of first node:"); int n1d=in.nextInt(); System.out.println("enter value of first node:"); int n2d=in.nextInt(); System.out.println("enter value of first node:"); int n3d=in.nextInt(); Node n3=new Node(n3d,null); Node n2=new Node(n2d,n3); Node n1=new Node(n1d,n2); if(position==1) { size++; size++; size++; if(size==0) { start=n1; } else { n3.setNext(start); start=n1; } } else if (position==size+1) { size++; size++; size++; Node t; t=start; while(t.getNext()!=null) { t=t.getNext(); } t.setNext(n1); } else { size...

delete at last position in java

delete at last position //delete at position. public void deleteAtPosition(int pos) { if(pos==1) deleteFirst(); else if(pos==size-1) deleteLast(); else if(pos<1||pos>size) { Node t; t=start; for(int i=1;i<=pos;i++) { t=t.getNext(); } } else System.out.println("Invalid input."); }

insert at last position in link list in java

insert at specific position //insert at position public void insertAtPosition(int val,int pos) { if(pos==1) { insertAtFirst(val); } else if(pos==size+1) { insertAtLast(val); } else if(pos>1&&pos<=size) { Node t,n; n=new Node(val,null); t=start; for(int i=1;i<pos-1;i++) { t=t.getNext(); } n.setNext(t.getNext()); t.setNext(n); size++; } else { System.out.println("Invalid position."); } }

all method of link list in java

link list link list is a dynamic data structure so in link list we can add element in run time.here we will implement how to implement node link list class Node{ public int data;//data public Node next;//next Node()//constructor { data=0; next=null; } Node(int data,Node next)//constructor { this.data=data; this.next=next; } //set data public void setData(int val) { data=val; } public Node setNext(Node n) {return next=n;} public int getData() {int val=data;return val;} public Node getNext() { return next;} public String toString() { return "data="+data; } }//end of node is link list is empty.  public boolean isEmpty() { return start==null; } add element at first position of link list. //insert at first position. public void insertAtFirst(int val) { Node tt=new Node(val,start); start=tt; size++; } //insert at last public void insertAtLast(int val) { Node n,t; t=start; n=new Node(val,null); if(isEmpty()) { sta...

earn money without any skills and investment.

Image
adsJob4U :  as also a website who clams that we give money of ads but  it is totally fake website so i search of website which give money of ads for your better understanding that how these website work.(what is the reality of ads) earn money on NeoBux registration with out any investment and skills you can earn money for more information watch video. sign up note:if you want to join these type of website first of all search in google its review. example  adsjob4U review neobux review for more information email:    hakimfazal426@gmail.com