Data Structure Using C (313301) Practical No.12: Write a 'C' Program to Implement Singly Linked List with Operations: (i) Insert at the beginning, (ii) Search, (iii) Display
A Singly Linked List is a linear data structure in which the elements are not stored in contiguous memory locations and each element is connected only to its next element using a pointer.
C Program Code
Algorithm
Flow Chart
Result of code
Linked List: 40 -> 30 -> 20 -> 10 -> NULL
Element 20 found in the list.
Final Linked List: 40 -> 30 -> 20 -> 10 -> NULL
Practical Related Questions
1. Write a function to insert a node at the beginning of a Singly Linked List.
Answer:
The function to insert a node at the beginning of a singly linked list in C is typically named insertAtBeginning or insertFront
2. Write a function to detect if a singly linked list has a cycle. If a cycle is detected, return the starting node of the cycle.
Answer:
The function name to detect if a singly linked list has a cycle and to return the starting node of the cycle is typically named detectCycle or findCycleStart
Exercise
1. Explain the use of Singly Linked List
Answer:
2. Write advantages and disadvantages of Singly Linked List
Answer:
3. Calculate length of Singly Linked List
Answer:
Conclusion
We successfully completed Data Structure Using C (313301) Practical No.12 and Write a 'C' Program to Implement Singly Linked List with Operations: (i) Insert at beginning, (ii) Search, (iii) Display