+1(978)310-4246 credencewriters@gmail.com
Select Page

Description

Using the linked list implementation posted on Blackboard, please complete the following methods:

Using the linked list implementation posted on Blackboard, please complete the following
methods:
Remove duplicates from a sorted linked list
.
Ã¢â‚¬Â¢ Compare the current node with the next nodes (adjacent nodes).
If current and current next have the same data value, then
Ã¢â‚¬Â¢ Create a temp node for the next of next node.
Ã¢â‚¬Â¢ Remove the node.
Ã¢â‚¬Â¢ Set the next of current node to temp node.
Else
Keep iterating the list.
.
.
data next
42
data next
50
data next
50
data next
50
data next
60
data next
60 pull
Remove duplicates from an unsorted linked list V1
.
Ã¢â‚¬Â¢ Create two pointers to store the current, and the runner
Ã¢â‚¬Â¢ The runner pointer points the current next
Ã¢â‚¬Â¢ Iterate the list with the runner pointer
Ã¢â‚¬Â¢ Iterate the list with the runner pointer
Ã¢â‚¬Â¢ If current data is same as runner data, then
Ã¢â‚¬Â¢ Call RemoveNode with the current node and the runner node.
Ã¢â‚¬Â¢ Set the runner to runner next.
Ã¢â‚¬Â¢ Set the current to current next.
data next
data next
50
data next
19
data next
42
data next
50
data next
9 null
42
Remove duplicates from an unsorted linked list V2
Ã¢â‚¬Â¢ Create three pointers to store the current, runner, and duplicate
Ã¢â‚¬Â¢ The runner pointer points the current
Ã¢â‚¬Â¢ Iterate the list with the runner pointer
If current data is same as runner next data, then
Ã¢â‚¬Â¢ Store the runner next node in duplicate pointer
Ã¢â‚¬Â¢ Set runner next to the next of the runner next node.
Ã¢â‚¬Â¢ Remove the node via duplicate pointer.
Else, set the runner to runner next.
.
data next
data next
42
data next
50
data next
42
data next
50
data next
9 null
19