SlideShare a Scribd company logo
1 of 4
Download to read offline
Using Java programming language solve the following:
SLL CLASS:
//************************** SLL.java *********************************
// a generic 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;
}
}
Part I: Programming Use the singly linked list class (Given below) to implement integers of
unlimited size. Each node of the list should store one digit of the integer. You are required to
implement the addition, subtraction and multiplication operations. 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). Part II: Problem Solving
With respect to the programming problem in Part I , What is the tightest asymptotic running time
for each of your operations, expressed in terms of the number of digits for the two operands, m
and n, of each operation? Clearly justify your answer.

More Related Content

Similar to Using Java programming language solve the followingSLL CLASS.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 {.pdffortmdu
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdffathimafancyjeweller
 
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
 
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
 
fix the error - class Node{ int data- Node next-.pdf
fix the error -   class Node{           int data-           Node next-.pdffix the error -   class Node{           int data-           Node next-.pdf
fix the error - class Node{ int data- Node next-.pdfAKVIGFOEU
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find excitingRobert MacLean
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldBTI360
 
how do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdfhow do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdffootwearpark
 
#include sstream #include linkylist.h #include iostream.pdf
#include sstream #include linkylist.h #include iostream.pdf#include sstream #include linkylist.h #include iostream.pdf
#include sstream #include linkylist.h #include iostream.pdfaravlitraders2012
 
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
 
tested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdftested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdfshanki7
 
^^^ Discuss about Header Node And also write a program for unorder.pdf
^^^ Discuss about Header Node  And also write a program for unorder.pdf^^^ Discuss about Header Node  And also write a program for unorder.pdf
^^^ Discuss about Header Node And also write a program for unorder.pdfarihantmum
 
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
 
Discuss about Header Node And also write a program for unordered si.pdf
Discuss about Header Node  And also write a program for unordered si.pdfDiscuss about Header Node  And also write a program for unordered si.pdf
Discuss about Header Node And also write a program for unordered si.pdfeyevision3
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfaksahnan
 

Similar to Using Java programming language solve the followingSLL CLASS.pdf (20)

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
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
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
 
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
 
fix the error - class Node{ int data- Node next-.pdf
fix the error -   class Node{           int data-           Node next-.pdffix the error -   class Node{           int data-           Node next-.pdf
fix the error - class Node{ int data- Node next-.pdf
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find exciting
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
how do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdfhow do i expand upon selectionSortType so that you are no longer bou.pdf
how do i expand upon selectionSortType so that you are no longer bou.pdf
 
#include sstream #include linkylist.h #include iostream.pdf
#include sstream #include linkylist.h #include iostream.pdf#include sstream #include linkylist.h #include iostream.pdf
#include sstream #include linkylist.h #include iostream.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
 
tested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdftested on eclipseDoublyLinkedList class.pdf
tested on eclipseDoublyLinkedList class.pdf
 
^^^ Discuss about Header Node And also write a program for unorder.pdf
^^^ Discuss about Header Node  And also write a program for unorder.pdf^^^ Discuss about Header Node  And also write a program for unorder.pdf
^^^ Discuss about Header Node And also write a program for unorder.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
 
Linked Stack program.docx
Linked Stack program.docxLinked Stack program.docx
Linked Stack program.docx
 
Discuss about Header Node And also write a program for unordered si.pdf
Discuss about Header Node  And also write a program for unordered si.pdfDiscuss about Header Node  And also write a program for unordered si.pdf
Discuss about Header Node And also write a program for unordered si.pdf
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
 

More from adonisjpr

Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdfUna mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdfadonisjpr
 
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdfUna empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdfadonisjpr
 
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdfUna empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdfadonisjpr
 
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0  1 pun.pdfUna cartera eficiente es una combinaci�n de activos que 0  1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdfadonisjpr
 
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdfUn objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdfadonisjpr
 
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdfTyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdfadonisjpr
 
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdfUn informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdfadonisjpr
 
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdfubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdfadonisjpr
 
Two categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdfTwo categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdfadonisjpr
 
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdfTwitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdfadonisjpr
 
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdfTurner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdfadonisjpr
 
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdfUber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdfadonisjpr
 
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdfTrilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdfadonisjpr
 
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdfTransforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdfadonisjpr
 
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdfUsing the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdfadonisjpr
 
Using the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdfUsing the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdfadonisjpr
 
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdfusing silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdfadonisjpr
 
Using financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdfUsing financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdfadonisjpr
 
using IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdfusing IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdfadonisjpr
 
using IRAC method Mary is an explorer and is about to set off on a.pdf
using IRAC method Mary is an explorer and is about to set off on a.pdfusing IRAC method Mary is an explorer and is about to set off on a.pdf
using IRAC method Mary is an explorer and is about to set off on a.pdfadonisjpr
 

More from adonisjpr (20)

Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdfUna mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
Una mujer de 36 a�os que se someti� a un trasplante de ri��n hace 2 .pdf
 
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdfUna empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
Una empresa tiene un ciclo operativo de 120 d�as, un per�odo promedi.pdf
 
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdfUna empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
Una empresa pag� por �ltima vez un dividendo de �3. Si el rendimient.pdf
 
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0  1 pun.pdfUna cartera eficiente es una combinaci�n de activos que 0  1 pun.pdf
Una cartera eficiente es una combinaci�n de activos que 0 1 pun.pdf
 
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdfUn objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
Un objetivo a corto plazo esOpci�n multiple A) una meta espec.pdf
 
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdfTyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
Tyco International, una empresa de fabricaci�n, demand� a su ex dire.pdf
 
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdfUn informe de an�lisis de estados financieros no incluye A) una dec.pdf
Un informe de an�lisis de estados financieros no incluye A) una dec.pdf
 
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdfubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
ubat 2015te Hazine 4 78lik 2044 alt aylk bileik vadeye kadar 2,8.pdf
 
Two categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdfTwo categories of attackers include hacktivists and state actors. .pdf
Two categories of attackers include hacktivists and state actors. .pdf
 
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdfTwitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
Twitter, el popular sitio de microblogs, se ha enfrentado a graves c.pdf
 
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdfTurner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
Turner, Roth y Lowe son socios que comparten ingresos y p�rdidas en .pdf
 
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdfUber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
Uber - Bir Startupn K�kenleri ve lk G�nleriDava M�terileri ele.pdf
 
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdfTrilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
Trilogy Enterprises Inc. de Austin, Texas, es una empresa de softwar.pdf
 
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdfTransforming Data - Creating a Data Set Creating a JOIN between two .pdf
Transforming Data - Creating a Data Set Creating a JOIN between two .pdf
 
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdfUsing the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
Using the location quotients(LQ) for year 2020 for 10 provinces anal.pdf
 
Using the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdfUsing the packet tracer simulator, create a network topology that in.pdf
Using the packet tracer simulator, create a network topology that in.pdf
 
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdfusing silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
using silde 2 to answer silde 1 and 3 Step 17 of 40 - Create T Accou.pdf
 
Using financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdfUsing financial data and information from Yahoo Finance only, calcul.pdf
Using financial data and information from Yahoo Finance only, calcul.pdf
 
using IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdfusing IRAC method Joseph was a team manager of an excursion in the O.pdf
using IRAC method Joseph was a team manager of an excursion in the O.pdf
 
using IRAC method Mary is an explorer and is about to set off on a.pdf
using IRAC method Mary is an explorer and is about to set off on a.pdfusing IRAC method Mary is an explorer and is about to set off on a.pdf
using IRAC method Mary is an explorer and is about to set off on a.pdf
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.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
 
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🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
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
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
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🔝
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

Using Java programming language solve the followingSLL CLASS.pdf

  • 1. Using Java programming language solve the following: SLL CLASS: //************************** SLL.java ********************************* // a generic 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;
  • 2. } 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;
  • 3. 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;
  • 4. 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; } } Part I: Programming Use the singly linked list class (Given below) to implement integers of unlimited size. Each node of the list should store one digit of the integer. You are required to implement the addition, subtraction and multiplication operations. 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). Part II: Problem Solving With respect to the programming problem in Part I , What is the tightest asymptotic running time for each of your operations, expressed in terms of the number of digits for the two operands, m and n, of each operation? Clearly justify your answer.