Professional Documents
Culture Documents
import java.io.*;
class NODE
NODE()
link=null;
data=0;
FUNCTION:
import java.io.*;
class list
nnode.data=Integer.parseInt(br.readLine());
snode=start;
while(snode.link!=null)
snode=snode.link;
snode.link=nnode;
System.out.println("work done");
snode=start;
while(snode.link!=null)
snode=snode.link;
System.out.println(snode.data);
System.out.println("work done");
}
public void add_at_btw()throws IOException
int place;
place=Integer.parseInt(br.readLine());
nnode.data=Integer.parseInt(br.readLine());
int count=0;
snode=start;
while(snode.link!=null)
snode=snode.link;
count++;
if(count==place)
nnode.link=snode.link;
snode.link=nnode;
int value;
int count=0;
value=Integer.parseInt(br.readLine());
snode=start;
while(snode.link!=null)
snode=snode.link;
count++;
if(snode.data==value)
place=Integer.parseInt(br.readLine());
int count=0;
snode=start;
while(snode.link!=null)
snode=snode.link;
count++;
if(count==place)
snode.data=Integer.parseInt(br.readLine());
int value;
value=Integer.parseInt(br.readLine());
snode=start;
while(snode.link!=null)
snode=snode.link;
if(snode.data==value)
snode.data=Integer.parseInt(br.readLine());
WORKING:
import java.io.*;
class working
int choice;
System.out.println("enter choice:"+'\t'+"1.add at end"+'\t'+"2.to read"+'\t'+"3.add at between"+'\
t'+"4.search");
choice=Integer.parseInt(br.readLine());
while(choice!=0&&choice<7)
choice=Integer.parseInt(br.readLine());
switch(choice)
case 1:
a.add_at_end();
break;
case 2:
a.read();
break;
case 3:
a.add_at_btw();
break;
case 4:
a.search();
break;
case 5:
a.place_edit();
break;
case 6:
a.value_edit();
break;
default:
System.out.println("error");