SlideShare a Scribd company logo
1 of 10
CS250 - Data Structures and
Algorithm
BESE-2A/B
Lecture 03
•
•
•
•
•
Outline
Problem with arrays
Solution
Introduction to Linked List
Arrays vs. Linked List
Linked List Pros & Cons
9/14/2012 DSA - Fall 2012 - SEECS, NUST 2
Our Prime Concern
• Performance & Efficiency
– In terms of time ;
• faster the execution, better the algorithm
– In terms of space ;
• lesser the space, better the data structure
9/14/2012 DSA - Fall 2012 - SEECS, NUST 3
Pros
• Easier to use and access
• Faster access to the
elements
– Takes constant time
– Base + ( item_number *
number_of_bytes)
Cons
• Fixed size
• One block allocation
– Fails if enough contiguous
memory isn’t available
• Complex position based
insertion
9/14/2012
– Expensive to maintain
ordered data OR insertion at
beginning
DSA - Fall 2012 - SEECS, NUST 4
Arrays
Most common data structure to implement
collections or to store data
Arrays
• Solution
– Dynamic Memory Allocation
– Faster insertion and deletion of elements without
changing the existing items
• Linked List
9/14/2012 DSA - Fall 2012 - SEECS, NUST 5
Linked List
• Linked structure is a collection of
nodes storing data and links to
other nodes
• Dynamic Memory Allocation
– Consequently, nodes can locate
anywhere in the memory and each
node can point to any other node
9/14/2012 DSA - Fall 2012 - SEECS, NUST 6
Linked List
• Linked structure is a collection of nodes storing
data and link to other nodes
struct Node {
int data;
Node * next;
};
9/14/2012 DSA - Fall 2012 - SEECS, NUST 7
Array vs. Linked List
9/14/2012 DSA - Fall 2012 - SEECS, NUST 8
Linked List
Pros
• Dynamic allocation
– the size is not required to be
known in advance
• Flexibility
– insert at (or delete from) any
position in constant time
• No single allocation of
memory needed
Cons
• Complex to use and access
– relatively complex as
compared to arrays
• No constant time access to
the elements
9/14/2012 DSA - Fall 2012 - SEECS, NUST 9
Question?
9/14/2012 DSA - Fall 2012 - SEECS, NUST 10

More Related Content

Similar to Link list 1

Presentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSPresentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSabdurrobsoyon
 
Presentation On NoSQL Databases
Presentation On NoSQL DatabasesPresentation On NoSQL Databases
Presentation On NoSQL DatabasesAbiral Gautam
 
Deep semantic understanding
Deep semantic understandingDeep semantic understanding
Deep semantic understandingsidra ali
 
Overview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdfOverview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdfChristalin Nelson
 
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES cscpconf
 
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIESENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIEScsandit
 
Enhancing keyword search over relational databases using ontologies
Enhancing keyword search over relational databases using ontologiesEnhancing keyword search over relational databases using ontologies
Enhancing keyword search over relational databases using ontologiescsandit
 
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdfKrishnaShah908060
 
Main MeMory Data Base
Main MeMory Data BaseMain MeMory Data Base
Main MeMory Data BaseSiva Rushi
 
access.2021.3077680.pdf
access.2021.3077680.pdfaccess.2021.3077680.pdf
access.2021.3077680.pdfneju3
 
Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018Fizaril Amzari Omar
 
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...IJCERT JOURNAL
 

Similar to Link list 1 (20)

NoSql Brownbag
NoSql BrownbagNoSql Brownbag
NoSql Brownbag
 
Rdbms
RdbmsRdbms
Rdbms
 
Presentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMSPresentation on NoSQL Database related RDBMS
Presentation on NoSQL Database related RDBMS
 
NoSql
NoSqlNoSql
NoSql
 
Presentation On NoSQL Databases
Presentation On NoSQL DatabasesPresentation On NoSQL Databases
Presentation On NoSQL Databases
 
03 data mining : data warehouse
03 data mining : data warehouse03 data mining : data warehouse
03 data mining : data warehouse
 
nosql.pptx
nosql.pptxnosql.pptx
nosql.pptx
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
Deep semantic understanding
Deep semantic understandingDeep semantic understanding
Deep semantic understanding
 
Overview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdfOverview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdf
 
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
 
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIESENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
ENHANCING KEYWORD SEARCH OVER RELATIONAL DATABASES USING ONTOLOGIES
 
Enhancing keyword search over relational databases using ontologies
Enhancing keyword search over relational databases using ontologiesEnhancing keyword search over relational databases using ontologies
Enhancing keyword search over relational databases using ontologies
 
Database overview
Database overviewDatabase overview
Database overview
 
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
 
Main MeMory Data Base
Main MeMory Data BaseMain MeMory Data Base
Main MeMory Data Base
 
access.2021.3077680.pdf
access.2021.3077680.pdfaccess.2021.3077680.pdf
access.2021.3077680.pdf
 
Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018
 
1_DBMS_Introduction.pdf
1_DBMS_Introduction.pdf1_DBMS_Introduction.pdf
1_DBMS_Introduction.pdf
 
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...
SURVEY ON IMPLEMANTATION OF COLUMN ORIENTED NOSQL DATA STORES ( BIGTABLE & CA...
 

More from sana younas

7 habits of highly effective people
7 habits of highly effective people7 habits of highly effective people
7 habits of highly effective peoplesana younas
 
Connectivity of graphs
Connectivity of graphsConnectivity of graphs
Connectivity of graphssana younas
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithmsana younas
 
Enterpise system
Enterpise systemEnterpise system
Enterpise systemsana younas
 
Database administration
Database administrationDatabase administration
Database administrationsana younas
 
Universal logic gate
Universal logic gateUniversal logic gate
Universal logic gatesana younas
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingsana younas
 
Memory management
Memory managementMemory management
Memory managementsana younas
 

More from sana younas (15)

7 habits of highly effective people
7 habits of highly effective people7 habits of highly effective people
7 habits of highly effective people
 
Connectivity of graphs
Connectivity of graphsConnectivity of graphs
Connectivity of graphs
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Binary search
Binary searchBinary search
Binary search
 
Link list 2
Link list 2Link list 2
Link list 2
 
Heapsort 1
Heapsort 1Heapsort 1
Heapsort 1
 
Arrays
ArraysArrays
Arrays
 
Enterpise system
Enterpise systemEnterpise system
Enterpise system
 
Database administration
Database administrationDatabase administration
Database administration
 
Encoders
EncodersEncoders
Encoders
 
Universal logic gate
Universal logic gateUniversal logic gate
Universal logic gate
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Memory management
Memory managementMemory management
Memory management
 
Parallel adders
Parallel addersParallel adders
Parallel adders
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

Link list 1

  • 1. CS250 - Data Structures and Algorithm BESE-2A/B Lecture 03
  • 2. • • • • • Outline Problem with arrays Solution Introduction to Linked List Arrays vs. Linked List Linked List Pros & Cons 9/14/2012 DSA - Fall 2012 - SEECS, NUST 2
  • 3. Our Prime Concern • Performance & Efficiency – In terms of time ; • faster the execution, better the algorithm – In terms of space ; • lesser the space, better the data structure 9/14/2012 DSA - Fall 2012 - SEECS, NUST 3
  • 4. Pros • Easier to use and access • Faster access to the elements – Takes constant time – Base + ( item_number * number_of_bytes) Cons • Fixed size • One block allocation – Fails if enough contiguous memory isn’t available • Complex position based insertion 9/14/2012 – Expensive to maintain ordered data OR insertion at beginning DSA - Fall 2012 - SEECS, NUST 4 Arrays Most common data structure to implement collections or to store data
  • 5. Arrays • Solution – Dynamic Memory Allocation – Faster insertion and deletion of elements without changing the existing items • Linked List 9/14/2012 DSA - Fall 2012 - SEECS, NUST 5
  • 6. Linked List • Linked structure is a collection of nodes storing data and links to other nodes • Dynamic Memory Allocation – Consequently, nodes can locate anywhere in the memory and each node can point to any other node 9/14/2012 DSA - Fall 2012 - SEECS, NUST 6
  • 7. Linked List • Linked structure is a collection of nodes storing data and link to other nodes struct Node { int data; Node * next; }; 9/14/2012 DSA - Fall 2012 - SEECS, NUST 7
  • 8. Array vs. Linked List 9/14/2012 DSA - Fall 2012 - SEECS, NUST 8
  • 9. Linked List Pros • Dynamic allocation – the size is not required to be known in advance • Flexibility – insert at (or delete from) any position in constant time • No single allocation of memory needed Cons • Complex to use and access – relatively complex as compared to arrays • No constant time access to the elements 9/14/2012 DSA - Fall 2012 - SEECS, NUST 9
  • 10. Question? 9/14/2012 DSA - Fall 2012 - SEECS, NUST 10