Question: Problems: Reverse a singly linked list Remove duplicated in a sorted linked list Submission First, look at the following checklist: Have you tested every method?
Problems:
Reverse a singly linked list
Remove duplicated in a sorted linked list
Submission First, look at the following checklist:
Have you tested every method?
Is the indentation easily readable? You can have Eclipse correct indentation by highlighting all
code and select "Source Correct Indentation".
Are comments well organized and concise?
Grading Criteria
Sort an array p
Find the kth largest element in an array, not sorted p
Reverse a singly linked list p
Remove duplicated in a sorted linked list p
Complete the unimplemented test cases in ArrayProblemsTest.java and in LinkedListProb
lemsTest.javap
Source code is appropriately commented p
public class LinkedListProblems
Given a sorted linked list, delete all duplicates such that each element appear only once.
Example :
Input:
Output:
Example :
Input:
Output:
public static ListNode deleteDuplicatesListNode head
TODO: finish this method.
TODO: Modify this line to return correct data.
return null;
Reverse a singly linked list.
Example:
Input: NULL
Output: NULL
public static ListNode reverseListListNode head
TODO:finish this method.
TODO: Modify this line to return correct data.
return null;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
public class LinkedListProblemsTest
ListNode T;
The common test data to be used is the list T:
@Before
public void setUp throws Exception
int testdata;
ListNode T new ListNodetestdata;
for int i; inull
Output: null
@Test
public void testDeleteDuplicates
int expected ;
ListNode newTLinkedListProblems.deleteDuplicatesT;
ListNode pnewT;
int i ;
while pnull
assertEqualsexpectedi pval;
i i;
Reverse a singly linked list.
Example:
Input: NULL
Output: NULL
@Test
public void testReverseList
failNot yet implemented"; TODO
public class ListNode
int val;
ListNode next;
ListNodeint x val x;
Please Complete them
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
