Write the algorithm to implement singly Linked list ADT.



Algorithm:
STEP 1: Start.
STEP 2: Create an class named as list with an empty linked list using the structure with the information and link fields.
STEP 3: Declare the methods for the list operations.
• CREATION
• INSERTION IN THE BEGINNING
• INSERTION IN THE END
• INSERTION AT A POSITION
• DELETION IN THE BEGINNING
• DELETION IN THE END
• DISPLAY THE LIST
STEP 4: If the method is creation, the define it get the input number from the user, if the number is 1 then the link to the next node is made NULL, else create the memory for the new node.
STEP 5: If the method is insertion, get the number to be inserted and get the key node after which the new node has to inserted.
STEP 5.1: Search the list until the key is found,
STEP 5.2: If the key is found then change the link of the key node to point the new node, and the link of the new node to the next of the key node.
STEP 6: Deletion method is define to get the data to be deleted and search the list until the data is matched.
STEP 7: Ifthe data matches change the link of the previous node to point the next node of the deletion node.
STEP 8: To display the list display method is define, print the information of each node until the link of the node is NULL.


STEP 9: Stop.


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments:

Thanks
Mukesh Rajput