SlideShare a Scribd company logo
1 of 7
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

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.pdfvinaythemodel
Β 
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.pdfankit11134
Β 
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-.pdfvishalateen
Β 
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.pdfarjunstores123
Β 
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.pdfthangarajarivukadal
Β 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
Β 
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.docxMatthPYNashd
Β 
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.pdfarmyshoes
Β 
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, .pdfArrowdeepak
Β 
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.pdfarihantelehyb
Β 
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.pdfEdwardw5nSlaterl
Β 
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.docxnoreendchesterton753
Β 
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..pdfferoz544
Β 
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.pdfcallawaycorb73779
Β 
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.pdfJUSTSTYLISH3B2MOHALI
Β 
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.pdfeyeonsecuritysystems
Β 
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.pdfalmaniaeyewear
Β 

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
Β 
C Exam Help
C Exam Help C Exam Help
C 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
Β 
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
Β 
C Homework Help
C Homework HelpC Homework Help
C 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
Β 
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
Β 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
Β 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 

More from 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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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).docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 
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.docxBrianGHiNewmanv
Β 

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
Β 
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
Β 
C-{2-8-10}.docx
C-{2-8-10}.docxC-{2-8-10}.docx
C-{2-8-10}.docx
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 
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
Β 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Β 
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
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
Β 
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
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
Β 
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈcall girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ9953056974 Low Rate Call Girls In Saket, Delhi NCR
Β 
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
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
Β 
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
Β 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
Β 
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
Β 
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
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
Β 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
Β 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
Β 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Β 
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
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
Β 
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
Β 
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 ...
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
Β 
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈcall girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
call girls in Kamla Market (DELHI) πŸ” >ΰΌ’9953330565πŸ” genuine Escort Service πŸ”βœ”οΈβœ”οΈ
Β 
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
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
Β 
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
Β 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
Β 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
Β 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
Β 
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
Β 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
Β 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
Β 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
Β 
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Β 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
Β 

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