SlideShare a Scribd company logo
1 of 6
Download to read offline
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.pdfEricvtJFraserr
 
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.pdfformicreation
 
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.pdfaashisha5
 
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.pdfrahulfancycorner21
 
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.docxPhil4IDBrownh
 
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 PointersANUSUYA 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.pdffortmdu
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq 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.pdfrahulfancycorner21
 
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.pdfsaradashata
 
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 notesGOKULKANNANMMECLECTC
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdfsimenehanmut
 
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 .pdfaaseletronics2013
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxmaxinesmith73660
 
Using the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdfUsing the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdfpicscamshoppe
 

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
 
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
 
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)
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
Using the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdfUsing the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdf
 

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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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.pdfinfo114
 
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).pdfinfo114
 

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

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 

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