SlideShare a Scribd company logo
C++ Please write the whole code that is needed for this assignment, write the completed code
together with the provided one, don't copy anyone else's code, label in what file each code
belongs, and please don't forget to share your code output after finishing writing the code, if
these requirements aren't met, I will nor upvote the answer, everything must be clear and
complete, everything is given below. Thank you.
ListNode.h
#include<memory>
#include <string>
template <class T>
//template <class T>
class ListNode{
public: T data;
public: ListNode * next;
// post: constructs a node with data 0 and null link
public: ListNode();
public: ListNode(T data);
public: ListNode(T idata, ListNode<T> * newNext);
public:std::string toString();
public: ListNode<T> * getNext();
public: void setNext(ListNode<T> * newNext);
public: T getData();
public: void setData(T newData);
};
ListNodecpp.h
#include "ListNode.h"
template <class T>
// post: constructs a node with data 0 and null link
//GIVEN
ListNode<T>:: ListNode() {
//std::cout<<" IN constructor"<<std::endl;
T t ;
next=nullptr;
}
//GIVEN
template <class T>
ListNode<T>:: ListNode(T idata) {
data=idata;
next=nullptr;
}
//TODO
template <class T>
ListNode<T>:: ListNode(T idata, ListNode<T>* inext) {
//TODO - assign data and next pointer
}
//GIVEN
template <class T>
std::string ListNode<T>::toString(){
return data.toString();
}
//GIVEN
template <class T>
ListNode<T> * ListNode<T>::getNext(){
return next;
}
//TODO
template <class T>
void ListNode<T>::setNext(ListNode<T> * newNext){
//TODO set the next pointer to incoming value
}
//GIVEN
template <class T>
T ListNode<T>::getData(){
return data;
}
//TODO
template <class T>
void ListNode<T>::setData(T newData){
//TODO set the data to incoming value
}
main.cpp
#include <iostream>
#include "ListNodecpp.h"
//Requires: integer value for searching, address of front
//Effects: traverses the list node chain starting from front until the end comparing search value
with listnode getData. Returns the original search value if found, if not adds +1 to indicate not
found
//Modifies: Nothing
int search(ListNode<int> * front, int value);
//Requires: integer value for inserting, address of front
//Effects: creates a new ListNode with value and inserts in proper position (increasing order)in
the chain. If chain is empty, adds to the beginning
//Modifies: front, if node is added at the beginning.
//Also changes the next pointer of the previous node to point to the newly inserted list node. the
next pointer of the newly inserted pointer points to what was the next of the previous node. This
way both previous and current links are adjusted
//******** NOTE the use of & in passing pointer to front as parameter - Why do you think this
is needed ?**********
void insert(ListNode<int> * &front,int value);
//Requires: integer value for adding, address of front
//Effects:creates a new ListNode with value and inserts at the beginning
//Modifies:front, if node is added at the beginning.
void addNode(ListNode<int> * &front,int value);
//Requires: integer value for removing, address of front
//Effects: removes a node, if list is empty or node not found, removes nothing.
//Modifies: If the first node is removed, front is adjusted.
// if removal is at the end or middle, makes sure all nececssary links are updated.
void remove(ListNode<int>* & front, int value);
//Requires: address of front
//Effects: prints data of each node, by traversing the chain starting from the front using next
pointers.
//Modifies: nothing
void printList(ListNode<int> * front);
//GIVEN
int main() {
// Add 3 Nodes to the chain of ListNodes
//note AddNode method appends to the end so this will be out of order
// the order of the nodes is 1,2 , 4
//Create a daisy chain aka Linked List
//
ListNode<int> * front = nullptr;
printList(front);
std::cout<<"**********************n";
addNode(front,1);
printList(front);
std::cout<<"**********************n";
addNode(front,2);
printList(front);
std::cout<<"**********************n";
addNode(front,4);
printList(front);
std::cout<<"**********************n";
// the insert method inserts node with value 3 in place
insert(front,3);
printList(front);
std::cout<<"**********************n";
// remove the first, so front needs to point to second
remove(front, 1);
printList(front);
std::cout<<"**********************n";
// insert it back
insert(front,1);
printList(front);
std::cout<<"**********************n";
//remove from the middle
remove(front, 3);
printList(front);
std::cout<<"**********************n";
// remove at the end
remove(front, 4);
printList(front);
std::cout<<"**********************n";
//remove a non existent node
remove(front, 5);
printList(front);
std::cout<<"**********************n";
// remove all nodes one by one leaving only front pointing to null pointer
remove(front, 2);
printList(front);
std::cout<<"**********************n";
remove(front, 1);
printList(front);
std::cout<<"**********************n";
// insert at the beginning of the empty list a larger value
insert(front, 4);
printList(front);
std::cout<<"**********************n";
// insert the smaller value at correct position in the front of the chain and change front
insert(front, 1);
printList(front);
std::cout<<"**********************n";
}
//GIVEN
void printList(ListNode<int> * front){
ListNode<int> * current = front;
while (current!=nullptr){
std::cout<<current->getData()<<"n";
current=current->getNext();
}
if (front ==nullptr)
std::cout<<"EMPTY LIST n";
}
//GIVEN
int search(ListNode<int> * front,int value){
ListNode<int> * current = front;
while (current!=nullptr&& current->getData()!=value){
// std::cout<<current->getData()<<"n";
current=current->getNext();
}
if (current!= nullptr) return current->getData();
return value+1 ; // to indicate not found. The calling program checks if return value is the same
as search value to know if its found; I was using *-1 but if search value is 0, then that does not
work;
}
//GIVEN
void addNode(ListNode<int> * & front ,int value){
ListNode<int> * current = front;
ListNode<int> * temp = new ListNode<int>(value);
if (front ==nullptr)
front=temp;
else {
while (current->getNext()!=nullptr){
// std::cout<<current->getData()<<"n";
current=current->getNext();
}
//ListNode<int> * temp = new ListNode<int>(value);
current->setNext(temp);
}
}
//TODO
void remove(ListNode<int> * &front,int value){
//TODO
}
//TODO
void insert(ListNode<int> * &front,int value){
//TODO
}
output.txt
EMPTY LIST
**********************
1
**********************
1
2
**********************
1
2
4
**********************
1
2
3
4
**********************
2
3
4
**********************
1
2
3
4
**********************
1
2
4
**********************
1
2
**********************
1
2
**********************
1
**********************
EMPTY LIST
**********************
4
**********************
1
4
**********************
This assignment and the next (#5) involve design and development of a sequential non
contiguous and dynamic datastructure called LinkedList. A linked list object is a container
consisting of connected ListNode objects. As before, we are not going to use pre-fabricated
classes from the c++ library, but construct the LinkedList ADT from scratch. The first step is
construction and testing of the ListNode class. A ListNode object contains a data field and a
pointer to the next ListNode object (note the recursive definition). #This assignment requires
you to 1. Read the Assignment 4 Notes 2. Watch the Assignment 4 Support video 3. Implement
the following methods of the ListNode class -custom constructor -setters for next pointer and
data 4. Implement the insert and remove method in the main program 5. Scan the given template
to find the above //TODO and implement the code needed //TODO in ListNodecpp. h file public:
ListNode(T idata, ListNode < T > newNext); public: void setNext(ListNode < T > newNext);
public: void setData(T newData); # The driver is given ListNodeMain.cpp is given to you that
does the following tests 1. Declares a pointer called front to point to a ListNode of datatype
integer 2. Constructs four ListNodes with data 1,2,4 and adds them to form a linkeo list. 3.
Inserts ListNode with data 3 to the list 4. Removes node 1 and adds it back to test removing and
adding the first element 5. Removes node 3 to test removing a middle node 6. Removes node 4 to
test removing the last node 7. Attempt to remove a non existent node 8. Remove all existing
nodes to empty the list 9. Insert node 4 and then node 1 to test if insertions preserve order 10.
Print the list

More Related Content

Similar to C++ Please write the whole code that is needed for this assignment- wr.docx (20)

Can somebody solve the TODO parts of the following problem- Thanks D.pdf
Can somebody solve the TODO parts of the following problem- Thanks   D.pdfCan somebody solve the TODO parts of the following problem- Thanks   D.pdf
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
vinaythemodel
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
Programming Exam Help
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
Programming Homework Help
 
In the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdfIn the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdf
arjunstores123
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
DaniyalAli81
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
ecomputernotes
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
MatthPYNashd
 
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdfC++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
armyshoes
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdf
Arrowdeepak
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
arihantelehyb
 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Edwardw5nSlaterl
 
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docxWrite a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
noreendchesterton753
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
callawaycorb73779
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdf
eyeonsecuritysystems
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
almaniaeyewear
 
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
Can somebody solve the TODO parts of the following problem- Thanks   D.pdfCan somebody solve the TODO parts of the following problem- Thanks   D.pdf
Can somebody solve the TODO parts of the following problem- Thanks D.pdf
vinaythemodel
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
In the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdfIn the class we extensively discussed a node class called IntNode in.pdf
In the class we extensively discussed a node class called IntNode in.pdf
arjunstores123
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
ecomputernotes
 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
MatthPYNashd
 
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdfC++ CodeConsider the LinkedList class and the Node class that we s.pdf
C++ CodeConsider the LinkedList class and the Node class that we s.pdf
armyshoes
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdf
Arrowdeepak
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
arihantelehyb
 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Edwardw5nSlaterl
 
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docxWrite a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
noreendchesterton753
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
callawaycorb73779
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdf
eyeonsecuritysystems
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
almaniaeyewear
 

More from BrianGHiNewmanv (20)

Cai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docxCai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docx
BrianGHiNewmanv
 
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docxCabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
BrianGHiNewmanv
 
C-{2-8-10}.docx
C-{2-8-10}.docxC-{2-8-10}.docx
C-{2-8-10}.docx
BrianGHiNewmanv
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docx
BrianGHiNewmanv
 
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docxC++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
BrianGHiNewmanv
 
By researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docxBy researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docx
BrianGHiNewmanv
 
By which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docxBy which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docx
BrianGHiNewmanv
 
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docxBONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BrianGHiNewmanv
 
Business ethics- 12- Introduce the abuse of official position concept.docx
Business ethics- 12- Introduce  the abuse of official position concept.docxBusiness ethics- 12- Introduce  the abuse of official position concept.docx
Business ethics- 12- Introduce the abuse of official position concept.docx
BrianGHiNewmanv
 
Building a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docxBuilding a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docx
BrianGHiNewmanv
 
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docxBuilding a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
BrianGHiNewmanv
 
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docxBriefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
BrianGHiNewmanv
 
Briefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docxBriefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docx
BrianGHiNewmanv
 
Brite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docxBrite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docx
BrianGHiNewmanv
 
Bridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docxBridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docx
BrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BrianGHiNewmanv
 
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docxBONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BrianGHiNewmanv
 
Bob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docxBob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docx
BrianGHiNewmanv
 
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docxBlood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
BrianGHiNewmanv
 
Cai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docxCai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docx
BrianGHiNewmanv
 
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docxCabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
BrianGHiNewmanv
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docx
BrianGHiNewmanv
 
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docxC++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
BrianGHiNewmanv
 
By researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docxBy researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docx
BrianGHiNewmanv
 
By which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docxBy which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docx
BrianGHiNewmanv
 
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docxBONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BrianGHiNewmanv
 
Business ethics- 12- Introduce the abuse of official position concept.docx
Business ethics- 12- Introduce  the abuse of official position concept.docxBusiness ethics- 12- Introduce  the abuse of official position concept.docx
Business ethics- 12- Introduce the abuse of official position concept.docx
BrianGHiNewmanv
 
Building a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docxBuilding a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docx
BrianGHiNewmanv
 
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docxBuilding a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
BrianGHiNewmanv
 
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docxBriefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
BrianGHiNewmanv
 
Briefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docxBriefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docx
BrianGHiNewmanv
 
Brite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docxBrite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docx
BrianGHiNewmanv
 
Bridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docxBridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docx
BrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BrianGHiNewmanv
 
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docxBONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BrianGHiNewmanv
 
Bob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docxBob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docx
BrianGHiNewmanv
 
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docxBlood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
BrianGHiNewmanv
 
Ad

Recently uploaded (20)

Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptxWRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
Sourav Kr Podder
 
Smart Borrowing: Everything You Need to Know About Short Term Loans in India
Smart Borrowing: Everything You Need to Know About Short Term Loans in IndiaSmart Borrowing: Everything You Need to Know About Short Term Loans in India
Smart Borrowing: Everything You Need to Know About Short Term Loans in India
fincrifcontent
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Freckle Project April 2025 Survey and report May 2025.pptx
Freckle Project April 2025 Survey and report May 2025.pptxFreckle Project April 2025 Survey and report May 2025.pptx
Freckle Project April 2025 Survey and report May 2025.pptx
EveryLibrary
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
la storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglesela storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglese
LetiziaLucente
 
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGYHUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
DHARMENDRA SAHU
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptxWRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
WRITTEN THEME ROUND- OPEN GENERAL QUIZ.pptx
Sourav Kr Podder
 
Smart Borrowing: Everything You Need to Know About Short Term Loans in India
Smart Borrowing: Everything You Need to Know About Short Term Loans in IndiaSmart Borrowing: Everything You Need to Know About Short Term Loans in India
Smart Borrowing: Everything You Need to Know About Short Term Loans in India
fincrifcontent
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
Freckle Project April 2025 Survey and report May 2025.pptx
Freckle Project April 2025 Survey and report May 2025.pptxFreckle Project April 2025 Survey and report May 2025.pptx
Freckle Project April 2025 Survey and report May 2025.pptx
EveryLibrary
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
la storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglesela storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglese
LetiziaLucente
 
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGYHUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
HUMAN SKELETAL SYSTEM ANATAMY AND PHYSIOLOGY
DHARMENDRA SAHU
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
Ad

C++ Please write the whole code that is needed for this assignment- wr.docx

  • 1. C++ Please write the whole code that is needed for this assignment, write the completed code together with the provided one, don't copy anyone else's code, label in what file each code belongs, and please don't forget to share your code output after finishing writing the code, if these requirements aren't met, I will nor upvote the answer, everything must be clear and complete, everything is given below. Thank you. ListNode.h #include<memory> #include <string> template <class T> //template <class T> class ListNode{ public: T data; public: ListNode * next; // post: constructs a node with data 0 and null link public: ListNode(); public: ListNode(T data); public: ListNode(T idata, ListNode<T> * newNext); public:std::string toString(); public: ListNode<T> * getNext(); public: void setNext(ListNode<T> * newNext); public: T getData(); public: void setData(T newData); }; ListNodecpp.h #include "ListNode.h" template <class T> // post: constructs a node with data 0 and null link //GIVEN ListNode<T>:: ListNode() { //std::cout<<" IN constructor"<<std::endl; T t ; next=nullptr; } //GIVEN template <class T> ListNode<T>:: ListNode(T idata) { data=idata; next=nullptr; }
  • 2. //TODO template <class T> ListNode<T>:: ListNode(T idata, ListNode<T>* inext) { //TODO - assign data and next pointer } //GIVEN template <class T> std::string ListNode<T>::toString(){ return data.toString(); } //GIVEN template <class T> ListNode<T> * ListNode<T>::getNext(){ return next; } //TODO template <class T> void ListNode<T>::setNext(ListNode<T> * newNext){ //TODO set the next pointer to incoming value } //GIVEN template <class T> T ListNode<T>::getData(){ return data; } //TODO template <class T> void ListNode<T>::setData(T newData){ //TODO set the data to incoming value } main.cpp #include <iostream> #include "ListNodecpp.h" //Requires: integer value for searching, address of front //Effects: traverses the list node chain starting from front until the end comparing search value with listnode getData. Returns the original search value if found, if not adds +1 to indicate not found //Modifies: Nothing int search(ListNode<int> * front, int value); //Requires: integer value for inserting, address of front //Effects: creates a new ListNode with value and inserts in proper position (increasing order)in the chain. If chain is empty, adds to the beginning //Modifies: front, if node is added at the beginning.
  • 3. //Also changes the next pointer of the previous node to point to the newly inserted list node. the next pointer of the newly inserted pointer points to what was the next of the previous node. This way both previous and current links are adjusted //******** NOTE the use of & in passing pointer to front as parameter - Why do you think this is needed ?********** void insert(ListNode<int> * &front,int value); //Requires: integer value for adding, address of front //Effects:creates a new ListNode with value and inserts at the beginning //Modifies:front, if node is added at the beginning. void addNode(ListNode<int> * &front,int value); //Requires: integer value for removing, address of front //Effects: removes a node, if list is empty or node not found, removes nothing. //Modifies: If the first node is removed, front is adjusted. // if removal is at the end or middle, makes sure all nececssary links are updated. void remove(ListNode<int>* & front, int value); //Requires: address of front //Effects: prints data of each node, by traversing the chain starting from the front using next pointers. //Modifies: nothing void printList(ListNode<int> * front); //GIVEN int main() { // Add 3 Nodes to the chain of ListNodes //note AddNode method appends to the end so this will be out of order // the order of the nodes is 1,2 , 4 //Create a daisy chain aka Linked List // ListNode<int> * front = nullptr; printList(front); std::cout<<"**********************n"; addNode(front,1); printList(front); std::cout<<"**********************n"; addNode(front,2); printList(front); std::cout<<"**********************n"; addNode(front,4); printList(front); std::cout<<"**********************n";
  • 4. // the insert method inserts node with value 3 in place insert(front,3); printList(front); std::cout<<"**********************n"; // remove the first, so front needs to point to second remove(front, 1); printList(front); std::cout<<"**********************n"; // insert it back insert(front,1); printList(front); std::cout<<"**********************n"; //remove from the middle remove(front, 3); printList(front); std::cout<<"**********************n"; // remove at the end remove(front, 4); printList(front); std::cout<<"**********************n"; //remove a non existent node remove(front, 5); printList(front); std::cout<<"**********************n"; // remove all nodes one by one leaving only front pointing to null pointer remove(front, 2); printList(front); std::cout<<"**********************n"; remove(front, 1); printList(front); std::cout<<"**********************n"; // insert at the beginning of the empty list a larger value insert(front, 4); printList(front); std::cout<<"**********************n"; // insert the smaller value at correct position in the front of the chain and change front insert(front, 1); printList(front); std::cout<<"**********************n"; } //GIVEN void printList(ListNode<int> * front){ ListNode<int> * current = front;
  • 5. while (current!=nullptr){ std::cout<<current->getData()<<"n"; current=current->getNext(); } if (front ==nullptr) std::cout<<"EMPTY LIST n"; } //GIVEN int search(ListNode<int> * front,int value){ ListNode<int> * current = front; while (current!=nullptr&& current->getData()!=value){ // std::cout<<current->getData()<<"n"; current=current->getNext(); } if (current!= nullptr) return current->getData(); return value+1 ; // to indicate not found. The calling program checks if return value is the same as search value to know if its found; I was using *-1 but if search value is 0, then that does not work; } //GIVEN void addNode(ListNode<int> * & front ,int value){ ListNode<int> * current = front; ListNode<int> * temp = new ListNode<int>(value); if (front ==nullptr) front=temp; else { while (current->getNext()!=nullptr){ // std::cout<<current->getData()<<"n"; current=current->getNext(); } //ListNode<int> * temp = new ListNode<int>(value); current->setNext(temp); } } //TODO void remove(ListNode<int> * &front,int value){ //TODO } //TODO void insert(ListNode<int> * &front,int value){
  • 7. ********************** 1 4 ********************** This assignment and the next (#5) involve design and development of a sequential non contiguous and dynamic datastructure called LinkedList. A linked list object is a container consisting of connected ListNode objects. As before, we are not going to use pre-fabricated classes from the c++ library, but construct the LinkedList ADT from scratch. The first step is construction and testing of the ListNode class. A ListNode object contains a data field and a pointer to the next ListNode object (note the recursive definition). #This assignment requires you to 1. Read the Assignment 4 Notes 2. Watch the Assignment 4 Support video 3. Implement the following methods of the ListNode class -custom constructor -setters for next pointer and data 4. Implement the insert and remove method in the main program 5. Scan the given template to find the above //TODO and implement the code needed //TODO in ListNodecpp. h file public: ListNode(T idata, ListNode < T > newNext); public: void setNext(ListNode < T > newNext); public: void setData(T newData); # The driver is given ListNodeMain.cpp is given to you that does the following tests 1. Declares a pointer called front to point to a ListNode of datatype integer 2. Constructs four ListNodes with data 1,2,4 and adds them to form a linkeo list. 3. Inserts ListNode with data 3 to the list 4. Removes node 1 and adds it back to test removing and adding the first element 5. Removes node 3 to test removing a middle node 6. Removes node 4 to test removing the last node 7. Attempt to remove a non existent node 8. Remove all existing nodes to empty the list 9. Insert node 4 and then node 1 to test if insertions preserve order 10. Print the list