1. Set a node to contain INFO and LINK fields.
2. Allot memory dynamically for a node and declare it as a header H.
3. To create a linked lists get the element N and allot memory for a node SI
4. Set S1→ INFO = N; and S1→ LINK = NULL.
5. Repeat the above two steps for all the elements.
6. A node can be inserted at the front, in the middle or at the end of the list.
7. To insert a node X→ at the front check check whether the list is empty, if not set
8. X→LINK = H→LINK and H→LINK = X.
9. To insert a node X at the end travel till the end of the list and assign the last node’s LINK value to X
10. To insert a node X after the specified node Y, travel the list till the node Y is reached Set X→LINK = Y→LINK = X
11. A node can be deleted at the front, in the middle or at the end of the list.
12. To delete a node X at the front set H→LINK = H→LINK→LINK.
13. To delete a node X at the end travel the list till the end and assign the previous at last node’s LINK value to be NULL.
14. To delete a node X after the specified node Y, Y→LINK = Y→LINK→LINK.
15. To search an element E traverse the list until E is found.
C Program To Implement Linked List Using Array Abstract Data Type:
|