5/4/2015 3:58 PM1. 2 Allen NewellCliff ShawHerbert Simon We Owe To These.

Slides:



Advertisements
Similar presentations
Pointers.
Advertisements

Lists CS 3358.
Linked Lists CS-212 Dick Steflik. Linked Lists A sequential collection of information Can be unordered; i.e. in no specific order Can be ordered; may.
Stacks, Queues, and Linked Lists
Linked Lists.
DATA STRUCTURES USING C++ Chapter 5
Linked Lists Linked Lists Representation Traversing a Linked List
Linked Lists CSE 2451 Matt Boggus. Dynamic memory reminder Allocate memory during run-time malloc() and calloc() – return a void pointer to memory or.
CHP-5 LinkedList.
Data Structure Lecture-5
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
M180: Data Structures & Algorithms in Java
Review Learn about linked lists
Chapter Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data Structures: A Pseudocode Approach with C
1 Linked Lists Gordon College Prof. Brinton. 2 Linked List Basics Why use? 1.Efficient insertion or deletion into middle of list. (Arrays are not efficient.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
Doubly Linked List. Contents  Linked list  Doubly linked list  Structure  Insertion of node  Deletion of node  Traversing of node  Application.
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 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
Reference: Vinu V Das, Principles of Data Structures using C and C++
Implementation of Linked List For more notes and topics visit: eITnotes.com.
Data Strcutures.
D ATA S TRUCTURE Ali Abdul Karem Habib MSc.IT. P OINTER A pointer is a variable which represents the location of a data item. We can have a pointer to.
A first look an ADTs Solving a problem involves processing data, and an important part of the solution is the careful organization of the data In order.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Linked List Chapter Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.
Linked Lists EENG 212 ALGORITHMS And DATA STRUCTURES.
Subject Name : Data Structure Using C Title : Linked Lists
1 Linked Lists (Lec 6). 2  Introduction  Singly Linked Lists  Circularly Linked Lists  Doubly Linked Lists  Multiply Linked Lists  Applications.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Chapter Lists Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
Binary Tree.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Linked Lists Linked Lists Dale.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
1 Linked List. Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion.
Linked List. LINKED LIST Link is collection of similar type of elements. There are two ways of maintaining a list in memory. The first way is store the.
Data Structure & Algorithms
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.
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.
Data Structures and Algorithm Analysis Dr. Ken Cosh 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.
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
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.
Linked List ADT used to store information in a list
Unit – I Lists.
Data Structures Using C, 2e
Linked List :: Basic Concepts
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Linked Lists Chapter 6 Section 6.4 – 6.6
Data Structure Interview Question and Answers
Data structures and algorithms
Data Structure and Algorithms
Prepared by, Jesmin Akhter, Lecturer, IIT, JU
Lecture - 6 On Data Structures
Data Structure Dr. Mohamed Khafagy.
UNIT-3 LINKED LIST.
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Data Structures Interview / VIVA Questions and Answers
LINKED LISTS CSCD Linked Lists.
LINKED LIST.
Chapter 17: Linked Lists.
LINKED LIST Dr. T. Kokilavani Assistant Professor
LINEAR DATA STRUCTURES
Presentation transcript:

5/4/2015 3:58 PM1

2 Allen NewellCliff ShawHerbert Simon We Owe To These

5/4/2015 3:58 PM3 Linked lists were developed in by Allen Newell, Cliff Shaw and Herbert Simon at RAND Corporation as the primary data structure for their Information Processing Language. IPL was used by the authors to develop several early artificial intelligence programs, including the Logic Theory Machine, the General Problem Solver, and a computer chess program. Reports on their work appeared in IRE Transactions on Information Theory in 1956, and several conference proceedings from , including Proceedings of the Western Joint Computer Conference in 1957 and 1958, and Information Processing (Proceedings of the first UNESCO International Conference on Information Processing) in The now-classic diagram consisting of blocks representing list nodes with arrows pointing to successive list nodes appears in "Programming the Logic Theory Machine" by Newell and Shaw in Proc. WJCC, February Newell and Simon were recognized with the ACM Turing Award in 1975 for having "made basic contributions to artificial intelligence, the psychology of human cognition, and list processing".Allen NewellCliff Shaw Herbert SimonRAND CorporationInformation Processing Languageartificial intelligenceUNESCOTuring Award History

LINK LIST Introduction. Why we use Linked List ? Overview of various Link Lists. Implementation of Link List. Operations. Advantage and Disadvantages. Applications. 5/4/2015 3:58 PM4

Introduction List : The term “List” refers to linear collection of data items.Following figure shows a simple list of data items : Linked List : Linked list is a linear data structure. Linked list are special list of some data elements linked to one another. The logical addressing is represented by having each element pointing to the next element. Each element is called a node which has two parts. (i)Info i.e. information part (ii)Next i.e. the Address part Milk Eggs Butter Tomato Apple Orange 5/4/2015 3:58 PM5

6 This stores the data Of the user. This stores the address of next node. Information Next

Some Key Points : 1.NULL Pointer: The link field of the last node of the linked list contains NULL rather than a valid address. It is a NULL pointer and indicates the end of the list. 2.External Pointer : It is a pointer to the very first node in the linked list, it enables us to access the entire linked list. 5/4/2015 3:58 PM7

8 3.Empty List : If the nodes are not present in a linked list, then it is called an empty linked list or simply empty list. It is also called the Null list. The value of the external pointer will be zero for an empty link list. A linked list can be made an empty linked list by assigning a NULL value to the external pointer.That is for example start=NULL; start=NULL;

Representation of a Node in a Linked list : Struct node { int a; struct node* next; }typedef struct node Node; Node *start; 5/4/2015 3:58 PM9

Why We Need Linked List Suppose we have a memory in fragmented form i.e. although there is space is availabe In the memory but It is not contigious, and we have to allocate maximum of the memory. For example : Suppose if we have memory of 256KB in fragmented form i.e. not conigious, and we have to store 10 records in which each of the record contain Name, Address, and Course of the Student. 5/4/2015 3:58 PM10

5/4/2015 3:58 PM K B 64 K B 32 K B 32 K B 0 256

Then we can use the Linked List to store these records with the help of Dynamic Memory Allocation schem. DMA can be implemented by : Malloc() Calloc() Realloc() Free() 5/4/2015 3:58 PM12

Overview Of various Link Lists  Singly Linked List  Doubly Linked List  Circular Linked List  Circular Doubly Linked List 5/4/2015 3:58 PM13

1. Singly Linked List : Singly linked list is one in which all nodes are linked together in some sequential manner. Hence, it is also called Linear Linked List. Clearly it has beginning and the end. The problem with this list is that we can not access the predecessor of nodes from the current node. i.e. we can not traverse back in this list. This problem can be overcome by using Doubly Linked List. 5/4/2015 3:58 PM14 N Start

2. Doubly Linked List : Doubly Linked List is one in which all nodes are linked together by multiple links which help in accessing both the successor node (next node) and predecessor node (previous node) for any arbitrary node in the list, that is we can traverse both the direction in the linked list. 5/4/2015 3:58 PM15 N N Start

3. Circular Linked List : Circular linked list is one which has no beginning and no end. A singly linked list can be made a circular linked list by simply attach the address of very first node in the link field of the last node. 5/4/2015 3:58 PM16 Start

4. Circular Doubly Linked List : is one which has both the successor pointer and predecessor pointer in circular manner. It is shown in the following figure : 5/4/2015 3:58 PM17 N Start

Link List Operations Creation Insertion Deletion Traversing Searching Concatenation Display 5/4/2015 3:58 PM18

First we are performed the operations on Singly Linked List Creation of LinkList : Algorithm : Step 1. Create node Step 2. if node is NULL then memory can not be allocated to the node. Step 3. else if start is NULL then start=node; 5/4/2015 3:58 PM19

else ptr=start; while ptr->next is not equal to NULL ptr=ptr->next; ptr->next=node; Step 4. Exit. 5/4/2015 3:58 PM20

Insertion of node at the beginning Algorithm : Step1. Start Step2. get node from the memory Step3. Check overflow if node is NULL then memory can not be allocated to the node. exit; 5/4/2015 3:58 PM21

else node->info=item; node->next=start; start =node; Step5. Exit 5/4/2015 3:58 PM22

Insertion at the end of the Linked List : Algorithm : Step1.Start Step2.Get node from the memory. Step3.Check Overflow if node =NULL then overflow exit; 5/4/2015 3:58 PM23

Else if start =NULL then start=node; else p=start; while p->next is not equal to NULL p=p->next p->next=item; Step 4. Exit 5/4/2015 3:58 PM24

Deletion a node from Linked List Algorithm : Step1. Start Step 2. Check Underflow if start =NULL then underflow Step3.else 5/4/2015 3:58 PM25

if start->info=item start=start->next else p=q=start; while p->next not equal to NULL if p->next->info=item delitem=p->next->info p->next=p->next->next; Step4. Exit. 5/4/2015 3:58 PM26

Implementation Linked List as a Stack Linked List as a Queue 5/4/2015 3:58 PM27

Doubly Link List So far we have studied singly link list.One of the most striking disadvantages of it is that the inability to traverse the list in the backward direction.In most of real world applications it is necessary to traverse the list in both the direction.The most appropriate data structure for such an application is a DOUBLY LINK LIST. A doubly link list is one in which all nodes are linked together by multiple number of links which help in accessing both the successor node and predecessor node.It provides bi-directional traversing.

Each node in doubly link list has two link fields. These are used to point to the successor and predecessor nodes. It can be illustrated by the following figure : 5/4/2015 3:58 PM29 prev Data next The LEFT link points to the predecessor node and RIGHT link points to the successor node.

Inserting node at beginning Allocate memory for the new node. Assign value to the data field of the node. Assign LEFT and RIGHT links to NULL. Make the RIGHT link of the new node to point to the head node of list and make left link of head node to point to new node. Finally reset the head pointer.That is make it to point to new node which has inserter at the beginning. 5/4/2015 3:58 PM30

Inserting node at the end Allocate memory for the new node. Assign values to the data field of the new node. If the list is not empty then traverse the list till the last and make the RIGHT link of the last node to point the new node and LEFT link of the new node to point the last node. 5/4/2015 3:58 PM31

Deleting node from beginning If the list is empty then display the message “Empty list-No deletion”. Otherwise make the head pointer to point to the second node and if the second node is not null then make its LEFT link to point to NULL. Free the first node. 5/4/2015 3:58 PM32

Deleting node from the end If the list is empty then display the message “Empty list-No deletion”. Otherwise traverse the list till the last but one node and make the Right link of the last but one node to point to NULL. Free the last node. 5/4/2015 3:58 PM33

Circular Link List It is just a singly link list in which the link field of the last node contains the address of first node of the list.That is the link field of the last node does not point to NULL rather it points back to the beginning of the link list. A circular link list has no end.Therefore it is necessary to establish the FIRST and LAST nodes in such a link list.It is useful if we set the external pointer to point the last node.From this conversion we can easily locate the FIRST node of the list.

Inserting node at beginning Allocate memory for new node. Assign values to its data field. Make the link part of new node point to the head node. Finally reset the head pointer. That is make it to point to the inserted node. 5/4/2015 3:58 PM35

Inserting node at the end Allocate memory for the new node. Assign values to the data field of the node. If the list is not empty then traverse the list till the last and make the link of the last node to point the new node and link of new node should point to the head node. 5/4/2015 3:58 PM36

Deleting node from beginning If the list is empty then display the message Empty list-No deletion. Otherwise make the head pointer to point to second node. Free the first node. 5/4/2015 3:58 PM37

Deleting node from the end If the list is empty then display the message Empty list-No deletion. Otherwise traverse the list till the last but one node and make the link to point to head node. Free the last node. 5/4/2015 3:58 PM38

Operations... Traversing Searching Concatenation Display 5/4/2015 3:58 PM39

Advantages Dynamic data structures. Efficient memory utilization. Easier and efficient insertion, deletion. Use in complex applications. 5/4/2015 3:58 PM40

Disadvantages More memory required. Cumbersome data access. 5/4/2015 3:58 PM41

Applications Polynomial operations. Dynamic programming. Base of other data structures. 5/4/2015 3:58 PM42

Applications  O.S maintain a link list of free and used memory  To solve complex applications 5/4/2015 3:58 PM43

5/4/2015 3:58 PM44 data