here is the file/starter code: public class LinkedListPracticeLab { private LinkedListPracticeLab(){} public static void main(String[] args) { // Test all methods here } /** * Given the heads of two sorted linked lists, merges the two lists in a one sorted list. * The list is made by splicing together the nodes of the original two lists, without * creating any new nodes. * * Returns the head of the merged linked list. */ public static ListNode mergeLists(ListNode head1, ListNode head2) { return null; } /** * Given the head of a sorted linked list, deletes all duplicates such that each element appears only once. * * Returns the head of the resulting linked list, which is still sorted. */ public static ListNode deleteDuplicates(ListNode head) { return null; } /** * Given the head of a linked list and an integer val, removes all the nodes of the linked list that has * Node.val == val. * * Returns the head of the resulting list. */ public static ListNode removeElements(ListNode head, int val) { return null; } /** * Given the head of a zero-indexed linked list and two indices i and j, swaps the elements at these indices. * * Returns the head of the resulting list. */ public static ListNode swapElements(ListNode head, int i, int j) { return null; } /** * Given the head of a singly linked list, reverse the list, and return the reversed list. */ public static ListNode reverseList(ListNode head) { return null;   } /** * Given the head of a singly linked list, returns the middle node of the linked list. * * If there are an even number of elements -- and thus two middle nodes -- returns the second middle node. */ public static ListNode middleNode(ListNode head) { return null; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

here is the file/starter code:

public class LinkedListPracticeLab {
private LinkedListPracticeLab(){}
public static void main(String[] args) {
// Test all methods here
}
/**
* Given the heads of two sorted linked lists, merges the two lists in a one
sorted list.
* The list is made by splicing together the nodes of the original two lists,
without
* creating any new nodes.
*
* Returns the head of the merged linked list.
*/
public static ListNode mergeLists(ListNode head1, ListNode head2) {
return null;
}
/**
* Given the head of a sorted linked list, deletes all duplicates such that
each element appears only once.
*
* Returns the head of the resulting linked list, which is still sorted.
*/
public static ListNode deleteDuplicates(ListNode head) {
return null;
}
/**
* Given the head of a linked list and an integer val, removes all the nodes of
the linked list that has
* Node.val == val.
*
* Returns the head of the resulting list.
*/
public static ListNode removeElements(ListNode head, int val) {
return null;
}
/**
* Given the head of a zero-indexed linked list and two indices i and j, swaps
the elements at these indices.
*
* Returns the head of the resulting list.
*/
public static ListNode swapElements(ListNode head, int i, int j) {
return null;
}
/**
* Given the head of a singly linked list, reverse the list, and return the
reversed list.
*/
public static ListNode reverseList(ListNode head) {
return null;

 

}
/**
* Given the head of a singly linked list, returns the middle node of the
linked list.
*
* If there are an even number of elements -- and thus two middle nodes --
returns the second middle node.
*/
public static ListNode middleNode(ListNode head) {
return null;
}
}

For this lab you will solve a few separate problems that involve linked lists. Some of these problems are taken from leetcode, but in a few instances are made small changes.
TASK 1
Download ListNode.java and ListUtils.java and place them in the \src folder in an IntelliJ IDEA project. Look at the code and try to understand what it does. You may try using methods in ListUtils to create and display linked lists.
TASK 2
Download this starter code:
Linked List PracticeLab.java
You will need to implement all the methods for which stubs are given; read the comments describing what the methods should do. Before you start writing any code, make sure you understand the problems you are trying to solve! And when
designing your solution you may want to make some drawings of how the linked lists are being manipulated.
TASK 3
For each method that you implement, you will need to test that it works correctly; you might put those tests in the main() method, or other methods that are invoked from main() -- up to you how you organize the tests. But make sure you include
several tests for each solution, and that you test for "special" or "boundary" cases.
Transcribed Image Text:For this lab you will solve a few separate problems that involve linked lists. Some of these problems are taken from leetcode, but in a few instances are made small changes. TASK 1 Download ListNode.java and ListUtils.java and place them in the \src folder in an IntelliJ IDEA project. Look at the code and try to understand what it does. You may try using methods in ListUtils to create and display linked lists. TASK 2 Download this starter code: Linked List PracticeLab.java You will need to implement all the methods for which stubs are given; read the comments describing what the methods should do. Before you start writing any code, make sure you understand the problems you are trying to solve! And when designing your solution you may want to make some drawings of how the linked lists are being manipulated. TASK 3 For each method that you implement, you will need to test that it works correctly; you might put those tests in the main() method, or other methods that are invoked from main() -- up to you how you organize the tests. But make sure you include several tests for each solution, and that you test for "special" or "boundary" cases.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education