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

Question Description

IÃ¢â‚¬â„¢m studying and need help with a C++ question to help me learn.

the instruction will be uploaded in the pictures

https://learn-us-east-1-prod-fleet01-xythos.conten…

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
Ã¢â‚¬Â¢ 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
data next
data next
42
data next
50
19
42 –
data next
9 nulll
50 C
Set the runner to runner next.
Ã¢â‚¬Â¢ Set the current to current next.
data next
data next
data next
42
data next
50
data next
42
data next
9 null
19
50
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