BY PROF. IRSHAD AHMAD LONE.

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

DATA STRUCTURES USING C++ Chapter 5
Linked List Variations
Data Structures: A Pseudocode Approach with C
Data Structures & Algorithms
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Chapter 3: Arrays, Linked Lists, and Recursion
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
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.
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
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 11 – Data Structures.
Subject Name : Data Structure Using C Title : Linked Lists
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
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.
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:
1 Midterm 1 on Friday February 12 Closed book, closed notes No computer can be used 50 minutes 4 questions Write a function Write program fragment Explain.
Data Structure & Algorithms
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
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
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.
Linked List ADT used to store information in a list
Lecture 6 of Computer Science II
Unit – I Lists.
Understanding Algorithms and Data Structures
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Linked List :: Basic Concepts
Vectors 5/31/2018 9:25 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Sequences 6/3/2018 9:11 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Data Structure Interview Question and Answers
Data structures and algorithms
Review Deleting an Element from a Linked List Deletion involves:
12 C Data Structures.
Data Structure Dr. Mohamed Khafagy.
UNIT-3 LINKED LIST.
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Sequences 8/2/ :16 AM Linked Lists Linked Lists.
ENERGY 211 / CME 211 Lecture 12 October 17, 2008.
Linked Lists head One downside of arrays is that they have a fixed size. To solve this problem of fixed size, we’ll relax the constraint that the.
Lists.
Linked List Sudeshna Sarkar.
Programmazione I a.a. 2017/2018.
LINKED LISTS CSCD Linked Lists.
CMSC 341 Lecture 5 Stacks, Queues
Lists.
Arrays and Linked Lists
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
Linked Lists.
Sequences 12/8/2018 3:02 AM 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.
CS2013 Lecture 4 John Hurley Cal State LA.
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Review & Lab assignments
Linked Lists in C and C++
Problem Understanding
Chapter 17: Linked Lists.
Programming and Data Structure
Chapter 9 Linked Lists.
LINEAR DATA STRUCTURES
CMPT 225 Lecture 5 – linked list.
Problem Understanding
Presentation transcript:

BY PROF. IRSHAD AHMAD LONE. TOPIC LINKED LISTS 12/07/2018 BY PROF. IRSHAD AHMAD LONE. LINKED LISTS THROUGH C..

A linked list is a data structure which can change during execution. 12/07/2018 A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element points to NULL. It can grow or shrink in size during execution of a program. It can be made just as long as required. It does not waste memory space. head A B C LINKED LISTS THROUGH C..

Keeping track of a linked list: 12/07/2018 Keeping track of a linked list: Must know the pointer to the first element of the list (called start, head, etc.). Linked lists provide flexibility in allowing the items to be rearranged efficiently. Insert an element. Delete an element. LINKED LISTS THROUGH C..

12/07/2018 A singly linked list is a concrete data structure consisting of a sequence of nodes Each node stores element link to the next node next node elem NULL A B C D LINKED LISTS THROUGH C..

Pseudo-code for insertion 12/07/2018 typedef struct nd { struct item data; struct nd * next; } node; void insert(node *curr) { node * tmp; tmp=(node *) malloc(sizeof(node)); tmp->next=curr->next; curr->next=tmp; } LINKED LISTS THROUGH C..

Inserting an entry into a linked list 12/07/2018 Inserting an entry into a linked list LINKED LISTS THROUGH C..

Pseudo-code for deletion 12/07/2018 typedef struct nd { struct item data; struct nd * next; } node; void delete(node *curr) { node * tmp; tmp=curr->next; curr->next=tmp->next; free(tmp); } LINKED LISTS THROUGH C..

Deleting an entry from a linked list 12/07/2018 Deleting an entry from a linked list LINKED LISTS THROUGH C..

Array versus Linked Lists 12/07/2018 Array versus Linked Lists Arrays are suitable for: Inserting/deleting an element at the end. Randomly accessing any element. Searching the list for a particular value. Linked lists are suitable for: Inserting an element. Deleting an element. Applications where sequential access is required. In situations where the number of elements cannot be predicted beforehand. LINKED LISTS THROUGH C..

12/07/2018 Types of Lists Depending on the way in which the links are used to maintain adjacency, several different types of linked lists are possible. Linear singly-linked list (or simply linear list) One we have discussed so far. A B C head LINKED LISTS THROUGH C..

A B C Circular linked list 12/07/2018 Circular linked list The pointer from the last element in the list points back to the first element. A B C head LINKED LISTS THROUGH C..

12/07/2018 Doubly linked list Pointers exist between adjacent nodes in both directions. The list can be traversed either forward or backward. Usually two pointers are maintained to keep track of the list, head and tail. A B C head tail LINKED LISTS THROUGH C..

Other Kinds of List Structures 12/07/2018 Other Kinds of List Structures Queue — FIFO (First In, First Out) Items added at end Items removed from beginning Stack — LIFO (Last In, First Out) Items added at beginning, removed from beginning Circular list Last item points to first item Head may point to first or last item Items added to end, removed from beginning LINKED LISTS THROUGH C..

Basic Operations on a List 12/07/2018 Basic Operations on a List Creating a list Traversing the list Inserting an item in the list Deleting an item from the list Concatenating two lists into one LINKED LISTS THROUGH C..

12/07/2018 QUESTIONS ?? LINKED LISTS THROUGH C..