SlideShare a Scribd company logo
1 of 21
Download to read offline
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
Double Lists 
Data 
next 
prev 
L_S 
Data 
next 
prev 
Data 
prev 
prev 
next 
next 
Data 
L_E
Definition 
Type 
D_P = ^D_R; 
D_R = Record 
ID:integer; 
next:D_P; 
prev:D_P; 
end; 
var 
L_S, L_E : D_P;
Double Lists Procedures: 
1) Insert a Node 
2) Delete a Node 
3) Search Node
Insert a Node 
Data 
next 
prev 
Data 
next 
prev 
Data 
next 
prev 
Data 
next 
prev 
L_E 
Data 
next 
prev 
L_S 
Temp
1) 
L_S 
Nil 
15 
next 
prev 
Temp 
L_E
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
2) 
L_S 
S 
L_E 
Temp
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
3) 
L_S 
S 
L_E 
2 
next 
prev 
Temp
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
L_S 
S 
L_E 
2 
next 
prev 
Nil 
4) 
Temp
procedure D_L_Insert ( var L_S, L_E: D_P; KEY:integer); 
var 
Temp , S : D_P; 
Located: Boolean; 
begin 
new(Temp); 
temp^.ID:=KEY; 
temp^.next:=nil; 
temp^.prev:=nil; 
15 
next 
prev 
Temp
If L_S=nil then 
begin 
L_S:=Temp; 
L_E:=Temp; 
end 
Else 
begin 
S:=L_S; 
Located:=False; 
while (S<>nil) and (not Located) do 
if S^.id < key then 
S:=S^.next 
else 
Located:=True; 
Temp^.next:=S; 
+2 points
If S=L_S then 
begin 
L_S^.prev:=Temp; 
L_S:=Temp; 
end 
Else if S=nil then 
begin 
Temp^.prev := L_E; 
L_E^.next := Temp; 
L_E:=Temp; 
end 
Else 
begin 
Temp^.prev := S^.prev; 
S^.prev^.next := Temp; 
S^.prev := Temp; 
end; 
end; 
end; {procedure}
1) 
L_S 
Nil 
Delete a Node 
flag 
3 
L_E
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
L_S 
L_E 
key 
3 
2) 
temp 
3 
next 
prev 
L_S 
Nil 
temp 
L_E 
flag 
2
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
L_S 
L_E 
temp 
3) 
falg 
2 
key 
20
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
L_S 
L_E 
4) 
flag 
2 
key 
15 
S
3 
next 
prev 
20 
next 
prev 
15 
next 
prev 
L_S 
L_E 
Nil 
flag 
1 
key 
99 
5) 
S
procedure D_L_Delete ( var L_S,L_E: D_P; KEY:integer; var flag :char); 
var 
Temp , S:D_P; 
begin 
If L_S=nil then 
flag:=‘3’ 
Else if KEY =L_S^.id then 
begin 
Temp:=L_S; 
L_S:=L_S^.next; ls^.prev:=nill ; 
Dispose(Temp); 
flag:=‘2’; 
If L_s=nil then 
L_E:=nil; 
Else 
L_s^.prev:=nil; 
end
Else if KEY = L_E^.id then 
begin 
Temp:=L_E; 
L_E:=L_E^.prev; L_E^.next:=nil; Dispose(Temp); 
Flag:=‘2’; 
end 
Else 
begin 
S:=L_S; 
while (S<>nil) and (S^.id <> KEY ) do 
S:=S^.next; 
if S=nil then 
flag:=‘1’; 
else 
begin 
S^.next^.prev:=S^.prev; 
S^.prev^.next:=S^.next; Dispose(S); 
flag:=‘ 2 ’; 
end; 
end; 
end; {procedure}
Homework: 
+15 points 
اكتب اجرائية البحث عه عنصر ما في سلسة مترابطة 
مه طرفيه : 
Search( var L_s, L_E : D_P ; Key:integer; 
var p: D_P ; var flag: char); 
بحيث تحفظ الاجرائية مؤشر على مكان العنصر المراد, 
وتعيد محرف يعبر عه حالة البحث ) فشل-وجد العنصر- 
السلسلة فارغة(
Group : group link 
Mobile phone- Kinan : 0994385748 
Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot

Suffix Array 構築方法の紹介
Suffix Array 構築方法の紹介Suffix Array 構築方法の紹介
Suffix Array 構築方法の紹介
Takashi Hoshino
 
Lisp programming
Lisp programmingLisp programming
Lisp programming
ilias ahmed
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
Syed Umair
 

What's hot (12)

Suffix Array 構築方法の紹介
Suffix Array 構築方法の紹介Suffix Array 構築方法の紹介
Suffix Array 構築方法の紹介
 
Hello, Type Systems! - Introduction to Featherweight Java
Hello, Type Systems! - Introduction to Featherweight JavaHello, Type Systems! - Introduction to Featherweight Java
Hello, Type Systems! - Introduction to Featherweight Java
 
Ch17
Ch17Ch17
Ch17
 
Promise of an API
Promise of an APIPromise of an API
Promise of an API
 
Lisp programming
Lisp programmingLisp programming
Lisp programming
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
8.2
8.28.2
8.2
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using C
 
Periodic pattern mining
Periodic pattern miningPeriodic pattern mining
Periodic pattern mining
 

Viewers also liked (7)

2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
New Orleans: Nature, Culture and the City
New Orleans: Nature, Culture and the CityNew Orleans: Nature, Culture and the City
New Orleans: Nature, Culture and the City
 
E learning y b-learning
E learning y b-learningE learning y b-learning
E learning y b-learning
 
Ppt mediasi bab kerukunan (shinta ariyana pratiwi 021)
Ppt mediasi bab kerukunan (shinta ariyana pratiwi 021)Ppt mediasi bab kerukunan (shinta ariyana pratiwi 021)
Ppt mediasi bab kerukunan (shinta ariyana pratiwi 021)
 
Farmacología ginecólogica
Farmacología ginecólogica Farmacología ginecólogica
Farmacología ginecólogica
 
Apuntes funciones 1º bach míos
Apuntes funciones 1º bach   míosApuntes funciones 1º bach   míos
Apuntes funciones 1º bach míos
 
Finca Kosovo - The recommendation Letter from ICM
Finca Kosovo - The recommendation Letter  from ICMFinca Kosovo - The recommendation Letter  from ICM
Finca Kosovo - The recommendation Letter from ICM
 

Similar to 2Bytesprog2 course_2014_c7_double_lists

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
fortmdu
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
bolovv
 
TableDrivenProg_20160714
TableDrivenProg_20160714TableDrivenProg_20160714
TableDrivenProg_20160714
Teddy Hsiung
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
vijaydeepakg
 

Similar to 2Bytesprog2 course_2014_c7_double_lists (17)

Double linked list c8
Double linked list c8Double linked list c8
Double linked list c8
 
Ch8a
Ch8aCh8a
Ch8a
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
12IRGeneration.pdf
12IRGeneration.pdf12IRGeneration.pdf
12IRGeneration.pdf
 
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdfPlease finish the int LLInsert function.typedef struct STUDENT {.pdf
Please finish the int LLInsert function.typedef struct STUDENT {.pdf
 
Linked lists c7
Linked lists c7Linked lists c7
Linked lists c7
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
 
Ch8b
Ch8bCh8b
Ch8b
 
Generating code from dags
Generating code from dagsGenerating code from dags
Generating code from dags
 
The TclQuadcode Compiler
The TclQuadcode CompilerThe TclQuadcode Compiler
The TclQuadcode Compiler
 
TableDrivenProg_20160714
TableDrivenProg_20160714TableDrivenProg_20160714
TableDrivenProg_20160714
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 
Big O Notation.ppt
Big O Notation.pptBig O Notation.ppt
Big O Notation.ppt
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisEuclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
 
Plsql programs
Plsql programsPlsql programs
Plsql programs
 
Digital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDLDigital to analog -Sqaure waveform generator in VHDL
Digital to analog -Sqaure waveform generator in VHDL
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
 

More from kinan keshkeh

More from kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 

Recently uploaded

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

2Bytesprog2 course_2014_c7_double_lists

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 2. Double Lists Data next prev L_S Data next prev Data prev prev next next Data L_E
  • 3. Definition Type D_P = ^D_R; D_R = Record ID:integer; next:D_P; prev:D_P; end; var L_S, L_E : D_P;
  • 4. Double Lists Procedures: 1) Insert a Node 2) Delete a Node 3) Search Node
  • 5. Insert a Node Data next prev Data next prev Data next prev Data next prev L_E Data next prev L_S Temp
  • 6. 1) L_S Nil 15 next prev Temp L_E
  • 7. 3 next prev 20 next prev 15 next prev 2) L_S S L_E Temp
  • 8. 3 next prev 20 next prev 15 next prev 3) L_S S L_E 2 next prev Temp
  • 9. 3 next prev 20 next prev 15 next prev L_S S L_E 2 next prev Nil 4) Temp
  • 10. procedure D_L_Insert ( var L_S, L_E: D_P; KEY:integer); var Temp , S : D_P; Located: Boolean; begin new(Temp); temp^.ID:=KEY; temp^.next:=nil; temp^.prev:=nil; 15 next prev Temp
  • 11. If L_S=nil then begin L_S:=Temp; L_E:=Temp; end Else begin S:=L_S; Located:=False; while (S<>nil) and (not Located) do if S^.id < key then S:=S^.next else Located:=True; Temp^.next:=S; +2 points
  • 12. If S=L_S then begin L_S^.prev:=Temp; L_S:=Temp; end Else if S=nil then begin Temp^.prev := L_E; L_E^.next := Temp; L_E:=Temp; end Else begin Temp^.prev := S^.prev; S^.prev^.next := Temp; S^.prev := Temp; end; end; end; {procedure}
  • 13. 1) L_S Nil Delete a Node flag 3 L_E
  • 14. 3 next prev 20 next prev 15 next prev L_S L_E key 3 2) temp 3 next prev L_S Nil temp L_E flag 2
  • 15. 3 next prev 20 next prev 15 next prev L_S L_E temp 3) falg 2 key 20
  • 16. 3 next prev 20 next prev 15 next prev L_S L_E 4) flag 2 key 15 S
  • 17. 3 next prev 20 next prev 15 next prev L_S L_E Nil flag 1 key 99 5) S
  • 18. procedure D_L_Delete ( var L_S,L_E: D_P; KEY:integer; var flag :char); var Temp , S:D_P; begin If L_S=nil then flag:=‘3’ Else if KEY =L_S^.id then begin Temp:=L_S; L_S:=L_S^.next; ls^.prev:=nill ; Dispose(Temp); flag:=‘2’; If L_s=nil then L_E:=nil; Else L_s^.prev:=nil; end
  • 19. Else if KEY = L_E^.id then begin Temp:=L_E; L_E:=L_E^.prev; L_E^.next:=nil; Dispose(Temp); Flag:=‘2’; end Else begin S:=L_S; while (S<>nil) and (S^.id <> KEY ) do S:=S^.next; if S=nil then flag:=‘1’; else begin S^.next^.prev:=S^.prev; S^.prev^.next:=S^.next; Dispose(S); flag:=‘ 2 ’; end; end; end; {procedure}
  • 20. Homework: +15 points اكتب اجرائية البحث عه عنصر ما في سلسة مترابطة مه طرفيه : Search( var L_s, L_E : D_P ; Key:integer; var p: D_P ; var flag: char); بحيث تحفظ الاجرائية مؤشر على مكان العنصر المراد, وتعيد محرف يعبر عه حالة البحث ) فشل-وجد العنصر- السلسلة فارغة(
  • 21. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team