Anda di halaman 1dari 3

# Assignment-5

(LL- Singly Linked List, DLL- Doubly Linked List CLL- Circular Linked List) 1. Implement a singly linked list and perform following operations, a) Insert a new node into LL, i) At the beginning, ii) At the end, iii) At the middle with, a) Before node, b) After node, b) Delete a node from LL, i) the beginning, ii) the end, iii) the middle with, a) Before node, b) After node, c) Node itself, c) Find Middle node of LL, d) Reverse LL, e) Find length of LL, f) Sort LL, g) Split LL, h) Merge two LL, i) Display LL(Traverse), j) Find the nth node of LL, k) Find the number of occurrences of each data in LL, l) Free or delete a whole LL. 2. Implement Sorted LL with,

a) Insert, b) Delete, c) Display. 3. Implement Double-Ended-Queue using an array. a) Input-restricted deque, 4. b) Output-restricted deque. Implement Circular LL with, a) Insert, b) Delete, c) Display. 5. Implement Doubly LL with, a) Insert, b) Delete, c) Display, d) Find reverse of DLL, e) Sort DLL. 6. Implement Stack using LL. 7. Implement Queue using LL. 8. Implement Priority Queue using LL. 9. Implement Stack using CLL. 10. Implement Queue using CLL. 11. Perform polynomial addition, subtraction and multiplication using LL. 12. Solve Josephus problem using CLL, A group of soldiers surrounded by an overwhelming enemy force. There is no hope for victory without reinforcements, but there is onli a single horse available for escape. The soldiers agree to a pact to determine which of them is to escape and summon help. They form a circle and a number n is picked from a hat. One of their names is also picked from a hat. Beginning with the soldier whose name is picked, they begin to count clockwise around the circle. When the count reaches n, that soldier is removed from the circle, and the count begins again with next soldier. The process continues so that each time the count reaches n, another soldier is removed from the circle. Any soldier removed from circle is no longer counted. The last soldier remaining is to take the horse and escape. Input: Take number n, the ordering of the soldiers in the circle and the soldier from whom the count begins.

Output: Determine the order in which soldiers are eliminated from the circle and which soldier escapes. 13. Write a program to check a loop/cycle in linked list. 14. Writeafunctiontoswapeverysecondnode.[ie1>2>3>4>5>|becomes2>1 >4>3>5>|] 15. WriteafunctiontoreturnNthnodefromtheendofthelinkedlist 16. Write a program to delete a node from linked list, if you have only a pointer to a node to be deleted. 17. Writeaprogramtocomparetwolinkedlists? 18. WriteaCprogramtodoaBinarysearchonalinkedlist? 19. Removeduplicatesfromasortedlinkedlist. 20. Readasinglylinkedlistbackwards? 21. Write an program to count number of nodes in a singly linked list? 22. Write efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).