By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Linked Lists Course Lecture Slides 23 July 2010 A list is only as strong.
CHP-5 LinkedList.
Stack & Queues COP 3502.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Data Structures: A Pseudocode Approach with C
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures.
Linked Structures, Project 1: Linked List Bryce Boe 2013/10/16 CS24, Fall 2013.
Linked Lists in C and C++ By Ravi Prakash PGT(CS).
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
CSE1303 Part A Data Structures and Algorithms Lecture A7 – Nodes and Linked Structures.
Linked lists Prof. Noah Snavely CS1114
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Summary of lectures (1 to 11)
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
School of Engineering and Computer Science, Victoria University of Wellington COMP 103 Linked Structures.
Data structures Abstract data types Java classes for Data structures and ADTs.
Introduction to Data Structures Systems Programming Concepts.
Data Structure & Algorithm
Dynamic Array. An Array-Based Implementation - Summary Good things:  Fast, random access of elements  Very memory efficient, very little memory is required.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
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.
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,
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
CNG 140 C Programming (Lecture set 12) Spring Chapter 13 Dynamic Data Structures.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Linked Lists Linked Lists Dale.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Data Structure and Algorithms
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
1 Data Structures and Algorithms Outline This topic will describe: –The concrete data structures that can be used to store information –The basic forms.
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
1 Linked List. 2 List A list refers to a sequence of data items  Example: An array The array index is used for accessing and manipulation of array elements.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
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.
STACKS & QUEUES for CLASS XII ( C++).
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Top 50 Data Structures Interview Questions
CSCI-255 LinkedList.
UNIT – I Linked Lists.
Linked Lists Chapter 6 Section 6.4 – 6.6
Review Deleting an Element from a Linked List Deletion involves:
12 C Data Structures.
Programming Abstractions
Chapter 15 Lists Objectives
Arrays and Linked Lists
Programming Abstractions
Review & Lab assignments
Data Structures & Algorithms
Structures in c By Anand George.
Functions By Anand George.
Presentation transcript:

By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Introduction  Structures which contains pointer to same structure type.  Self referencing structures are mainly used to implement data structures like linked list, stack, queue, tree, graph etc.  Note: 1. While we going to see a couple of them now and next couple of presentations please note these sessions are no way an introduction to algorithms or data structures but just a foundation for both on a C language perspective. 2. None of the presentations on self referencing data structures may not implement the best algorithm for the sample operations it does. 3. From a language standpoint this is all you going to need for any data structures or algorithms to be implemented or understood in C. So the focus is on the language part. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Self referencing structure struct MyNode { int data; MyNode* link; }; SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Linked List  Like array can be used to save multiple items of same type.  Unlike array is not contiguous.  Discontiguous memory chunks linked together.  A chain of self referencing structure variables.  Total memory can be dynamically allocated. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Node  One link in the chain.  Is a structure in C  Will have pointer to its own type.  Can have any amount of data.  End of the list is designated by a pointer to NULL. struct MyNode { int data; MyNode* link; }; SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

End NodeA typical Node Linked list. 1 link NULL SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  Linked list.  Add 10 elements to the list.  print the list. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Difference between array and linked list  Indexing ( getting the nth element ) Is faster in array as we can calculate the address of nth element if the first address is given. Slow in linked list as traversal is need to nth element as we don’t know the address of nth element only (n-1)th element knows it.  Sorting and similar operations which need data to be moved between elements. Normally operation which need change in elements position linked list is better as links can be exchanged instead of data itself. Sorting is just an example.  Serialization( save to devices like disk/NIC etc ) Linked list cannot serialize by itself like array as memory is not contiguous.  Expansion Array cannot expand.  Adding something in the middle or anywhere. Array cannot do this operation if it is full or very costly. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Summary  Self referencing structures.  Linked List SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Thank you SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)