313301 DSU Practical No.13: Write a 'C' Program to Implement Singly Linked List with Operations: (i) Insert at end (ii) Insert after (iii)Delete(iv) Display
A Singly Linked List is a linear data structure in which the elements are not stored in contiguous memory locations. Each component is connected only to its next element using a pointer.
The list is not required to be continuously present in the memory. The node can reside anywhere in the memory and be linked together to make a list. This achieves optimized utilization of space. list size is limited to the memory size and doesn't need to be declared in advance.
C Program Code
Algorithm
Flow chart
Draw a flow chart using the below instructions:
Result (Output of Program)
Linked List after insertion at end:
10 -> 20 -> 30 -> 40 -> NULL
Linked List after inserting 25 after 20:
10 -> 20 -> 25 -> 30 -> 40 -> NULL
Linked List after deleting 30:
10 -> 20 -> 25 -> 40 -> NULL
Practical Related Questions
1. Write a function to insert a node at the end in a Singly Linked List.
Answer:
2. Write a function to check whether a singly linked list is a palindrome or not.
Answer:
Exercise
1. Write applications of Singly Linked List.
Answer:
- Implementation of stacks and queues: Singly linked lists can be used as the underlying data structure for stacks (LIFO) and queues (FIFO).
- Polynomial representation: Linked lists can efficiently represent polynomials, allowing for arithmetic operations like addition and multiplication.
- Graph representation: Adjacency lists, a common representation of graphs, utilize linked lists to store neighbors of each vertex.
- Hash tables: Linked lists can be used to resolve collisions in hash tables
2. Explain the procedure to find middle of singly linked list.
Answer:
Conclusion
We completed 313301 DSU Practical No.13 in which we Write a 'C' Program to Implement Singly Linked List with Operations: (i) Insert at end (ii) Insert after (iii)Delete(iv) Display