SlideShare a Scribd company logo
1 of 4
Download to read offline
Solve using java and using this Singly linked list class:
public class SLL {
private class SLLNode {
private T info;
private SLLNode next;
public SLLNode() {
this(null,null);
}
public SLLNode(T el) {
this(el,null);
}
public SLLNode(T el, SLLNode ptr) {
info = el; next = ptr;
}
}
protected SLLNode head, tail;
public SLL() {
head = tail = null;
}
public boolean isEmpty() {
return head == null;
}
public void addToHead(T el) {
head = new SLLNode(el,head);
if (tail == null)
tail = head;
}
public void addToTail(T el) {
if (!isEmpty()) {
tail.next = new SLLNode(el);
tail = tail.next;
}
else head = tail = new SLLNode(el);
}
public T deleteFromHead() { // delete the head and return its info;
if (isEmpty())
return null;
T el = head.info;
if (head == tail) // if only one node on the list;
head = tail = null;
else head = head.next;
return el;
}
public T deleteFromTail() { // delete the tail and return its info;
if (isEmpty())
return null;
T el = tail.info;
if (head == tail) // if only one node in the list;
head = tail = null;
else { // if more than one node in the list,
SLLNode tmp; // find the predecessor of tail;
for (tmp = head; tmp.next != tail; tmp = tmp.next);
tail = tmp; // the predecessor of tail becomes tail;
tail.next = null;
}
return el;
}
public void delete(T el) { // delete the node with an element el;
if (!isEmpty())
if (head == tail && el.equals(head.info)) // if only one
head = tail = null; // node on the list;
else if (el.equals(head.info)) // if more than one node on the list;
head = head.next; // and el is in the head node;
else { // if more than one node in the list
SLLNode pred, tmp;// and el is in a nonhead node;
for (pred = head, tmp = head.next;
tmp != null && !tmp.info.equals(el);
pred = pred.next, tmp = tmp.next);
if (tmp != null) { // if el was found;
pred.next = tmp.next;
if (tmp == tail) // if el is in the last node;
tail = pred;
}
}
}
@Override
public String toString() {
if(head == null)
return "[ ]";
String str = "[ ";
SLLNode tmp = head;
while(tmp != null){
str += tmp.info + " ";
tmp = tmp.next;
}
return str+"]";
}
public boolean contains(T el) {
if(head == null)
return false;
SLLNode tmp = head;
while(tmp != null){
if(tmp.info.equals(el))
return true;
tmp = tmp.next;
}
return false;
}
public int size(){
if(head == null)
return 0;
int count = 0;
SLLNode p = head;
while(p != null) {
count++;
p = p.next;
}
return count;
}
} The following Questions have to be Solved and Submitted: Part I: Programming ( 50 points)
Use the singly linked list class introduced in the lab to implement integers of unlimited size.
Each node of the list should store one digit of the integer. You are to implement the addition,
subtraction and multiplication operations. Please note that any additional data structure to be
used in solving this problem has to be taken from the ones introduced in the ICS 202 lab. In
addition, provide a test class that will do the following: It will keep asking the user to enter two
integers, choose one of the operations (addition, subtraction, multiplication) and then display the
result. The program will stop upon entering the "#" character (without the double quotes).

More Related Content

Similar to Solve using java and using this Singly linked list classpublic cl.pdf

Create your own Linked list from scratch (singly linked list).So.pdf
Create your own Linked list from scratch (singly linked list).So.pdfCreate your own Linked list from scratch (singly linked list).So.pdf
Create your own Linked list from scratch (singly linked list).So.pdfarumugambags
 
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdffortmdu
 
You can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdfYou can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdffashionbigchennai
 
#include node1.h #include list.h #include cassert P.pdf
#include node1.h #include list.h #include cassert  P.pdf#include node1.h #include list.h #include cassert  P.pdf
#include node1.h #include list.h #include cassert P.pdfaquacosmossystems
 
Solutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfSolutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfrakeshankur
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdfankitmobileshop235
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptxchin463670
 
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfI keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfarkmuzikllc
 
Write the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdfWrite the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdffckindswear
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdffootstatus
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docxMARRY7
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find excitingRobert MacLean
 

Similar to Solve using java and using this Singly linked list classpublic cl.pdf (20)

Create your own Linked list from scratch (singly linked list).So.pdf
Create your own Linked list from scratch (singly linked list).So.pdfCreate your own Linked list from scratch (singly linked list).So.pdf
Create your own Linked list from scratch (singly linked list).So.pdf
 
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
 
You can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdfYou can list anything, it doesnt matter. I just want to see code f.pdf
You can list anything, it doesnt matter. I just want to see code f.pdf
 
#include node1.h #include list.h #include cassert P.pdf
#include node1.h #include list.h #include cassert  P.pdf#include node1.h #include list.h #include cassert  P.pdf
#include node1.h #include list.h #include cassert P.pdf
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
Solutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfSolutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
 
Ll.pptx
Ll.pptxLl.pptx
Ll.pptx
 
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfI keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
 
Write the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdfWrite the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdf
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
 
Linked Stack program.docx
Linked Stack program.docxLinked Stack program.docx
Linked Stack program.docx
 
Linked lists
Linked listsLinked lists
Linked lists
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docx
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find exciting
 

More from aloeplusint

Starware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdfStarware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdfaloeplusint
 
Some obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdfSome obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdfaloeplusint
 
Sophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdfSophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdfaloeplusint
 
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdfSQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdfaloeplusint
 
SQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdfSQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdfaloeplusint
 
Some of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdfSome of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdfaloeplusint
 
Southeastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdfSoutheastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdfaloeplusint
 
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdfSorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdfaloeplusint
 
Subject Computer Architecture & Organization Q-4 Assume that .pdf
Subject Computer Architecture & Organization  Q-4 Assume that .pdfSubject Computer Architecture & Organization  Q-4 Assume that .pdf
Subject Computer Architecture & Organization Q-4 Assume that .pdfaloeplusint
 
Subject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdfSubject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdfaloeplusint
 
Subject Computer Architecture & Organization i. Show the con.pdf
Subject Computer Architecture & Organization  i. Show the con.pdfSubject Computer Architecture & Organization  i. Show the con.pdf
Subject Computer Architecture & Organization i. Show the con.pdfaloeplusint
 
Solve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdfSolve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdfaloeplusint
 
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdfSu clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdfaloeplusint
 
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdfSu compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdfaloeplusint
 
Study the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdfStudy the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdfaloeplusint
 
study of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdfstudy of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdfaloeplusint
 
Start Program like this Chapter 7 Validate Password import.pdf
Start Program like this  Chapter 7 Validate Password import.pdfStart Program like this  Chapter 7 Validate Password import.pdf
Start Program like this Chapter 7 Validate Password import.pdfaloeplusint
 
Students may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdfStudents may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdfaloeplusint
 
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdfStevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdfaloeplusint
 
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfaloeplusint
 

More from aloeplusint (20)

Starware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdfStarware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdf
 
Some obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdfSome obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdf
 
Sophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdfSophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdf
 
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdfSQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
 
SQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdfSQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdf
 
Some of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdfSome of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdf
 
Southeastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdfSoutheastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdf
 
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdfSorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
 
Subject Computer Architecture & Organization Q-4 Assume that .pdf
Subject Computer Architecture & Organization  Q-4 Assume that .pdfSubject Computer Architecture & Organization  Q-4 Assume that .pdf
Subject Computer Architecture & Organization Q-4 Assume that .pdf
 
Subject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdfSubject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdf
 
Subject Computer Architecture & Organization i. Show the con.pdf
Subject Computer Architecture & Organization  i. Show the con.pdfSubject Computer Architecture & Organization  i. Show the con.pdf
Subject Computer Architecture & Organization i. Show the con.pdf
 
Solve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdfSolve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdf
 
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdfSu clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
 
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdfSu compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
 
Study the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdfStudy the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdf
 
study of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdfstudy of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdf
 
Start Program like this Chapter 7 Validate Password import.pdf
Start Program like this  Chapter 7 Validate Password import.pdfStart Program like this  Chapter 7 Validate Password import.pdf
Start Program like this Chapter 7 Validate Password import.pdf
 
Students may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdfStudents may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdf
 
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdfStevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
 
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Solve using java and using this Singly linked list classpublic cl.pdf

  • 1. Solve using java and using this Singly linked list class: public class SLL { private class SLLNode { private T info; private SLLNode next; public SLLNode() { this(null,null); } public SLLNode(T el) { this(el,null); } public SLLNode(T el, SLLNode ptr) { info = el; next = ptr; } } protected SLLNode head, tail; public SLL() { head = tail = null; } public boolean isEmpty() { return head == null; } public void addToHead(T el) { head = new SLLNode(el,head); if (tail == null) tail = head; } public void addToTail(T el) { if (!isEmpty()) { tail.next = new SLLNode(el); tail = tail.next; } else head = tail = new SLLNode(el);
  • 2. } public T deleteFromHead() { // delete the head and return its info; if (isEmpty()) return null; T el = head.info; if (head == tail) // if only one node on the list; head = tail = null; else head = head.next; return el; } public T deleteFromTail() { // delete the tail and return its info; if (isEmpty()) return null; T el = tail.info; if (head == tail) // if only one node in the list; head = tail = null; else { // if more than one node in the list, SLLNode tmp; // find the predecessor of tail; for (tmp = head; tmp.next != tail; tmp = tmp.next); tail = tmp; // the predecessor of tail becomes tail; tail.next = null; } return el; } public void delete(T el) { // delete the node with an element el; if (!isEmpty()) if (head == tail && el.equals(head.info)) // if only one head = tail = null; // node on the list; else if (el.equals(head.info)) // if more than one node on the list; head = head.next; // and el is in the head node; else { // if more than one node in the list SLLNode pred, tmp;// and el is in a nonhead node; for (pred = head, tmp = head.next; tmp != null && !tmp.info.equals(el); pred = pred.next, tmp = tmp.next); if (tmp != null) { // if el was found;
  • 3. pred.next = tmp.next; if (tmp == tail) // if el is in the last node; tail = pred; } } } @Override public String toString() { if(head == null) return "[ ]"; String str = "[ "; SLLNode tmp = head; while(tmp != null){ str += tmp.info + " "; tmp = tmp.next; } return str+"]"; } public boolean contains(T el) { if(head == null) return false; SLLNode tmp = head; while(tmp != null){ if(tmp.info.equals(el)) return true; tmp = tmp.next; } return false; } public int size(){ if(head == null) return 0;
  • 4. int count = 0; SLLNode p = head; while(p != null) { count++; p = p.next; } return count; } } The following Questions have to be Solved and Submitted: Part I: Programming ( 50 points) Use the singly linked list class introduced in the lab to implement integers of unlimited size. Each node of the list should store one digit of the integer. You are to implement the addition, subtraction and multiplication operations. Please note that any additional data structure to be used in solving this problem has to be taken from the ones introduced in the ICS 202 lab. In addition, provide a test class that will do the following: It will keep asking the user to enter two integers, choose one of the operations (addition, subtraction, multiplication) and then display the result. The program will stop upon entering the "#" character (without the double quotes).