Tasks
Tasks
Submission date
23-09-2019 (Section-B)
26-09-2019 (Section-A)
You need to write a class called LinkedList that implements the following List operations:
// adds an item to the list at the given index, that index may be at start, end or after or before the
// specific element
// removes the item from the list that has the given index
// finds the item from list and removes that item from the list
8. public Delete_Smallest();
// Delete smallest element from linked list
Freq(20) =2
Freq(18) =3
Freq(15)=1
Freq(6)=1
Freq(5)=1
13. Create two circular linked lists and find their maximum numbers. Merge the two circular
linked lists such that the maximum number of 2nd circular linked list immediately follows
the maximum number of the 1st circular linked list.
Input:
12 -> 28 -> 18 -> 25 -> 19-> NULL
5 -> 24 -> 12 -> 6 -> 15-> NULL
Output:
28 -> 24-> 25 -> 15 -> 19 -> 15->5-> 18 -> 25 -> 19->NULL
14. Given a pairlinked lists, insert nodes of second linked list into the first linked list at alternate
positions.Assume that the first linked list has at least as many elements as the second.
Input:
1 -> 2 -> 3 -> NULL
4 ->5 -> NULL
Output:
1 -> 4-> 2 -> 5 -> 3 -> NULL
15. Swap k-th node from the beginning with k-th node from the end in a linked list.
Input:
k=11 -> 2 -> 3 ->NULL
k=21 -> 2 -> 3 ->NULL
k=31 -> 2 -> 3 ->NULL
Output:
3-> 2 -> 1->NULL
1-> 2 -> 3->NULL
3-> 2 -> 1->NULL
16. Make a function that adds a linked list to itself at the end.
Input:
4 -> 2 -> 1 -> NULL
Output:
4 -> 2 -> 1 -> 4 -> 2 -> 1 -> NULL
17. Write a program to represent a polynomial in variable X using a singly linked list, each node
of which contains two kinds of data fields; one to store coefficient and another stores the
power on variable X. For example, if a polynomial is: P(X)=2X^2 + 3X + 4 then the
structure of linked list is as below:
Perform polynomial addition on two such polynomials represented by linked lists and generate a
new list representing the sum of those polynomials.
Input:
18. Write the method to swap 1st node with last node and 2nd node with 2nd last node and so on.
You have to swap addresses not values.
Input:
28 -> 24-> 25 -> 15 -> 19 -> 17-> 18 -> 23 -> 19->NULL
Output:
19 -> 23-> 18 -> 17 -> 19 -> 15-> 25 -> 24 -> 28->NULL
Note:
Don’t apply the reverse method
Grading Criteria
G D Luck