Linked List Chapter 3 1. 2 Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Pointers.
Linked Lists.
Data Structures: A Pseudocode Approach with C
DATA STRUCTURES USING C++ Chapter 5
Chapter 1 Object Oriented Programming 1. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
Review Learn about linked lists
Data Structures: A Pseudocode Approach with C
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
Linked list More terminology Singly-linked lists Doubly-linked lists DLLs compared to SLLs Circular Lists.
Data Structures & Algorithms
Comparison summary Array based (dynamic) Keeps place for up to 4N elements Each element takes 1 memory places Fast accession time Slow removals and insertion.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
Chapter 4 Linked Lists. © 2005 Pearson Addison-Wesley. All rights reserved4-2 Preliminaries Options for implementing an ADT List –Array has a fixed size.
Data Structures Using C++ 2E
Doubly Linked Lists Deleting from the end of the list – Have to traverse the entire list to stop right in front of tail to delete it, so O(n) – With head.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
1 CSC 211 Data Structures Lecture 21 Dr. Iftikhar Azim Niaz 1.
1 Chapter 16-1 Linked Structures Dale/Weems. 2 Chapter 16 Topics l Meaning of a Linked List l Meaning of a Dynamic Linked List l Traversal, Insertion.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 17: Linked Lists.
1 Chapter 16 Linked Structures Dale/Weems/Headington.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
Data Structures Using C++1 Chapter 5 Linked Lists.
© 2006 Pearson Addison-Wesley. All rights reserved5 B-1 Chapter 5 (continued) Linked Lists.
Chapter 3 The easy stuff. Lists If you only need to store a few things, the simplest and easiest approach might be to put them in a list Only if you need.
Linked Lists. Introduction In linked list each item is embedded in a link Each item has two parts – Data – Pointer to the next item in the list Insert,
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Data Structure & Algorithms
1 CS 132 Spring 2008 Chapter 5 Linked Lists p
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
Chapter 6. Character String Types It is one in which the values consists of sequences of characters. How to Define a variable contain a string? In a programming.
Lists List Implementations. 2 Linked List Review Recall from CMSC 201 –“A linked list is a linear collection of self- referential structures, called nodes,
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
Computer Programming II
Chapter 16: Linked Lists.
Linked List ADT used to store information in a list
C++ Programming:. Program Design Including
Chapter 4 Linked Structures.
CSCI-255 LinkedList.
Linked Lists Chapter 5 (continued)
Linked Lists Chapter 6 Section 6.4 – 6.6
Review Deleting an Element from a Linked List Deletion involves:
COP3530- Data Structures Advanced Lists
Chapter 4 Linked Lists.
Doubly Linked Lists or Two-way Linked Lists
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Linked Lists Chapter 4.
Chapter 17: Linked Lists.
Chapter 16 Linked Structures
Linked Lists Chapter 5 (continued)
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
Linked Lists Chapter 5 (continued)
Variable Storage Memory Locations (Logical) Variable Classes Stack
Presentation transcript:

Linked List Chapter 3 1

2

Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the possible values? – What operations will be needed? IMPLEMENTATION – How can this be done in C++? – How can data types be used? 3

Data structures A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Data structures are declared in C++ using the following: 4 syntax: struct structure_name { member_type1 member_name1; member_type2 member_name2; member_type3 member_name3;. } object_names; struct product { int weight; float price; } apple, banana, melon;

5

6

Templates - Class templates A template parameter is a special kind of parameter that can be used to pass a type as argument: 7

8

Linked List a linked list is a list in which the order of the components is determined by an explicit link member in each node the nodes are structs--each node contains a component member and also a link member that gives the location of the next node in the list an external pointer (or head pointer) points to the first node in the list 9

Nodes can be located anywhere in memory the link member holds the memory address of the next node in the list 10

Traversing a Linked List (single) 11

12

13

14

15

16

17

18

19

20

21

Figure 3.1 (text book) 22

23

Algorithm from e to h 24

Insertion - Algorithm (beginning) 25

26 Inserting a new node at the beginning of a singly linked list

Insertion - Algorithm (end) 27

28 Inserting a new node at the end of a singly linked list

Deleting a node at the beginning of a singly linked list 29

Deleting a node at the end of a singly linked list 30

Deleting a node from a singly linked list 31

32

Doubly Linked Lists An extension of a Singly Linked List Each node has two pointer – One pointing to the successor – One pointing to the predecessor They are used because they ease certain operations like the delete Element They are interesting for traversal as you can move in either directions 33

Doubly Linked Lists (Cont.) Most of our structures and algorithms will be implemented with the help of Doubly Linked Lists Although some operations are made easier to understand they also become a bit slower due to the overhead of extra pointers In addition to the head a pointer called tail is also maintained 34

Inserting in the Front 35

Inserting in the Front (cont.) 36

Inserting in the Front (cont.) 37

Inserting in the Front (cont.) 38

Inserting in the Front (cont.) 39

Deleting element 40

Circular Lists Nodes form a ring Each node has a successor 41

Inserting a Node at the Tail of a List Circular Lists 42

Inserting a Node at the Tail of a List Circular Lists (cont.) 43

Inserting a Node at the Tail of a List Circular Lists (cont.) 44

Inserting a Node at the Tail of a List Circular Lists (cont.) 45

Skip Lists Linked lists require sequential scanning for a search operation Skip lists allow for skipping certain nodes A skip list is an ordered linked list A Skip List with Evenly spaced nodes of different levels 46

Figure 3.17 (self study) Note: (no need) 3.5 to