Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.

Slides:



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

Pointers.
Lists CS 3358.
Linked Lists Linked Lists Representation Traversing a Linked List
Data Structures Using C++
CHP-5 LinkedList.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Data Structures: A Pseudocode Approach with C
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Data Structures & Algorithms
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.
Summary of lectures (1 to 11)
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Chapter 3: Arrays, Linked Lists, and Recursion
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Data Structures Using C++ 2E
Implementation of Linked List For more notes and topics visit: eITnotes.com.
Lists 1. Introduction Data: A finite sequence of data items. Operations: Construction: Create an empty list Empty: Check if list is empty Insert: Add.
Data Structures Using Java1 Chapter 4 Linked Lists.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
Linked List by Chapter 5 Linked List by
COSC 1P03 Data Structures and Abstraction 5.1 Linear Linked Structures A bank is a place where they lend you an umbrella in fair weather and ask for it.
Subject Name : Data Structure Using C Title : Linked Lists
Data Structures Using C++1 Chapter 5 Linked Lists.
CS2006- Data Structures I Chapter 5 Linked Lists III.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
1 Data Organization Example 1: Heap storage management –Keep track of free chunks of memory Example 2: A simple text editor –Maintain a sequence of lines.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
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:
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
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 51 LINKED LISTS. Introduction link list is a linear array collection of data elements called nodes, where the linear order is given by means of.
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
UNIT-II Topics to be covered Singly linked list Circular linked list
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Linked List ADT used to store information in a list
Lecture 6 of Computer Science II
Unit – I Lists.
C++ Programming:. Program Design Including
Data Structure By Amee Trivedi.
Top 50 Data Structures Interview Questions
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Data Structure Interview Question and Answers
Data structures and algorithms
Review Deleting an Element from a Linked List Deletion involves:
UNIT-3 LINKED LIST.
Lists.
Arrays and Linked Lists
BY PROF. IRSHAD AHMAD LONE.
Linked Lists Chapter 5 (continued)
Chapter 9 Linked Lists.
LINEAR DATA STRUCTURES
Presentation transcript:

Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list

data structure consisting of a group of nodes which together represent a sequence each node is composed of a data and a reference (in other words, a link) to the next node in the sequence this structure allows for efficient insertion or removal of elements from any position in the sequence

 Linked lists are among the simplest and most common data structures  They can be used to implement several other common abstract data types, including lists (the abstract data type), stacks, queues, associative arrays, and S-expressions

the list elements can easily be inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk linked lists allow insertion and removal of nodes at any point in the list

 Linked lists are a dynamic data structure, allocating the needed memory while the program is running.  Insertion and deletion node operations are easily implemented in a linked list.  Linear data structures such as stacks and queues are easily executed with a linked list.  They can reduce access time and may expand in real time without memory overhead.

 They have a tendency to waste memory due to pointers requiring extra storage space.  Nodes in a linked list must be read in order from the beginning as linked lists are inherently sequential access.  Nodes are stored incontiguously, greatly increasing the time required to access individual elements within the list.  Difficulties arise in linked lists when it comes to reverse traversing. Singly linked lists are extremely difficult to navigate backwards, and while doubly linked lists are somewhat easier to read, memory is wasted in allocating space for a back pointer.

It is contain nodes which have a data field as well as a 'next' field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal. head

In the last node of a list, the link field often contains a null reference, a special value used to indicate the lack of further nodes. A less common convention is to make it point to the first node of the list. head

each node contains, besides the next-node link, a second link field pointing to the 'previous' node in the sequence. The two links may be called 'forward('s') and 'backwards', or 'next' and 'prev'('previous'). head

a list that contains no data records. This is usually the same as saying that it has zero nodes.

Our node data structure will have two fields. We also keep a variable firstNode which always points to the first node in the list, or is null for an empty list.

Traversal: beginning at the first node and following each next link until we come to the end node := list.firstNode while node not null (do something with node.data) node := node.next

 Insertion: a node after an existing node in a singly linked list.  Inserting a node before an existing one cannot be done directly; instead, one must keep track of the previous node and insert a node after it.

 Inserting at the beginning of the list requires a separate function function insertBeginning(List list, Node newNode) newNode.next := list.firstNode list.firstNode := newNode

 we have functions for removing the node after a given node, and for removing a node from the beginning of the list.  To find and remove a particular node, one must again keep track of the previous element.

 function removeAfter(Node node) obsoleteNode := node.next node.next := node.next.next destroy obsoleteNode  function removeBeginning(List list) obsoleteNode := list.firstNode list.firstNode := list.firstNode.next destroy obsoleteNode