Linked List Test Part 3
By Mickey Arnold
starstarstarstarstar
Last updated 10 months ago
2 Questions
Part 1 : Complete method removeEveryXthNode(int x).
private ListNode theList; //instance variable / data field
//method removeEveryXthNode will remove every x node in the list
public void removeEveryXthNode(int x)
{
///Code goes here Part 1///
}
Example
//original list
1 -> 5 -> 3 -> 4 -> 7 -> null
//list after call(2)
1 -> 3 -> 7 -> null
Part 2 : Complete method doubleFront().
private ListNode theList; //instance variable / data field
//method doubleFront will add a new node at the front of the list with
// the same value as the current node at the front of the list
public void doubleFront()
{
///Code goes here Part 2///
}
Example
//original list
1 -> 4 -> null
//list after call to double
1 -> 1 -> 4 -> null