Question: java Sakkaravarthi Ramanathan 1. Write a java program to remove duplicates from an unsorted stack. Also sort the stack after removing the duplicates. You must

java
java Sakkaravarthi Ramanathan 1. Write a java program to remove duplicates from

Sakkaravarthi Ramanathan 1. Write a java program to remove duplicates from an unsorted stack. Also sort the stack after removing the duplicates. You must use only Stack operations. Sample: Input: [6,5,2,3,1,3,2,1, 4, 2, 4, 5] Output:[1,2,3,4,5,6] (4Marks) 2. Given a queue of integers of even length, rearrange the elements by interleaving the first half of the queue with the second half of the queue. Only a stack can be used as an auxiliary space. (4Marks) Input : 1 2 3 4 Output : 1 3 2 4 Input : 11 12 13 14 15 16 17 18 19 20 Output : 11 16 12 17 13 18 14 19 15 20 3. Sum Lists: You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a java program that adds the two numbers and returns the sum as a linked list. (4Marks) Input: (7-> 1 -> 6) + (5 -> 9 -> 2). That is,617 + 295. Output: 2 -> 1->9. That is, 912. 4. FOLLOW UP (3Marks) Suppose the digits are stored in forward order. Repeat the above problem. Input: (6-> 1-> 7)+(2->9 > 5). That is, 617 +295. Output: 9-> 1 -> 2. That is, 912

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!