Question: 1. Given a pointer/reference to the head node of a linked list, write a method to display its elements, one element per line. If the

1. Given a pointer/reference to the head node of a linked list, write a method to display its elements, one element per line. If the head pointer is null (indicating the list is empty), dont display anything.(java code)

2. Reverse a singly linked list. Write reverseIteratively() method which reverses a single linked list using a three-pointers approach and using loops. It traverses through the linked list and adds nodes at the beginning of the singly linked list in each iteration. It uses three reference variables (pointers) to keep track of previous, current and next nodes.(java code)

1. Given a pointer/reference to the head node of a linked list,

3. Find Union and Intersection of two sets. Given two sets (elements in a set are distinct), write a method that finds the union and intersection of two sets using linked list. E.g., given A= {6,1,3, 20,7 }, B={2,6,8,3,5} your algorithm should print Union as {1, 2, 3, 5, 6, 7, 8, 20} and Intersection as {3, 6}. Note that the elements of union and intersection can be printed in any order. (java code)

4. Write a method rotate(list,k) which rotates an integer list by a given number k. k elements from the end should move to the beginning of the list, and all other elements should move to right to make the space. E.g., if list a is initialized with elements l = {1, 2, 3, 4, 5, 6, 7, 8, 9}. (java code)

Divide the list into two parts Head First Rest Reverse Rest Head First Now wy need to remove this link a ceate a ink from node 2 to node 1 Rest Link rest to first first nextnext-first irst->next nu Head Change Head Rest 'head ref= rest 3 Head

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!