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

Description

Linked lists in C++

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

Homework 3-Linked lists in C++
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
Please submit your source code to your BitBucket repository csci221-HW03. Make sure that
there is no memory leak when these duplicates are removed.

Purchase answer to see full
attachment

  
error: Content is protected !!