Less'Implement an extractLessThan operation on a singly-linked list with no tail pointer. Your code SHOULD NOT delete memory, only return a new LinkedList with the value less than parameter value. Your code must not call other LinkedList functions. Order of the extracted nodes does not matter. 8. struct LinkNode { Data • data; // note that you can compare by calling data->compareTo(other) LinkNode • next; }; class LinkedList { LinkNode • head; • Returns a nev LinkedList that contains all of the LinkNodes from this • LinkedList that have node->data->compareTo (value) < 0. • LinkedList •x- ... // x contains [5, 8, 1, 3] • Data • value - new IntegerData (4); • LinkedList • y- x->extractLessThan(value); • // x nov contains [5, 8] and y nov contains (3, 1 // You have access to head and to this LinkedList extractLessThan (Data • value) { LinkedList nevList - new LinkedList(); LinkNode • current - head; LinkNode • previous - NULL;
Less'Implement an extractLessThan operation on a singly-linked list with no tail pointer. Your code SHOULD NOT delete memory, only return a new LinkedList with the value less than parameter value. Your code must not call other LinkedList functions. Order of the extracted nodes does not matter. 8. struct LinkNode { Data • data; // note that you can compare by calling data->compareTo(other) LinkNode • next; }; class LinkedList { LinkNode • head; • Returns a nev LinkedList that contains all of the LinkNodes from this • LinkedList that have node->data->compareTo (value) < 0. • LinkedList •x- ... // x contains [5, 8, 1, 3] • Data • value - new IntegerData (4); • LinkedList • y- x->extractLessThan(value); • // x nov contains [5, 8] and y nov contains (3, 1 // You have access to head and to this LinkedList extractLessThan (Data • value) { LinkedList nevList - new LinkedList(); LinkNode • current - head; LinkNode • previous - NULL;
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16SA
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning