SlideShare a Scribd company logo
Add these methods to the code :
-Create at least three classes such as:
1. listnode- for data and link, constructors
2. Singlelinkedlist-for method definition
3. linkedlist-for objects
-Insert a node at tail/end in a linked list.
-Delete a node at a particular position in the list
code:
class listnodes{
int data;
listnodes link;
listnodes(){
data=0;
link=null;
}
listnodes(int d,listnodes l){
data=d;
link=l;
}
}
class singlelinkedlist{
public listnodes insertnode(int data,listnodes head){
listnodes newnode=new listnodes(data,null);
newnode.link=head;
head=newnode;
return head;
}
public listnodes insertAtPosition(listnodes head,int data,int position){
listnodes newnode=new listnodes(data,null);//create the newnode
listnodes previous=head;
int count=1;
while(count<=position-1)
{
previous=previous.link;
count++;
}
listnodes current=previous.link;
newnode.link=current;
previous.link=newnode;
return head;
}
public listnodes deletefirst(listnodes head){
listnodes pre=head;
head=head.link;
pre.link=null;
return pre;
}
public listnodes deletelast(listnodes head){
listnodes cur=head;
listnodes previouscur=head;
while(cur.link!=null){
previouscur=cur;
cur=cur.link;
}
previouscur.link=null;
return cur;
}
public int length(listnodes head)
{
listnodes current=head;
int c=0;
while(current!=null)
{
c++;
current=current.link;
}
return c;
}
public boolean find(listnodes head,int searchdata){
listnodes cur=head;
while(cur!=null)
{
if(cur.data==searchdata)
{
return true;
}
cur=cur.link;
}
return false;
}
void display(listnodes head){
listnodes current=head;
while(current.link!=null){
System.out.print(current.data+"-->");
current=current.link;
}
System.out.print(current.data);
}
}
public class LinkedList {
public static void main(String[] args) {
listnodes head=new listnodes(10,null);
singlelinkedlist sl=new singlelinkedlist();
sl.display(head);
System.out.println("n*****Insert at front*****");
listnodes newhead=sl.insertnode(20, head);
sl.display(newhead);
System.out.println("n*****Insert at a position*****");
sl.insertAtPosition(newhead, 40, 1);
sl.display(newhead);
}
}

More Related Content

Similar to Add these methods to the code - -Create at least three classes such.pdf

Abstract data types
Abstract data typesAbstract data types
Abstract data types
JAGDEEPKUMAR23
 
Lec3-Linked list.pptx
Lec3-Linked list.pptxLec3-Linked list.pptx
Lec3-Linked list.pptx
FaheemMahmood2
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
Komlin1
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
EricvtJFraserr
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
Waf1231
 
In this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdfIn this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdf
fantasiatheoutofthef
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
RashidFaridChishti
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
rohit219406
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
Himadri Sen Gupta
 
Linked list.docx
Linked list.docxLinked list.docx
Linked list.docx
EmilyMengich
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
Masud Parvaze
 
Using C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdfUsing C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdf
picscamshoppe
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
Khuram Shahzad
 
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
Can somebody solve the TODO parts of the following problem- Thanks   D.pdfCan somebody solve the TODO parts of the following problem- Thanks   D.pdf
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
vinaythemodel
 
linked-list.ppt
linked-list.pptlinked-list.ppt
linked-list.ppt
DikkySuryadiSKomMKom
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
eyewaregallery
 

Similar to Add these methods to the code - -Create at least three classes such.pdf (20)

Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Lec3-Linked list.pptx
Lec3-Linked list.pptxLec3-Linked list.pptx
Lec3-Linked list.pptx
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
List
ListList
List
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
In this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdfIn this assignment you will implement insert() method for a singly l.pdf
In this assignment you will implement insert() method for a singly l.pdf
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 
Linked list.docx
Linked list.docxLinked list.docx
Linked list.docx
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
Using C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdfUsing C++ use a linked list to create an alphabetical Conta.pdf
Using C++ use a linked list to create an alphabetical Conta.pdf
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
 
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
Can somebody solve the TODO parts of the following problem- Thanks   D.pdfCan somebody solve the TODO parts of the following problem- Thanks   D.pdf
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
 
linked-list.ppt
linked-list.pptlinked-list.ppt
linked-list.ppt
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 

More from SebastianRzuHarrisw

Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdfAge- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
SebastianRzuHarrisw
 
After the Sponsor submits the New Drug Application- the FDA may reques.pdf
After the Sponsor submits the New Drug Application- the FDA may reques.pdfAfter the Sponsor submits the New Drug Application- the FDA may reques.pdf
After the Sponsor submits the New Drug Application- the FDA may reques.pdf
SebastianRzuHarrisw
 
After reading the Technology Timeline answer the questions below in o.pdf
After reading the Technology Timeline  answer the questions below in o.pdfAfter reading the Technology Timeline  answer the questions below in o.pdf
After reading the Technology Timeline answer the questions below in o.pdf
SebastianRzuHarrisw
 
After researching the competitors of EJH Enterprises- you determine th (2).pdf
After researching the competitors of EJH Enterprises- you determine th (2).pdfAfter researching the competitors of EJH Enterprises- you determine th (2).pdf
After researching the competitors of EJH Enterprises- you determine th (2).pdf
SebastianRzuHarrisw
 
After listening to the opinions of her staff- Willa though through a v.pdf
After listening to the opinions of her staff- Willa though through a v.pdfAfter listening to the opinions of her staff- Willa though through a v.pdf
After listening to the opinions of her staff- Willa though through a v.pdf
SebastianRzuHarrisw
 
After learning about the Dietary Guidelines for Americans- Felix decid.pdf
After learning about the Dietary Guidelines for Americans- Felix decid.pdfAfter learning about the Dietary Guidelines for Americans- Felix decid.pdf
After learning about the Dietary Guidelines for Americans- Felix decid.pdf
SebastianRzuHarrisw
 
After analyzing the horrific killings of victims like Tyre Nichols and.pdf
After analyzing the horrific killings of victims like Tyre Nichols and.pdfAfter analyzing the horrific killings of victims like Tyre Nichols and.pdf
After analyzing the horrific killings of victims like Tyre Nichols and.pdf
SebastianRzuHarrisw
 
Advertising appeal The process of designing an effective advertising h.pdf
Advertising appeal The process of designing an effective advertising h.pdfAdvertising appeal The process of designing an effective advertising h.pdf
Advertising appeal The process of designing an effective advertising h.pdf
SebastianRzuHarrisw
 
Add a private variable SSN to the person class- Add a private variable.pdf
Add a private variable SSN to the person class- Add a private variable.pdfAdd a private variable SSN to the person class- Add a private variable.pdf
Add a private variable SSN to the person class- Add a private variable.pdf
SebastianRzuHarrisw
 
Add a WHERE clause to the end of the existing SQL that selects records.pdf
Add a WHERE clause to the end of the existing SQL that selects records.pdfAdd a WHERE clause to the end of the existing SQL that selects records.pdf
Add a WHERE clause to the end of the existing SQL that selects records.pdf
SebastianRzuHarrisw
 
Adams Company reports the following balance sheet accounts as of Decem (1).pdf
Adams Company reports the following balance sheet accounts as of Decem (1).pdfAdams Company reports the following balance sheet accounts as of Decem (1).pdf
Adams Company reports the following balance sheet accounts as of Decem (1).pdf
SebastianRzuHarrisw
 
Acute cystitis without hematuria- a- main term- b- diagnosis- Pulmon.pdf
Acute cystitis without hematuria- a- main term-  b- diagnosis-  Pulmon.pdfAcute cystitis without hematuria- a- main term-  b- diagnosis-  Pulmon.pdf
Acute cystitis without hematuria- a- main term- b- diagnosis- Pulmon.pdf
SebastianRzuHarrisw
 
Activity-Age Structure Graphs 4- What type of information can we obtai.pdf
Activity-Age Structure Graphs 4- What type of information can we obtai.pdfActivity-Age Structure Graphs 4- What type of information can we obtai.pdf
Activity-Age Structure Graphs 4- What type of information can we obtai.pdf
SebastianRzuHarrisw
 
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdfACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
SebastianRzuHarrisw
 
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdfAcme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
SebastianRzuHarrisw
 
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdfAceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
SebastianRzuHarrisw
 
Accounting was developed in the 20 th century- True False Question 8 (.pdf
Accounting was developed in the 20 th century- True False Question 8 (.pdfAccounting was developed in the 20 th century- True False Question 8 (.pdf
Accounting was developed in the 20 th century- True False Question 8 (.pdf
SebastianRzuHarrisw
 
Accountants for Morston- Inc have assembled the following data for the.pdf
Accountants for Morston- Inc have assembled the following data for the.pdfAccountants for Morston- Inc have assembled the following data for the.pdf
Accountants for Morston- Inc have assembled the following data for the.pdf
SebastianRzuHarrisw
 
According to the World Bank's year 2015 estimates of the Poverty Overv.pdf
According to the World Bank's year 2015 estimates of the Poverty Overv.pdfAccording to the World Bank's year 2015 estimates of the Poverty Overv.pdf
According to the World Bank's year 2015 estimates of the Poverty Overv.pdf
SebastianRzuHarrisw
 
According to Dale Jamieson- climate change challenges the current form.pdf
According to Dale Jamieson- climate change challenges the current form.pdfAccording to Dale Jamieson- climate change challenges the current form.pdf
According to Dale Jamieson- climate change challenges the current form.pdf
SebastianRzuHarrisw
 

More from SebastianRzuHarrisw (20)

Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdfAge- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
Age- 71 Gender- F History- Mrs S was referred by her internist for eva.pdf
 
After the Sponsor submits the New Drug Application- the FDA may reques.pdf
After the Sponsor submits the New Drug Application- the FDA may reques.pdfAfter the Sponsor submits the New Drug Application- the FDA may reques.pdf
After the Sponsor submits the New Drug Application- the FDA may reques.pdf
 
After reading the Technology Timeline answer the questions below in o.pdf
After reading the Technology Timeline  answer the questions below in o.pdfAfter reading the Technology Timeline  answer the questions below in o.pdf
After reading the Technology Timeline answer the questions below in o.pdf
 
After researching the competitors of EJH Enterprises- you determine th (2).pdf
After researching the competitors of EJH Enterprises- you determine th (2).pdfAfter researching the competitors of EJH Enterprises- you determine th (2).pdf
After researching the competitors of EJH Enterprises- you determine th (2).pdf
 
After listening to the opinions of her staff- Willa though through a v.pdf
After listening to the opinions of her staff- Willa though through a v.pdfAfter listening to the opinions of her staff- Willa though through a v.pdf
After listening to the opinions of her staff- Willa though through a v.pdf
 
After learning about the Dietary Guidelines for Americans- Felix decid.pdf
After learning about the Dietary Guidelines for Americans- Felix decid.pdfAfter learning about the Dietary Guidelines for Americans- Felix decid.pdf
After learning about the Dietary Guidelines for Americans- Felix decid.pdf
 
After analyzing the horrific killings of victims like Tyre Nichols and.pdf
After analyzing the horrific killings of victims like Tyre Nichols and.pdfAfter analyzing the horrific killings of victims like Tyre Nichols and.pdf
After analyzing the horrific killings of victims like Tyre Nichols and.pdf
 
Advertising appeal The process of designing an effective advertising h.pdf
Advertising appeal The process of designing an effective advertising h.pdfAdvertising appeal The process of designing an effective advertising h.pdf
Advertising appeal The process of designing an effective advertising h.pdf
 
Add a private variable SSN to the person class- Add a private variable.pdf
Add a private variable SSN to the person class- Add a private variable.pdfAdd a private variable SSN to the person class- Add a private variable.pdf
Add a private variable SSN to the person class- Add a private variable.pdf
 
Add a WHERE clause to the end of the existing SQL that selects records.pdf
Add a WHERE clause to the end of the existing SQL that selects records.pdfAdd a WHERE clause to the end of the existing SQL that selects records.pdf
Add a WHERE clause to the end of the existing SQL that selects records.pdf
 
Adams Company reports the following balance sheet accounts as of Decem (1).pdf
Adams Company reports the following balance sheet accounts as of Decem (1).pdfAdams Company reports the following balance sheet accounts as of Decem (1).pdf
Adams Company reports the following balance sheet accounts as of Decem (1).pdf
 
Acute cystitis without hematuria- a- main term- b- diagnosis- Pulmon.pdf
Acute cystitis without hematuria- a- main term-  b- diagnosis-  Pulmon.pdfAcute cystitis without hematuria- a- main term-  b- diagnosis-  Pulmon.pdf
Acute cystitis without hematuria- a- main term- b- diagnosis- Pulmon.pdf
 
Activity-Age Structure Graphs 4- What type of information can we obtai.pdf
Activity-Age Structure Graphs 4- What type of information can we obtai.pdfActivity-Age Structure Graphs 4- What type of information can we obtai.pdf
Activity-Age Structure Graphs 4- What type of information can we obtai.pdf
 
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdfACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
ACTIVITY 8- Fruit and seed anatomy (Student dissection or demonstratio.pdf
 
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdfAcme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
Acme Corp- filed Articles of Incorporation with the following authoriz (2).pdf
 
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdfAceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
Aceording to the Competere Exctuabon Pirislele- twe spiects awe unable.pdf
 
Accounting was developed in the 20 th century- True False Question 8 (.pdf
Accounting was developed in the 20 th century- True False Question 8 (.pdfAccounting was developed in the 20 th century- True False Question 8 (.pdf
Accounting was developed in the 20 th century- True False Question 8 (.pdf
 
Accountants for Morston- Inc have assembled the following data for the.pdf
Accountants for Morston- Inc have assembled the following data for the.pdfAccountants for Morston- Inc have assembled the following data for the.pdf
Accountants for Morston- Inc have assembled the following data for the.pdf
 
According to the World Bank's year 2015 estimates of the Poverty Overv.pdf
According to the World Bank's year 2015 estimates of the Poverty Overv.pdfAccording to the World Bank's year 2015 estimates of the Poverty Overv.pdf
According to the World Bank's year 2015 estimates of the Poverty Overv.pdf
 
According to Dale Jamieson- climate change challenges the current form.pdf
According to Dale Jamieson- climate change challenges the current form.pdfAccording to Dale Jamieson- climate change challenges the current form.pdf
According to Dale Jamieson- climate change challenges the current form.pdf
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 

Add these methods to the code - -Create at least three classes such.pdf

  • 1. Add these methods to the code : -Create at least three classes such as: 1. listnode- for data and link, constructors 2. Singlelinkedlist-for method definition 3. linkedlist-for objects -Insert a node at tail/end in a linked list. -Delete a node at a particular position in the list code: class listnodes{ int data; listnodes link; listnodes(){ data=0; link=null; } listnodes(int d,listnodes l){ data=d; link=l; } } class singlelinkedlist{ public listnodes insertnode(int data,listnodes head){ listnodes newnode=new listnodes(data,null); newnode.link=head; head=newnode; return head; } public listnodes insertAtPosition(listnodes head,int data,int position){ listnodes newnode=new listnodes(data,null);//create the newnode listnodes previous=head; int count=1; while(count<=position-1) { previous=previous.link;
  • 2. count++; } listnodes current=previous.link; newnode.link=current; previous.link=newnode; return head; } public listnodes deletefirst(listnodes head){ listnodes pre=head; head=head.link; pre.link=null; return pre; } public listnodes deletelast(listnodes head){ listnodes cur=head; listnodes previouscur=head; while(cur.link!=null){ previouscur=cur; cur=cur.link; } previouscur.link=null; return cur; } public int length(listnodes head) { listnodes current=head; int c=0; while(current!=null) { c++; current=current.link; } return c; } public boolean find(listnodes head,int searchdata){ listnodes cur=head; while(cur!=null) { if(cur.data==searchdata) { return true; } cur=cur.link; } return false;
  • 3. } void display(listnodes head){ listnodes current=head; while(current.link!=null){ System.out.print(current.data+"-->"); current=current.link; } System.out.print(current.data); } } public class LinkedList { public static void main(String[] args) { listnodes head=new listnodes(10,null); singlelinkedlist sl=new singlelinkedlist(); sl.display(head); System.out.println("n*****Insert at front*****"); listnodes newhead=sl.insertnode(20, head); sl.display(newhead); System.out.println("n*****Insert at a position*****"); sl.insertAtPosition(newhead, 40, 1); sl.display(newhead); } }