Data structures and algorithms

Slides:



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

Pointers.
Lists CS 3358.
CHP-5 LinkedList.
M180: Data Structures & Algorithms in Java
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.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
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.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Linked List by Chapter 5 Linked List by
Subject Name : Data Structure Using C Title : Linked Lists
Data Structures Using C++1 Chapter 5 Linked Lists.
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,
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.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
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:
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.
UNIT-II Topics to be covered Singly linked list Circular linked list
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
UNIT-V ABSTRACT DATA TYPE 1.LIST 2.STACK 3.QUEUE EC6301-II-ECE-C.
CPSC 252 Linked Lists III Page 1 Variations on Singly Linked Lists Inserting or deleting at the front of a list is different from at any other point in.
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 Lists Source: presentation based on notes written by R.Kay, A. Hill and C.Noble ● Lists in general ● Lists indexed using pointer arrays ● Singly.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
Chapter 16: Linked Lists.
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
Sorted Linked List Same objective as a linked list, but it should be sorted Sorting can be custom according to the type of nodes Offers speedups over non-sorted.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Data Structure Interview Question and Answers
Review Deleting an Element from a Linked List Deletion involves:
Data Structure and Algorithms
John Hurley Cal State LA
Data Structure Dr. Mohamed Khafagy.
UNIT-3 LINKED LIST.
EEL 4854 IT Data Structures Linked Lists
Data Structures Interview / VIVA Questions and Answers
CSCE 210 Data Structures and Algorithms
Lists.
LINKED LISTS CSCD Linked Lists.
Lists.
Linked Lists.
Arrays and Linked Lists
Chapter 18: Linked Lists.
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
Linked Lists.
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
CS212D: Data Structures Week 5-6 Linked List.
CS2013 Lecture 4 John Hurley Cal State LA.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
Problem Understanding
Chapter 17: Linked Lists.
Data Structures & Algorithms
Programming II (CS300) Chapter 07: Linked Lists
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
BY PROF. IRSHAD AHMAD LONE.
Linked Lists Chapter 5 (continued)
Chapter 9 Linked Lists.
LINEAR DATA STRUCTURES
Presentation transcript:

Data structures and algorithms Kovács Zita 2016/2017. II. semester 23 February 2016, Linked lists

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 list 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

Benefit 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

Advanteges 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.

Disadvanteges 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.

Singly linked list 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

Circular linked list 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

Doubly linked list 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

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

Operations 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.

Operations - traversing 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

Operations - inserting 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.

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

Operations - removing 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.

Operations - removing 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

References http://en.wikipedia.org/wiki/Linked_list