SlideShare una empresa de Scribd logo
1 de 15
Abstract Data Types:
Lists
List
• A List is a sequence of zero or
more elements.
a1, a2, a3, a4, ………..,an
Where n  0,
a1 is the first element
an is the last element
n is length of the list
if n = 0, the list is empty (no
element)
Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 2
More about lists
• Elements are linearly ordered.
ai precedes ai+1
for i = 1, 2, 3,… (n-1)
ai follows ai-1
for i = 2, 3,… n
• Element ai is at position i
a1, a2, a3, a4, ………..,an
Not a list
a1, a3, a5, a7, ………..,an
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
3
1 2 3 4 n Position of
element.
More about lists
a1, a2, a3, a4, a5
a1, a2, a3, a4, a5, a6, a7
a1, a2, a3, a4
a1, a2, a3
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
4
LIST: Abstract Data Type
• L: List of elements
• e: an element
• p: position
LIST ADT
Properties
- Sequence of linearly
ordered elements.
Operations
• Insert(e, p, L)
• Locate(e,L)
• Retrieve(p,L)
• Delete(p,L)
• Next(p,L)
• Previous(p,L)
• MakeNull(L)
• First(L)
• PrintList(L)
• END(L)
Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 5
Print all elements of the LIST ADT
• PRINTLIST(L)
• Print the elements of L in order of occurrence.
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
6
End of list
a1, a2, a3, a4 ,…………, an
• END(L)
• Returns the position following an on the list.
a1, a2, a3, a4, a5, a6, a7
• END(L) will return 8 for this list
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
7
1 2 3 4 7 Position of element.
First position on LIST ADT
a1, a2, a3, a4 ,…………, an
• FIRST(L)
• Returns the first position on the list.
• If L is empty the position returned is END(L)
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
8
1 2 3 4 n Position of element.
Next and Previous position on LIST ADT
• NEXT(p, L)
• Returns the position following the position p on the list.
• PREVIOUS(p, L)
• Returns the position preceding the position p on the list.
• If p is the last position on the list then NEXT(p,L) will return END(L).
• PREVIOUS is undefined if p is 1.
• Both functions are undefined if L has no position p.
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
9
Insert an element in LIST ADT
a1, a2, a3, a4, a5, a6, a7
• INSERT(e, p, L)
a1, a2, a3, a4 ,……ap ,…… an
a1, a2, a3, a4 ,……,ap-1, e, ap ,…… an
• INSERT(3, 5, a1, a2, a3, a4, a5, a6, a7)
a1, a2, a3, a4, a5, a6, a7
a1, a2, a3, a4, 3, a5, a6, a7
• if p = END(L) then L becomes a1, a2, a3, a4, a5, a6, a7, e
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
10
Locate an element in LIST ADT
33, 90, 76, 21, 65, 36, 87
• LOCATE(e, L)
• Returns the position of e on list L
• LOCATE(76,L)
• Return 3
• If e appears more than once, then the position of first occurrence is
returned.
• If e does not appear than END(L) is returned.
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
11
1 2 3 4 7 Position of element.
Retrieve an element from LIST ADT
33, 90, 76, 21, 65, 36, 87
• Retrieve(p, L)
• Returns the element at position p from the List.
• Retrieve(3, L) will return 76
• The result is undefined if p = END(L) or if L has no position p
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
12
1 2 3 4 7 Position of element.
Delete an element from the list
a1, a2, a3, a4, a5, a6, a7
• DELETE(p, L)
a1, a2, a3, a4 ,……ap ,…… an
a1, a2, a3, a4 ,……,ap-1, ap+1 ,…… an
• DELETE(5, L)
a1, a2, a3, a4, a5, a6, a7
a1, a2, a3, a4, a6, a7
• Result is undefined if L has no position p
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
13
Empty entire LIST ADT
• MAKENULL(L)
• L becomes empty and returns position END(L)
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
14
Buy this course
• You can buy this course from
www.learnbywatch.com/course/data-structure-using-c-online-course
https://goo.gl/I1ZHK3
• You can also send an e-mail at info@learnbywatch.com to know more
about this course or get discount.
Data Structure using C | Dr. Yogendra Pal |
www.LearnByWatch.com
15

Más contenido relacionado

Destacado

1.2.6 analysis of centre tapped fwr parameters
1.2.6 analysis of centre tapped fwr parameters1.2.6 analysis of centre tapped fwr parameters
1.2.6 analysis of centre tapped fwr parametersLearn By Watch
 
Receiver characteristics | Communication Systems
Receiver characteristics | Communication SystemsReceiver characteristics | Communication Systems
Receiver characteristics | Communication SystemsLearn By Watch
 
1.2.5 full wave rectifier
1.2.5 full wave rectifier1.2.5 full wave rectifier
1.2.5 full wave rectifierLearn By Watch
 
1.2.2 half wave rectifier part 2
1.2.2 half wave rectifier part 21.2.2 half wave rectifier part 2
1.2.2 half wave rectifier part 2Learn By Watch
 
Preparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_typesPreparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_typesAndres Mendez-Vazquez
 
Data abstraction the walls
Data abstraction the wallsData abstraction the walls
Data abstraction the wallsHoang Nguyen
 
Semiconductor intrinsic and extrinsic electronics engineering
Semiconductor intrinsic and extrinsic   electronics engineeringSemiconductor intrinsic and extrinsic   electronics engineering
Semiconductor intrinsic and extrinsic electronics engineeringLearn By Watch
 
03 data abstraction
03 data abstraction03 data abstraction
03 data abstractionOpas Kaewtai
 
Amplitude modulation
Amplitude modulationAmplitude modulation
Amplitude modulationdude_deepak
 
Data structure
Data structureData structure
Data structureeShikshak
 
Data structure
Data structureData structure
Data structuresnaya
 
Task analysis and training need assessment
Task analysis and training  need assessmentTask analysis and training  need assessment
Task analysis and training need assessmentbegraj SIWAL
 
15934 am demodulation
15934 am demodulation15934 am demodulation
15934 am demodulationManish Kumar
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaVisakh V
 
Function in Mathematics
Function in MathematicsFunction in Mathematics
Function in Mathematicsghhgj jhgh
 
Big Data As a service - Sethuonline.com | Sathyabama University Chennai
Big Data As a service - Sethuonline.com | Sathyabama University ChennaiBig Data As a service - Sethuonline.com | Sathyabama University Chennai
Big Data As a service - Sethuonline.com | Sathyabama University Chennaisethuraman R
 

Destacado (20)

1.2.6 analysis of centre tapped fwr parameters
1.2.6 analysis of centre tapped fwr parameters1.2.6 analysis of centre tapped fwr parameters
1.2.6 analysis of centre tapped fwr parameters
 
Receiver characteristics | Communication Systems
Receiver characteristics | Communication SystemsReceiver characteristics | Communication Systems
Receiver characteristics | Communication Systems
 
1.2.5 full wave rectifier
1.2.5 full wave rectifier1.2.5 full wave rectifier
1.2.5 full wave rectifier
 
1.2.2 half wave rectifier part 2
1.2.2 half wave rectifier part 21.2.2 half wave rectifier part 2
1.2.2 half wave rectifier part 2
 
Preparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_typesPreparation Data Structures 03 abstract data_types
Preparation Data Structures 03 abstract data_types
 
Data abstraction the walls
Data abstraction the wallsData abstraction the walls
Data abstraction the walls
 
Semiconductor intrinsic and extrinsic electronics engineering
Semiconductor intrinsic and extrinsic   electronics engineeringSemiconductor intrinsic and extrinsic   electronics engineering
Semiconductor intrinsic and extrinsic electronics engineering
 
Algo>Abstract data type
Algo>Abstract data typeAlgo>Abstract data type
Algo>Abstract data type
 
03 data abstraction
03 data abstraction03 data abstraction
03 data abstraction
 
Amplitude modulation
Amplitude modulationAmplitude modulation
Amplitude modulation
 
Data structure
Data structureData structure
Data structure
 
Data structure
Data structureData structure
Data structure
 
Task analysis and training need assessment
Task analysis and training  need assessmentTask analysis and training  need assessment
Task analysis and training need assessment
 
15934 am demodulation
15934 am demodulation15934 am demodulation
15934 am demodulation
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
How to make CV Resume
How to make CV ResumeHow to make CV Resume
How to make CV Resume
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
 
Function in Mathematics
Function in MathematicsFunction in Mathematics
Function in Mathematics
 
Big Data As a service - Sethuonline.com | Sathyabama University Chennai
Big Data As a service - Sethuonline.com | Sathyabama University ChennaiBig Data As a service - Sethuonline.com | Sathyabama University Chennai
Big Data As a service - Sethuonline.com | Sathyabama University Chennai
 

Más de Learn By Watch

Demodulation of fm pll detector
Demodulation of fm pll detectorDemodulation of fm pll detector
Demodulation of fm pll detectorLearn By Watch
 
Demodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorDemodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorLearn By Watch
 
In direct method of fm generation armstrong method
In direct method of fm generation armstrong methodIn direct method of fm generation armstrong method
In direct method of fm generation armstrong methodLearn By Watch
 
Direct method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodDirect method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodLearn By Watch
 
Spectrum and power of wbfm
Spectrum and power of wbfmSpectrum and power of wbfm
Spectrum and power of wbfmLearn By Watch
 
Narrow band frequency modulation nbfm
Narrow band frequency modulation nbfmNarrow band frequency modulation nbfm
Narrow band frequency modulation nbfmLearn By Watch
 
General expression of fm signal
General expression of fm signalGeneral expression of fm signal
General expression of fm signalLearn By Watch
 
Frequency division multiplexing
Frequency division multiplexingFrequency division multiplexing
Frequency division multiplexingLearn By Watch
 
Demodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorDemodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorLearn By Watch
 
Generarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodGenerarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodLearn By Watch
 
Generarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodGenerarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodLearn By Watch
 
Demodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverDemodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverLearn By Watch
 
Quadrature carrier multiplexing qam
Quadrature carrier multiplexing qamQuadrature carrier multiplexing qam
Quadrature carrier multiplexing qamLearn By Watch
 
Demodulation of am synchronous detector
Demodulation of am synchronous detectorDemodulation of am synchronous detector
Demodulation of am synchronous detectorLearn By Watch
 

Más de Learn By Watch (20)

Tutorial 9 fm
Tutorial 9 fmTutorial 9 fm
Tutorial 9 fm
 
Phase modulation
Phase modulationPhase modulation
Phase modulation
 
Demodulation of fm pll detector
Demodulation of fm pll detectorDemodulation of fm pll detector
Demodulation of fm pll detector
 
Demodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorDemodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detector
 
In direct method of fm generation armstrong method
In direct method of fm generation armstrong methodIn direct method of fm generation armstrong method
In direct method of fm generation armstrong method
 
Direct method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodDirect method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator method
 
Carson's rule
Carson's ruleCarson's rule
Carson's rule
 
Spectrum and power of wbfm
Spectrum and power of wbfmSpectrum and power of wbfm
Spectrum and power of wbfm
 
Narrow band frequency modulation nbfm
Narrow band frequency modulation nbfmNarrow band frequency modulation nbfm
Narrow band frequency modulation nbfm
 
General expression of fm signal
General expression of fm signalGeneral expression of fm signal
General expression of fm signal
 
Angle modulation
Angle modulationAngle modulation
Angle modulation
 
Frequency division multiplexing
Frequency division multiplexingFrequency division multiplexing
Frequency division multiplexing
 
Vsb modulation
Vsb modulationVsb modulation
Vsb modulation
 
Demodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorDemodulation of ssb synchronous detector
Demodulation of ssb synchronous detector
 
Generarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodGenerarion of ssb phase discrimination method
Generarion of ssb phase discrimination method
 
Generarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodGenerarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination method
 
Ssb modulation
Ssb modulationSsb modulation
Ssb modulation
 
Demodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverDemodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiver
 
Quadrature carrier multiplexing qam
Quadrature carrier multiplexing qamQuadrature carrier multiplexing qam
Quadrature carrier multiplexing qam
 
Demodulation of am synchronous detector
Demodulation of am synchronous detectorDemodulation of am synchronous detector
Demodulation of am synchronous detector
 

Último

Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 

Último (20)

Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 

Data Structure: List as abstract data type

  • 2. List • A List is a sequence of zero or more elements. a1, a2, a3, a4, ………..,an Where n  0, a1 is the first element an is the last element n is length of the list if n = 0, the list is empty (no element) Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 2
  • 3. More about lists • Elements are linearly ordered. ai precedes ai+1 for i = 1, 2, 3,… (n-1) ai follows ai-1 for i = 2, 3,… n • Element ai is at position i a1, a2, a3, a4, ………..,an Not a list a1, a3, a5, a7, ………..,an Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 3 1 2 3 4 n Position of element.
  • 4. More about lists a1, a2, a3, a4, a5 a1, a2, a3, a4, a5, a6, a7 a1, a2, a3, a4 a1, a2, a3 Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 4
  • 5. LIST: Abstract Data Type • L: List of elements • e: an element • p: position LIST ADT Properties - Sequence of linearly ordered elements. Operations • Insert(e, p, L) • Locate(e,L) • Retrieve(p,L) • Delete(p,L) • Next(p,L) • Previous(p,L) • MakeNull(L) • First(L) • PrintList(L) • END(L) Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 5
  • 6. Print all elements of the LIST ADT • PRINTLIST(L) • Print the elements of L in order of occurrence. Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 6
  • 7. End of list a1, a2, a3, a4 ,…………, an • END(L) • Returns the position following an on the list. a1, a2, a3, a4, a5, a6, a7 • END(L) will return 8 for this list Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 7 1 2 3 4 7 Position of element.
  • 8. First position on LIST ADT a1, a2, a3, a4 ,…………, an • FIRST(L) • Returns the first position on the list. • If L is empty the position returned is END(L) Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 8 1 2 3 4 n Position of element.
  • 9. Next and Previous position on LIST ADT • NEXT(p, L) • Returns the position following the position p on the list. • PREVIOUS(p, L) • Returns the position preceding the position p on the list. • If p is the last position on the list then NEXT(p,L) will return END(L). • PREVIOUS is undefined if p is 1. • Both functions are undefined if L has no position p. Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 9
  • 10. Insert an element in LIST ADT a1, a2, a3, a4, a5, a6, a7 • INSERT(e, p, L) a1, a2, a3, a4 ,……ap ,…… an a1, a2, a3, a4 ,……,ap-1, e, ap ,…… an • INSERT(3, 5, a1, a2, a3, a4, a5, a6, a7) a1, a2, a3, a4, a5, a6, a7 a1, a2, a3, a4, 3, a5, a6, a7 • if p = END(L) then L becomes a1, a2, a3, a4, a5, a6, a7, e Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 10
  • 11. Locate an element in LIST ADT 33, 90, 76, 21, 65, 36, 87 • LOCATE(e, L) • Returns the position of e on list L • LOCATE(76,L) • Return 3 • If e appears more than once, then the position of first occurrence is returned. • If e does not appear than END(L) is returned. Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 11 1 2 3 4 7 Position of element.
  • 12. Retrieve an element from LIST ADT 33, 90, 76, 21, 65, 36, 87 • Retrieve(p, L) • Returns the element at position p from the List. • Retrieve(3, L) will return 76 • The result is undefined if p = END(L) or if L has no position p Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 12 1 2 3 4 7 Position of element.
  • 13. Delete an element from the list a1, a2, a3, a4, a5, a6, a7 • DELETE(p, L) a1, a2, a3, a4 ,……ap ,…… an a1, a2, a3, a4 ,……,ap-1, ap+1 ,…… an • DELETE(5, L) a1, a2, a3, a4, a5, a6, a7 a1, a2, a3, a4, a6, a7 • Result is undefined if L has no position p Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 13
  • 14. Empty entire LIST ADT • MAKENULL(L) • L becomes empty and returns position END(L) Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 14
  • 15. Buy this course • You can buy this course from www.learnbywatch.com/course/data-structure-using-c-online-course https://goo.gl/I1ZHK3 • You can also send an e-mail at info@learnbywatch.com to know more about this course or get discount. Data Structure using C | Dr. Yogendra Pal | www.LearnByWatch.com 15