**Write an algorithm for array implementation of List ADT.**

*A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. The linked list is the second most-used data structure after the array.*

*A linked list is a sequence of data structures, which are connected together via links.*

*Linked List is a sequence of links which contains items. Each link contains a connection to another link. The linked list is the second most-used data structure after the array.*

**Following are the important terms to understand the concept of Linked List.***• Link − each link of a linked list can store a data called an element.*

*• Next − each link of a linked list contains a link to the next link called Next.*

*• Linked List − A Linked List contains the connection link to the first link called First.*

**Algorithm Steps:**

*Step1: Create nodes first, last; next, prev and cur then set the value as NULL.*

*Step 2: Read the list operation type.*

*Step 3: If the operation type is created then process the following steps.*

*1. Allocate memory for node cur.*

*2. Read data in cur's data area.*

*3. Assign cur node as NULL.*

*4. Assign first=last=cur.*

*Step 4: If the operation type is Insert then process the following steps.*

*1. Allocate memory for node cur.*

*2. Read data in cur's data area.*

*3. Read the position the Data to be inserted.*

*4. Availability of the position is true then assign cur's node as first and first=cur.*

*5. If availability of position is false then do following steps.*

*1. Assign next as cur and count as zero.*

*2. Repeat the following steps until count less than position.*

*1.Assign prev as next*

*2. Next as prev of the node.*

*3. Add count by one.*

*4. If prev as NULL then display the message INVALID POSITION.*

*5. If prev not equal to NULL then do the following steps.*

*1. Assign cur's node as prev's node.*

*2. Assign prev's node as cur.*

*Step5: If the operation type is deleted then do the following steps.*

*1. Read the position.*

*2. Check list is Empty.If it is true display the message List empty.*

*3. If the position is first.*

*1. Assign cur as first.*

*2. Assign First as first of node.*

*3. Reallocate the cur from memory.*

*4. If the position is last.*

*1. Move the current node to prev.*

*2. cur's node as Null.*

*3. Reallocate the Last from memory.*

*4. Assign last as cur.*

*5. If the position is to enter Mediate.*

*1. Move the cur to the required position.*

*2. Move the Previous to cur's previous position*

*3. Move the Next to cur's Next position.*

*4. Now Assign previous of node as next.*

*5. Reallocate the cur from memory.*

*Step 6: If the operation is traverse.*

*1. Assign current as first.*

*2. Repeat the following steps until cur becomes NULL.*

## Post A Comment:

## 0 comments: