Download presentation

Presentation is loading. Please wait.

Published byRylie Sudweeks Modified over 2 years ago

1
5/4/2015 3:58 PM1

2
2 Allen NewellCliff ShawHerbert Simon We Owe To These

3
5/4/2015 3:58 PM3 Linked lists were developed in 1955-56 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 1957-1959, 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 1959. 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 1957. 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

4
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

5
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
6 This stores the data Of the user. This stores the address of next node. Information Next

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

9
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

10
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

11
5/4/2015 3:58 PM11 128 K B 64 K B 32 K B 32 K B 0 256

12
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

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

14
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

15
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

16
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

17
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

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

19
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

20
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

21
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

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

23
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

24
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

25
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

26
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

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

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

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

30
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

31
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

32
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

33
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

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

35
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

36
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

37
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

38
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

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

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

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

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

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

44
5/4/2015 3:58 PM44 data

Similar presentations

Presentation is loading. Please wait....

OK

Stacks, Queues, and Linked Lists

Stacks, Queues, and Linked Lists

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Sixth sense technology best ppt on robotics Free ppt on moving coil galvanometer instrument Ppt on time management at work Ppt on condition monitoring devices Ppt on measuring brand equity Download ppt on management of natural resources class 10 By appt only sign Ppt on world book day dressing Download ppt on oxidation and reduction potential Sample ppt on personality test