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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education