SlideShare a Scribd company logo
Need done for Date Structures please!
4.18 LAB: Sorted number list implementation with linked lists
Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking
on the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables:
a double data value,
a pointer to the next node, and
a pointer to the previous node.
Each member variable is protected. So code outside of the class must use the provided getter and
setter member functions to get or set a member variable.
Node.h is read only, since no changes are required.
Step 2: Implement the Insert() member function
A class for a sorted, doubly-linked list is declared in SortedNumberList.h. Implement the
SortedNumberList class's Insert() member function. The function must create a new node with
the parameter value, then insert the node into the proper sorted position in the linked list. Ex:
Suppose a SortedNumberList's current list is 23 47.25 86, then Insert(33.5) is called. A new node
with data value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's
sorted order and yielding: 23 35.5 47.25 86
Step 3: Test in develop mode
Code in main() takes a space-separated list of numbers and inserts each into a SortedNumberList.
The list is displayed after each insertion. Ex: If input is
then output is:
Try various program inputs, ensuring that each outputs a sorted list.
Step 4: Implement the Remove() member function
Implement the SortedNumberList class's Remove() member function. The function takes a
parameter for the number to be removed from the list. If the number does not exist in the list, the
list is not changed and false is returned. Otherwise, the first instance of the number is removed
from the list and true is returned.
Uncomment the commented-out part in main() that reads a second input line and removes
numbers from the list. Test in develop mode to ensure that insertion and removal both work
properly, then submit code for grading. Ex: If input is
then output is:
main.cpp
#include <iostream>
#include <string>
#include <vector>
#include "Node.h"
#include "SortedNumberList.h"
using namespace std;
void PrintList(SortedNumberList& list);
vector<string> SpaceSplit(string source);
int main(int argc, char *argv[]) {
// Read the line of input numbers
string inputLine;
getline(cin, inputLine);
// Split on space character
vector<string> terms = SpaceSplit(inputLine);
// Insert each value and show the sorted list's contents after each insertion
SortedNumberList list;
for (auto term : terms) {
double number = stod(term);
cout << "List after inserting " << number << ": " << endl;
list.Insert(number);
PrintList(list);
}
/*
// Read the input line with numbers to remove
getline(cin, inputLine);
terms = SpaceSplit(inputLine);
// Remove each value
for (auto term : terms) {
double number = stod(term);
cout << "List after removing " << number << ": " << endl;
list.Remove(number);
PrintList(list);
}
*/
return 0;
}
// Prints the SortedNumberList's contents, in order from head to tail
void PrintList(SortedNumberList& list) {
Node* node = list.head;
while (node) {
cout << node->GetData() << " ";
node = node->GetNext();
}
cout << endl;
}
// Splits a string at each space character, adding each substring to the vector
vector<string> SpaceSplit(string source) {
vector<string> result;
size_t start = 0;
for (size_t i = 0; i < source.length(); i++) {
if (' ' == source[i]) {
result.push_back(source.substr(start, i - start));
start = i + 1;
}
}
result.push_back(source.substr(start));
return result;
}
Node
#ifndef NODE_H
#define NODE_H
class Node {
protected:
double data;
Node* next;
Node* previous;
public:
// Constructs this node with the specified numerical data value. The next
// and previous pointers are each assigned nullptr.
Node(double initialData) {
data = initialData;
next = nullptr;
previous = nullptr;
}
// Constructs this node with the specified numerical data value, next
// pointer, and previous pointer.
Node(double initialData, Node* nextNode, Node* previousNode) {
data = initialData;
next = nextNode;
previous = previousNode;
}
virtual ~Node() {
}
// Returns this node's data.
virtual double GetData() {
return data;
}
// Sets this node's data.
virtual void SetData(double newData) {
data = newData;
}
// Gets this node's next pointer.
virtual Node* GetNext() {
return next;
}
// Sets this node's next pointer.
virtual void SetNext(Node* newNext) {
next = newNext;
}
// Gets this node's previous pointer.
virtual Node* GetPrevious() {
return previous;
}
// Sets this node's previous pointer.
virtual void SetPrevious(Node* newPrevious) {
previous = newPrevious;
}
};
#endif
SORTEDNUMBERLIST
#ifndef SORTEDNUMBERLIST_H
#define SORTEDNUMBERLIST_H
#include "Node.h"
class SortedNumberList {
private:
// Optional: Add any desired private functions here
public:
Node* head;
Node* tail;
SortedNumberList() {
head = nullptr;
tail = nullptr;
}
// Inserts the number into the list in the correct position such that the
// list remains sorted in ascending order.
void Insert(double number) {
// Your code here
}
// Removes the node with the specified number value from the list. Returns
// true if the node is found and removed, false otherwise.
bool Remove(double number) {
// Your code here (remove placeholder line below)
return false;
}
};
#endif
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf

More Related Content

Similar to Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf

This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
EricvtJFraserr
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
Arrays
ArraysArrays
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
aashisha5
 
Array Cont
Array ContArray Cont
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
rahulfancycorner21
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
RashidFaridChishti
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
Mohammed Khan
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docx
Phil4IDBrownh
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
QalandarBux2
 
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about Pointers
ANUSUYA S
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
Programming Exam Help
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
Tareq Hasan
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
rahulfancycorner21
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
saradashata
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
GOKULKANNANMMECLECTC
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
aaseletronics2013
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
Himadri Sen Gupta
 

Similar to Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf (20)

This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
Arrays
ArraysArrays
Arrays
 
C++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdfC++ Please test your program before you submit the answer.pdf
C++ Please test your program before you submit the answer.pdf
 
Array Cont
Array ContArray Cont
Array Cont
 
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdfC++ code, please help! Troubleshooting and cannot for the life of me.pdf
C++ code, please help! Troubleshooting and cannot for the life of me.pdf
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docx
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
 
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about Pointers
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdfC++ code, please help! RESPOND W COMPLETED CODE PLEASE,  am using V.pdf
C++ code, please help! RESPOND W COMPLETED CODE PLEASE, am using V.pdf
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 

More from info114

9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
9- A 45yr old male patient is suspected to have meningitis- The patien.pdf9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
info114
 
4- Implement a main function that uses each function declared below (B.pdf
4- Implement a main function that uses each function declared below (B.pdf4- Implement a main function that uses each function declared below (B.pdf
4- Implement a main function that uses each function declared below (B.pdf
info114
 
4- Using the illustration- draw-label the following- ATP synthase- int.pdf
4- Using the illustration- draw-label the following- ATP synthase- int.pdf4- Using the illustration- draw-label the following- ATP synthase- int.pdf
4- Using the illustration- draw-label the following- ATP synthase- int.pdf
info114
 
1What is the route of HCO3- from a tissue capillary located in a knee.pdf
1What is the route of HCO3- from a tissue capillary located in a knee.pdf1What is the route of HCO3- from a tissue capillary located in a knee.pdf
1What is the route of HCO3- from a tissue capillary located in a knee.pdf
info114
 
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
info114
 
3a) Translate ER Diagram into a relational schema diagram 3b) Popula.pdf
3a) Translate ER Diagram into a relational schema diagram   3b) Popula.pdf3a) Translate ER Diagram into a relational schema diagram   3b) Popula.pdf
3a) Translate ER Diagram into a relational schema diagram 3b) Popula.pdf
info114
 
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
info114
 
15-8 Project 4- Team Roster This program will store roster and rating.pdf
15-8 Project 4- Team Roster This program will store roster and rating.pdf15-8 Project 4- Team Roster This program will store roster and rating.pdf
15-8 Project 4- Team Roster This program will store roster and rating.pdf
info114
 
David seems to enjoy challenging members' viewpoints on every issue so.pdf
David seems to enjoy challenging members' viewpoints on every issue so.pdfDavid seems to enjoy challenging members' viewpoints on every issue so.pdf
David seems to enjoy challenging members' viewpoints on every issue so.pdf
info114
 
Consider a Canadian corporation that is not a CCPC- ________ will add.pdf
Consider a Canadian corporation that is not a CCPC- ________ will add.pdfConsider a Canadian corporation that is not a CCPC- ________ will add.pdf
Consider a Canadian corporation that is not a CCPC- ________ will add.pdf
info114
 
Bedford Company reports the following information for June- (Click the.pdf
Bedford Company reports the following information for June- (Click the.pdfBedford Company reports the following information for June- (Click the.pdf
Bedford Company reports the following information for June- (Click the.pdf
info114
 
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdfWhich of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
info114
 
Write a script in Python that generates random string of defined lengt.pdf
Write a script in Python that generates random string of defined lengt.pdfWrite a script in Python that generates random string of defined lengt.pdf
Write a script in Python that generates random string of defined lengt.pdf
info114
 
Howl Corporation wants to determine its breakeven sales in both units.pdf
Howl Corporation wants to determine its breakeven sales in both units.pdfHowl Corporation wants to determine its breakeven sales in both units.pdf
Howl Corporation wants to determine its breakeven sales in both units.pdf
info114
 
An organism appears as a purple color and appears as round cels that f.pdf
An organism appears as a purple color and appears as round cels that f.pdfAn organism appears as a purple color and appears as round cels that f.pdf
An organism appears as a purple color and appears as round cels that f.pdf
info114
 
Which of the following line items will NOT be included in the journal.pdf
Which of the following line items will NOT be included in the journal.pdfWhich of the following line items will NOT be included in the journal.pdf
Which of the following line items will NOT be included in the journal.pdf
info114
 
The electron micrograph shows the structures in an exocrine gland cell.pdf
The electron micrograph shows the structures in an exocrine gland cell.pdfThe electron micrograph shows the structures in an exocrine gland cell.pdf
The electron micrograph shows the structures in an exocrine gland cell.pdf
info114
 
The cohesion-tension model relies on the properties of water- notably.pdf
The cohesion-tension model relies on the properties of water- notably.pdfThe cohesion-tension model relies on the properties of water- notably.pdf
The cohesion-tension model relies on the properties of water- notably.pdf
info114
 
The gene encoding tor the transport of lectose into the cell lacA begi.pdf
The gene encoding tor the transport of lectose into the cell lacA begi.pdfThe gene encoding tor the transport of lectose into the cell lacA begi.pdf
The gene encoding tor the transport of lectose into the cell lacA begi.pdf
info114
 
Required information -The following information applies to the questio (58).pdf
Required information -The following information applies to the questio (58).pdfRequired information -The following information applies to the questio (58).pdf
Required information -The following information applies to the questio (58).pdf
info114
 

More from info114 (20)

9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
9- A 45yr old male patient is suspected to have meningitis- The patien.pdf9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
9- A 45yr old male patient is suspected to have meningitis- The patien.pdf
 
4- Implement a main function that uses each function declared below (B.pdf
4- Implement a main function that uses each function declared below (B.pdf4- Implement a main function that uses each function declared below (B.pdf
4- Implement a main function that uses each function declared below (B.pdf
 
4- Using the illustration- draw-label the following- ATP synthase- int.pdf
4- Using the illustration- draw-label the following- ATP synthase- int.pdf4- Using the illustration- draw-label the following- ATP synthase- int.pdf
4- Using the illustration- draw-label the following- ATP synthase- int.pdf
 
1What is the route of HCO3- from a tissue capillary located in a knee.pdf
1What is the route of HCO3- from a tissue capillary located in a knee.pdf1What is the route of HCO3- from a tissue capillary located in a knee.pdf
1What is the route of HCO3- from a tissue capillary located in a knee.pdf
 
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
5- The money multiplier- - Will be equal to 10 if the reserve ratio is.pdf
 
3a) Translate ER Diagram into a relational schema diagram 3b) Popula.pdf
3a) Translate ER Diagram into a relational schema diagram   3b) Popula.pdf3a) Translate ER Diagram into a relational schema diagram   3b) Popula.pdf
3a) Translate ER Diagram into a relational schema diagram 3b) Popula.pdf
 
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
1- Using the lillustration- draw-label the following- Outer mitochondr.pdf
 
15-8 Project 4- Team Roster This program will store roster and rating.pdf
15-8 Project 4- Team Roster This program will store roster and rating.pdf15-8 Project 4- Team Roster This program will store roster and rating.pdf
15-8 Project 4- Team Roster This program will store roster and rating.pdf
 
David seems to enjoy challenging members' viewpoints on every issue so.pdf
David seems to enjoy challenging members' viewpoints on every issue so.pdfDavid seems to enjoy challenging members' viewpoints on every issue so.pdf
David seems to enjoy challenging members' viewpoints on every issue so.pdf
 
Consider a Canadian corporation that is not a CCPC- ________ will add.pdf
Consider a Canadian corporation that is not a CCPC- ________ will add.pdfConsider a Canadian corporation that is not a CCPC- ________ will add.pdf
Consider a Canadian corporation that is not a CCPC- ________ will add.pdf
 
Bedford Company reports the following information for June- (Click the.pdf
Bedford Company reports the following information for June- (Click the.pdfBedford Company reports the following information for June- (Click the.pdf
Bedford Company reports the following information for June- (Click the.pdf
 
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdfWhich of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
Which of the following is mismatched- Giardia lamblia - amoebic dysent.pdf
 
Write a script in Python that generates random string of defined lengt.pdf
Write a script in Python that generates random string of defined lengt.pdfWrite a script in Python that generates random string of defined lengt.pdf
Write a script in Python that generates random string of defined lengt.pdf
 
Howl Corporation wants to determine its breakeven sales in both units.pdf
Howl Corporation wants to determine its breakeven sales in both units.pdfHowl Corporation wants to determine its breakeven sales in both units.pdf
Howl Corporation wants to determine its breakeven sales in both units.pdf
 
An organism appears as a purple color and appears as round cels that f.pdf
An organism appears as a purple color and appears as round cels that f.pdfAn organism appears as a purple color and appears as round cels that f.pdf
An organism appears as a purple color and appears as round cels that f.pdf
 
Which of the following line items will NOT be included in the journal.pdf
Which of the following line items will NOT be included in the journal.pdfWhich of the following line items will NOT be included in the journal.pdf
Which of the following line items will NOT be included in the journal.pdf
 
The electron micrograph shows the structures in an exocrine gland cell.pdf
The electron micrograph shows the structures in an exocrine gland cell.pdfThe electron micrograph shows the structures in an exocrine gland cell.pdf
The electron micrograph shows the structures in an exocrine gland cell.pdf
 
The cohesion-tension model relies on the properties of water- notably.pdf
The cohesion-tension model relies on the properties of water- notably.pdfThe cohesion-tension model relies on the properties of water- notably.pdf
The cohesion-tension model relies on the properties of water- notably.pdf
 
The gene encoding tor the transport of lectose into the cell lacA begi.pdf
The gene encoding tor the transport of lectose into the cell lacA begi.pdfThe gene encoding tor the transport of lectose into the cell lacA begi.pdf
The gene encoding tor the transport of lectose into the cell lacA begi.pdf
 
Required information -The following information applies to the questio (58).pdf
Required information -The following information applies to the questio (58).pdfRequired information -The following information applies to the questio (58).pdf
Required information -The following information applies to the questio (58).pdf
 

Recently uploaded

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 

Recently uploaded (20)

How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 

Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf

  • 1. Need done for Date Structures please! 4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on the orange arrow next to main.cpp at the top of the coding window. The Node class has three member variables: a double data value, a pointer to the next node, and a pointer to the previous node. Each member variable is protected. So code outside of the class must use the provided getter and setter member functions to get or set a member variable. Node.h is read only, since no changes are required. Step 2: Implement the Insert() member function A class for a sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList class's Insert() member function. The function must create a new node with the parameter value, then insert the node into the proper sorted position in the linked list. Ex: Suppose a SortedNumberList's current list is 23 47.25 86, then Insert(33.5) is called. A new node with data value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order and yielding: 23 35.5 47.25 86 Step 3: Test in develop mode Code in main() takes a space-separated list of numbers and inserts each into a SortedNumberList. The list is displayed after each insertion. Ex: If input is then output is: Try various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove() member function Implement the SortedNumberList class's Remove() member function. The function takes a parameter for the number to be removed from the list. If the number does not exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the number is removed from the list and true is returned.
  • 2. Uncomment the commented-out part in main() that reads a second input line and removes numbers from the list. Test in develop mode to ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is then output is: main.cpp #include <iostream> #include <string> #include <vector> #include "Node.h" #include "SortedNumberList.h" using namespace std; void PrintList(SortedNumberList& list); vector<string> SpaceSplit(string source); int main(int argc, char *argv[]) { // Read the line of input numbers string inputLine; getline(cin, inputLine); // Split on space character vector<string> terms = SpaceSplit(inputLine); // Insert each value and show the sorted list's contents after each insertion SortedNumberList list; for (auto term : terms) { double number = stod(term); cout << "List after inserting " << number << ": " << endl; list.Insert(number); PrintList(list); } /* // Read the input line with numbers to remove getline(cin, inputLine); terms = SpaceSplit(inputLine); // Remove each value for (auto term : terms) { double number = stod(term); cout << "List after removing " << number << ": " << endl; list.Remove(number); PrintList(list);
  • 3. } */ return 0; } // Prints the SortedNumberList's contents, in order from head to tail void PrintList(SortedNumberList& list) { Node* node = list.head; while (node) { cout << node->GetData() << " "; node = node->GetNext(); } cout << endl; } // Splits a string at each space character, adding each substring to the vector vector<string> SpaceSplit(string source) { vector<string> result; size_t start = 0; for (size_t i = 0; i < source.length(); i++) { if (' ' == source[i]) { result.push_back(source.substr(start, i - start)); start = i + 1; } } result.push_back(source.substr(start)); return result; } Node #ifndef NODE_H #define NODE_H class Node { protected: double data; Node* next; Node* previous; public: // Constructs this node with the specified numerical data value. The next // and previous pointers are each assigned nullptr. Node(double initialData) { data = initialData;
  • 4. next = nullptr; previous = nullptr; } // Constructs this node with the specified numerical data value, next // pointer, and previous pointer. Node(double initialData, Node* nextNode, Node* previousNode) { data = initialData; next = nextNode; previous = previousNode; } virtual ~Node() { } // Returns this node's data. virtual double GetData() { return data; } // Sets this node's data. virtual void SetData(double newData) { data = newData; } // Gets this node's next pointer. virtual Node* GetNext() { return next; } // Sets this node's next pointer. virtual void SetNext(Node* newNext) { next = newNext; } // Gets this node's previous pointer. virtual Node* GetPrevious() { return previous; } // Sets this node's previous pointer. virtual void SetPrevious(Node* newPrevious) { previous = newPrevious; } };
  • 5. #endif SORTEDNUMBERLIST #ifndef SORTEDNUMBERLIST_H #define SORTEDNUMBERLIST_H #include "Node.h" class SortedNumberList { private: // Optional: Add any desired private functions here public: Node* head; Node* tail; SortedNumberList() { head = nullptr; tail = nullptr; } // Inserts the number into the list in the correct position such that the // list remains sorted in ascending order. void Insert(double number) { // Your code here } // Removes the node with the specified number value from the list. Returns // true if the node is found and removed, false otherwise. bool Remove(double number) { // Your code here (remove placeholder line below) return false; } }; #endif