Develop a linked-list processing function, IsolateTargetSoloAsTail, to process a linked list as follows. ● If a target cannot be found on the given list, a new node containing the target is created and added to the list's end (made the new tail node).     ► This includes the case where the given list is empty, in which the new tail node added is also the new head node. (This is so because the only node in a 1-node list is the list's head and tail node.)   ● If the target appears only once on the given list, the target-matching node is moved to the list's end (made the new tail node).     ► Nothing needs to be done if the target-matching node is already the tail node (of the given list).   ● If the target appears multiple times on the given list, the first target-matching node is moved to the list's end (made the new tail node), and all other target-matching nodes are to be deleted from the list.     ► Note that although the target-matching node to be moved does not have to be the first (i.e., it can also be any of the other target-matching nodes) for the function to work as intended, you are to make it so for the purpose (and simplicity/uniformity) of this exercise. Algorithm should:        ○ NOT change the data of any existing nodes.       ○ Destroy ONLY existing nodes that constitute the second target-matching node, third target-matching node, etc.

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Develop a linked-list processing function, IsolateTargetSoloAsTail, to process a linked list as follows.

If a target cannot be found on the given list, a new node containing the target is created and added to the list's end (made the new tail node).
    This includes the case where the given list is empty, in which the new tail node added is also the new head node. (This is so because the only node in a 1-node list is the list's head and tail node.)
  If the target appears only once on the given list, the target-matching node is moved to the list's end (made the new tail node).
    Nothing needs to be done if the target-matching node is already the tail node (of the given list).
  If the target appears multiple times on the given list, the first target-matching node is moved to the list's end (made the new tail node), and all other target-matching nodes are to be deleted from the list.
    Note that although the target-matching node to be moved does not have to be the first (i.e., it can also be any of the other target-matching nodes) for the function to work as intended, you are to make it so for the purpose (and simplicity/uniformity) of this exercise.
Algorithm should: 
      NOT change the data of any existing nodes.
      Destroy ONLY existing nodes that constitute the second target-matching node, third target-matching node, etc.

evelop a linked-list processing function IsolateTargetSoloAsTail that is to process a linked list as follows.

If target cannot be found on the given list, a new node containing target is created and added to the end (made the new tail node) of the list.
    This includes the case where the given list is empty, in which case the new tail node added is also new head node. (This is so because the only node in a 1-node list is both the head and tail node of the list.)
  If target appears only once on the given list, the target-matching node is moved to the end (made the new tail node) of the list.
    In case the target-matching node is already the tail node (of the given list), then nothing needs to be done.
  If target appears multiple times on the given list, the first target-matching node is moved to the end (made the new tail node) of the list, and all other target-matching nodes are to be deleted from the list.
    Note that although the target-matching node to be moved does not have to be the first (i.e., it can also be any of the other target-matching nodes) for the function to work as intended, you are to make it so for the purpose (and simplicity/uniformity) of this exercise.

void   IsolateTargetSoloAsTail(Node* headPtr, int target);

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning