SlideShare a Scribd company logo
1 of 2
Download to read offline
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 .pdfsudhinjv
 
Mi 103 linked list
Mi 103 linked listMi 103 linked list
Mi 103 linked listAmit 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.pdffatoryoutlets
 
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.pdfarkmuzikllc
 
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.pdfaminbijal86
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxMeghaKulkarni27
 
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 .pdfrohit219406
 
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.pptxRashidFaridChishti
 
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.pdfaravlitraders2012
 
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.pdftxkev
 
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 1Anaya 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.pdftesmondday29076
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfKylaMaeGarcia1
 
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,.pdfRBMADU
 
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.pdfezzi97
 

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

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

Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 

Recently uploaded (20)

Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 

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.