SlideShare a Scribd company logo
code:
-----
public void add(int key, T value)
{
Link previous = null; // start at first
Link current = first;
// until end of list,
while( current != null && key > current.getKey() )
{ // or current > key,
previous = current;
current = current.next; // go to next item
}
if(previous==null) // if beginning of list,
first = theLink; // first --> new link
else // not at beginning,
previous.next = theLink; // prev --> new link
theLink.next = current; // new link --> current
}
Pseudo code:
------------
1. start from first node
Link current=first;
2. Traverse the hash table till the end of the list and
the key value becomes greater than the current key value,
and locate a position,called previous.
3. If the obtained position is null, make the new node as
first node. Place the value in that node.
4. if the position is not null,insert the new node as next
to previous node.
Solution
code:
-----
public void add(int key, T value)
{
Link previous = null; // start at first
Link current = first;
// until end of list,
while( current != null && key > current.getKey() )
{ // or current > key,
previous = current;
current = current.next; // go to next item
}
if(previous==null) // if beginning of list,
first = theLink; // first --> new link
else // not at beginning,
previous.next = theLink; // prev --> new link
theLink.next = current; // new link --> current
}
Pseudo code:
------------
1. start from first node
Link current=first;
2. Traverse the hash table till the end of the list and
the key value becomes greater than the current key value,
and locate a position,called previous.
3. If the obtained position is null, make the new node as
first node. Place the value in that node.
4. if the position is not null,insert the new node as next
to previous node.

More Related Content

Similar to code ----- public void add(int key, T value) { Link previou.pdf

1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf
sudhinjv
 
Linked List
Linked ListLinked List
Linked List
Md gulam sarwar
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
Mi 103 linked list
Mi 103 linked listMi 103 linked list
Mi 103 linked list
Amit Vats
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
fatoryoutlets
 
I have been tasked to write a code for a Singly Linked list that inc.pdf
I have been tasked to write a code for a Singly Linked list that inc.pdfI have been tasked to write a code for a Singly Linked list that inc.pdf
I have been tasked to write a code for a Singly Linked list that inc.pdf
arkmuzikllc
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
Programming Exam Help
 
please help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdfplease help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdf
aminbijal86
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
Khuram Shahzad
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
rohit219406
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
RashidFaridChishti
 
Let n = size of the hash table hashTable = array of size n, w.pdf
Let n = size of the hash table  hashTable = array of size n, w.pdfLet n = size of the hash table  hashTable = array of size n, w.pdf
Let n = size of the hash table hashTable = array of size n, w.pdf
aravlitraders2012
 
double Skiplist code below#include iostream#include vector.pdf
double Skiplist code below#include iostream#include vector.pdfdouble Skiplist code below#include iostream#include vector.pdf
double Skiplist code below#include iostream#include vector.pdf
txkev
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
 
Link list part 1
Link list part 1Link list part 1
Link list part 1
Anaya Zafar
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
tesmondday29076
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
 
using the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdfusing the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdf
RBMADU
 
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfHomework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
ezzi97
 

Similar to code ----- public void add(int key, T value) { Link previou.pdf (20)

1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf
 
Linked List
Linked ListLinked List
Linked List
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Mi 103 linked list
Mi 103 linked listMi 103 linked list
Mi 103 linked list
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
I have been tasked to write a code for a Singly Linked list that inc.pdf
I have been tasked to write a code for a Singly Linked list that inc.pdfI have been tasked to write a code for a Singly Linked list that inc.pdf
I have been tasked to write a code for a Singly Linked list that inc.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
please help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdfplease help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdf
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
 
Data Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdfData Structures in C++I am really new to C++, so links are really .pdf
Data Structures in C++I am really new to C++, so links are really .pdf
 
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptxData Structures and Agorithm: DS 05 Doubly Linked List.pptx
Data Structures and Agorithm: DS 05 Doubly Linked List.pptx
 
Let n = size of the hash table hashTable = array of size n, w.pdf
Let n = size of the hash table  hashTable = array of size n, w.pdfLet n = size of the hash table  hashTable = array of size n, w.pdf
Let n = size of the hash table hashTable = array of size n, w.pdf
 
double Skiplist code below#include iostream#include vector.pdf
double Skiplist code below#include iostream#include vector.pdfdouble Skiplist code below#include iostream#include vector.pdf
double Skiplist code below#include iostream#include vector.pdf
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 
Link list part 1
Link list part 1Link list part 1
Link list part 1
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
 
using the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdfusing the single linked list code written in the class or in the lab,.pdf
using the single linked list code written in the class or in the lab,.pdf
 
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfHomework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
 

More from annucommunication1

4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
annucommunication1
 
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
annucommunication1
 
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
annucommunication1
 
package patienttest;import java.util.Comparator; import java..pdf
 package patienttest;import java.util.Comparator; import java..pdf package patienttest;import java.util.Comparator; import java..pdf
package patienttest;import java.util.Comparator; import java..pdf
annucommunication1
 
ZnO + H2O = Zn(OH)2 .pdf
                     ZnO + H2O = Zn(OH)2                             .pdf                     ZnO + H2O = Zn(OH)2                             .pdf
ZnO + H2O = Zn(OH)2 .pdf
annucommunication1
 
will result in the formation of a soluble complex.pdf
                     will result in the formation of a soluble complex.pdf                     will result in the formation of a soluble complex.pdf
will result in the formation of a soluble complex.pdf
annucommunication1
 
What types of elements are involved in metallic b.pdf
                     What types of elements are involved in metallic b.pdf                     What types of elements are involved in metallic b.pdf
What types of elements are involved in metallic b.pdf
annucommunication1
 
The correct statements are When two atoms of app.pdf
                     The correct statements are  When two atoms of app.pdf                     The correct statements are  When two atoms of app.pdf
The correct statements are When two atoms of app.pdf
annucommunication1
 
Sure can There you go. .pdf
                     Sure can  There you go.                         .pdf                     Sure can  There you go.                         .pdf
Sure can There you go. .pdf
annucommunication1
 
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
annucommunication1
 
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
annucommunication1
 
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
annucommunication1
 
Eukaryotic Chromosome Structure The length of DN.pdf
                     Eukaryotic Chromosome Structure  The length of DN.pdf                     Eukaryotic Chromosome Structure  The length of DN.pdf
Eukaryotic Chromosome Structure The length of DN.pdf
annucommunication1
 
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
annucommunication1
 
D. is correct. Solution .pdf
                     D. is correct.  Solution                     .pdf                     D. is correct.  Solution                     .pdf
D. is correct. Solution .pdf
annucommunication1
 
The various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdfThe various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdf
annucommunication1
 
boiling point 1-propanol propanone note there.pdf
                     boiling point 1-propanol  propanone note there.pdf                     boiling point 1-propanol  propanone note there.pdf
boiling point 1-propanol propanone note there.pdf
annucommunication1
 
The organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdfThe organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdf
annucommunication1
 
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdfThe incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
annucommunication1
 
The answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdfThe answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdf
annucommunication1
 

More from annucommunication1 (20)

4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
 
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
 
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
 
package patienttest;import java.util.Comparator; import java..pdf
 package patienttest;import java.util.Comparator; import java..pdf package patienttest;import java.util.Comparator; import java..pdf
package patienttest;import java.util.Comparator; import java..pdf
 
ZnO + H2O = Zn(OH)2 .pdf
                     ZnO + H2O = Zn(OH)2                             .pdf                     ZnO + H2O = Zn(OH)2                             .pdf
ZnO + H2O = Zn(OH)2 .pdf
 
will result in the formation of a soluble complex.pdf
                     will result in the formation of a soluble complex.pdf                     will result in the formation of a soluble complex.pdf
will result in the formation of a soluble complex.pdf
 
What types of elements are involved in metallic b.pdf
                     What types of elements are involved in metallic b.pdf                     What types of elements are involved in metallic b.pdf
What types of elements are involved in metallic b.pdf
 
The correct statements are When two atoms of app.pdf
                     The correct statements are  When two atoms of app.pdf                     The correct statements are  When two atoms of app.pdf
The correct statements are When two atoms of app.pdf
 
Sure can There you go. .pdf
                     Sure can  There you go.                         .pdf                     Sure can  There you go.                         .pdf
Sure can There you go. .pdf
 
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
 
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
 
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
 
Eukaryotic Chromosome Structure The length of DN.pdf
                     Eukaryotic Chromosome Structure  The length of DN.pdf                     Eukaryotic Chromosome Structure  The length of DN.pdf
Eukaryotic Chromosome Structure The length of DN.pdf
 
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
 
D. is correct. Solution .pdf
                     D. is correct.  Solution                     .pdf                     D. is correct.  Solution                     .pdf
D. is correct. Solution .pdf
 
The various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdfThe various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdf
 
boiling point 1-propanol propanone note there.pdf
                     boiling point 1-propanol  propanone note there.pdf                     boiling point 1-propanol  propanone note there.pdf
boiling point 1-propanol propanone note there.pdf
 
The organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdfThe organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdf
 
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdfThe incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
 
The answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdfThe answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdf
 

Recently uploaded

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

code ----- public void add(int key, T value) { Link previou.pdf

  • 1. code: ----- public void add(int key, T value) { Link previous = null; // start at first Link current = first; // until end of list, while( current != null && key > current.getKey() ) { // or current > key, previous = current; current = current.next; // go to next item } if(previous==null) // if beginning of list, first = theLink; // first --> new link else // not at beginning, previous.next = theLink; // prev --> new link theLink.next = current; // new link --> current } Pseudo code: ------------ 1. start from first node Link current=first; 2. Traverse the hash table till the end of the list and the key value becomes greater than the current key value, and locate a position,called previous. 3. If the obtained position is null, make the new node as first node. Place the value in that node. 4. if the position is not null,insert the new node as next to previous node. Solution code: ----- public void add(int key, T value)
  • 2. { Link previous = null; // start at first Link current = first; // until end of list, while( current != null && key > current.getKey() ) { // or current > key, previous = current; current = current.next; // go to next item } if(previous==null) // if beginning of list, first = theLink; // first --> new link else // not at beginning, previous.next = theLink; // prev --> new link theLink.next = current; // new link --> current } Pseudo code: ------------ 1. start from first node Link current=first; 2. Traverse the hash table till the end of the list and the key value becomes greater than the current key value, and locate a position,called previous. 3. If the obtained position is null, make the new node as first node. Place the value in that node. 4. if the position is not null,insert the new node as next to previous node.