+ All Categories
Home > Documents > 5/4/2015 3:58 PM1. 2 Allen NewellCliff ShawHerbert Simon We Owe To These.

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

Date post: 16-Dec-2015
Category:
Upload: rylie-sudweeks
View: 214 times
Download: 1 times
Share this document with a friend
Popular Tags:
44
06/27/22 06:01 1
Transcript
Page 1: 5/4/2015 3:58 PM1. 2 Allen NewellCliff ShawHerbert Simon We Owe To These.

04/18/23 13:47 1

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

04/18/23 13:47 2

Allen Newell Cliff Shaw Herbert Simon

We Owe To These

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

04/18/23 13:47 3

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

History

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

LINK LIST• Introduction .• Why we use Linked List ?• Overview of various Link Lists .• Implementation of Link List .• Operations . • Advantage and Disadvantages .• Applications .

04/18/23 13:47 4

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

IntroductionList : 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

04/18/23 13:47 5

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

04/18/23 13:47 6

This stores the dataOf the user .

This stores the address of next node .

Information Next

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

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.

04/18/23 13:47 7

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

04/18/23 13:47 8

3.Empty List :3.Empty List : If the nodes are not If the nodes are not present present in a linked list, then it is in a linked list, then it is called an empty linked list or simply called an empty linked list or simply emptyempty list. It list. It is also called the Null list.is also called the Null list.

The value of the external pointer will be The value of the external pointer will be zero for an empty link list. A linked list can be zero for an empty link list. A linked list can be made an empty linked list by assigning a NULL made an empty linked list by assigning a NULL value to the external pointer .That is for example value to the external pointer .That is for example

start=NULL;start=NULL;

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

Representation of a Node in a Linked list :

Struct node{ int a;

struct node* next;}typedef struct node Node;Node *start;

04/18/23 13:47 9

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

Why We Need Linked List Suppose we have a memory in fragmented form

i.e. although there is space is availabeIn 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.

04/18/23 13:47 10

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

04/18/23 13:47 11

128 K B

64 K B

32 K B

32 K B 0

256

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

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()

04/18/23 13:47 12

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

Overview Of various Link Lists

Singly Linked List

Doubly Linked List

Circular Linked List

Circular Doubly Linked List

04/18/23 13:47 13

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

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.

04/18/23 13:47 14

NStart

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

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.

04/18/23 13:47 15

N NStart

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

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.

04/18/23 13:47 16

Start

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

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 :

04/18/23 13:47 17

N Start

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

Link List Operations

• Creation• Insertion• Deletion• Traversing• Searching• Concatenation• Display

04/18/23 13:47 18

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

First we are performed the operations on Singly Linked List

Creation of LinkList : Algorithm :Step 1. Create nodeStep 2. if node is NULL then memory can not

be allocated to the node. Step 3. else

if start is NULLthen start=node;

04/18/23 13:47 19

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

elseptr=start;while ptr->next is not equal to

NULLptr=ptr->next;

ptr->next=node;Step 4. Exit.

04/18/23 13:47 20

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

Insertion of node at the beginning

Algorithm :Step1. StartStep2. get node from the memoryStep3. Check overflow

if node is NULL then memory can not be allocated to the node.exit;

04/18/23 13:47 21

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

elsenode->info=item;node->next=start;start =node;

Step5. Exit

04/18/23 13:47 22

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

Insertion at the end of the Linked List :

Algorithm :Step1.StartStep2.Get node from the memory.Step3.Check Overflow

if node =NULL then overflowexit;

04/18/23 13:47 23

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

Else if start =NULL then start=node;

elsep=start;

while p->next is not equal to NULLp=p->next

p->next=item;Step 4. Exit04/18/23 13:47 24

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

Deletion a node from Linked List

Algorithm :

Step1. StartStep 2. Check Underflow

if start =NULL then underflow

Step3. else

04/18/23 13:47 25

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

if start->info=itemstart=start->nextelse

p=q=start;while p->next not equal to

NULL if p->next->info=itemdelitem=p->next->infop->next=p->next->next;

Step4. Exit.

04/18/23 13:47 26

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

Implementation

Linked List as a Stack

Linked List as a Queue

04/18/23 13:47 27

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

Doubly Link ListSo 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 .

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

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 :

04/18/23 13:47 29

prev Data next

The LEFT link points to the predecessor node and RIGHT link points to the successor node .

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

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 .

04/18/23 13:47 30

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

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.

04/18/23 13:47 31

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

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 .

04/18/23 13:47 32

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

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 .

04/18/23 13:47 33

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

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 .

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

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 .

04/18/23 13:47 35

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

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 .

04/18/23 13:47 36

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

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 .

04/18/23 13:47 37

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

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 .

04/18/23 13:47 38

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

Operations . . .

• Traversing• Searching• Concatenation• Display

04/18/23 13:47 39

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

Advantages

• Dynamic data structures .

• Efficient memory utilization .

• Easier and efficient insertion , deletion .

• Use in complex applications .

04/18/23 13:47 40

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

Disadvantages

• More memory required .

• Cumbersome data access .

04/18/23 13:47 41

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

Applications

• Polynomial operations .

• Dynamic programming .

• Base of other data structures .

04/18/23 13:47 42

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

Applications

O.S maintain a link list of free and used memory

To solve complex applications

04/18/23 13:47 43

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

04/18/23 13:47 44

datadata

data

data

data

data

data data data

data data

datadata

data data

data

data

data

datadata

data

data

data

data

data

data

data

data


Recommended