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

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
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
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
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🔝
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
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
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

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).