SlideShare a Scribd company logo
1 of 7
Download to read offline
Need Help!! C++
#include<iostream>
#include"linkedlist.h"
using namespace std;
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
//TODO: Add code here. Make sure memory is released properly.
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const{
//TODO: Add code here
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//TODO: Add comments
void LinkedList::addRear(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
void LinkedList::addFront(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
bool LinkedList::deleteFront(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//TODO: Add comments
bool LinkedList::deleteRear(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
/* --- harder ones for test 2 and 3 -- */
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool LinkedList::deleteAt(int pos, T &val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of deleting the first node and the last node
// Do not forget to set value.
}
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to
count+1.
* The value will be inserted before the node at the specified position. if pos = 1, the value will be
inserted
* at the front of the list. if pos = count+1, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserted.
* @return false: if the value was not inserted because pos is out of the range.
*/
bool LinkedList::insertAt(int pos, T val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of inserting the first node and the last node
}
/**
* @brief Copy Constructor to allow pass by value and return by value of a LinkedList
* @param other LinkedList to be copied
*/
LinkedList::LinkedList(const LinkedList &other) {
// Start with an empty list
front = nullptr;
rear = nullptr;
count = 0;
// TODO: Add code here. Interate through the other list and add a new node to this list
// for each node in the other list. The new node should have the same value as the other node.
}
/**
* @brief Overloading of = (returns a reference to a LinkedList)
* @param other LinkedList to be copied
* @return reference to a LinkedList
*/
LinkedList &LinkedList::operator=(const LinkedList &other) {
if(this != &other) { // check if the same object
// Delete all nodes in this list
// TODO: Add code here
// Interate through the other list and add a new node to this list
// Be sure to set the front and rear pointers to the correct values
// Be sure to set the count to the correct value
// TODO: Add code here
}
return *this;
}
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------
LinkedList.h
//INSTRUCTION:
//Linkedlist class - header file template
//You must complete the TODO parts and then complete LinkedList.cpp. Delete "TODO" after
you are done.
//You should always comments to each function to describe its PURPOSE and PARAMETERS
#pragma once
// =======================================================
// Your name: ??? (TODO: Add your name)
// Compiler: g++
// File type: headher file linkedlist.h
//=======================================================
#include <string>
using namespace std;
// Datatype T : element type definition
typedef int T; // int for now but can change later
//a list node is defined here as a struct Node for now
struct Node {
T val; // stored value
Node *next; // pointer to the next node
// Constructor
Node(T val = 0, Node *next = nullptr) {
this->val = val;
this->next = next;
}
};
//---------------------------------------------------------
class LinkedList {
private:
Node *front; // pointer to the front node
Node *rear; // pointer to the rear node
int count; // the number of nodes in the list
public:
LinkedList() { // constructor to create an empty list
front = nullptr;
rear = nullptr;
count = 0;
}
~LinkedList(); // destructor to destroy all nodes and release memory
/**
* @brief Copy Constructor to allow pass by value and return by value of a LinkedList
* @param other LinkedList to be copied
*/
LinkedList(const LinkedList &other);
/**
* @brief Overloading of = (returns a reference to a LinkedList)
* @param other LinkedList to be copied
* @return reference to a LinkedList
*/
LinkedList &operator=(const LinkedList &other);
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool isEmpty() const;
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int length() const;
/**
* @brief Convert the contents of the list to a string
*/
string toString();
/**
* @brief Displays the contents of the list
*
*/
void displayAll();
//TODO: Add comments
void addFront(T val);
//TODO: Add comments
void addRear(T val);
//TODO: Add comments
bool deleteFront(T &val);
//TODO: Add comments
bool deleteRear(T &val);
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 0 to count-1. pos = 0 for the first node, and pos = count-1 for the last
node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool deleteAt(int pos, T &val);
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 0 to
count.
* The value will be inserted before the node at the specified position. if pos = 0, the value will be
inserted
* at the front of the list. if pos = count, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserted.
* @return false: if the value was not inserted because pos is out of the range.
*/
bool insertAt(int pos, T val);
};
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf

More Related Content

Similar to Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf

C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
 
Please correct my errors upvote Clears our entire .pdf
Please correct my errors upvote      Clears our entire .pdfPlease correct my errors upvote      Clears our entire .pdf
Please correct my errors upvote Clears our entire .pdfkitty811
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
 
Create a link list. Add some nodes to it, search and delete nodes fro.pdf
Create a link list. Add some nodes to it, search and delete nodes fro.pdfCreate a link list. Add some nodes to it, search and delete nodes fro.pdf
Create a link list. Add some nodes to it, search and delete nodes fro.pdfhadpadrrajeshh
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfmalavshah9013
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdffantasiatheoutofthef
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfJamesPXNNewmanp
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfmail931892
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
How do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdfHow do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdffmac5
 
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfHomework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfezzi97
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfarcellzone
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfudit652068
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfarorastores
 
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docxajoy21
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docxhoney725342
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfkingsandqueens3
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
 
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
 

Similar to Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf (20)

C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
Please correct my errors upvote Clears our entire .pdf
Please correct my errors upvote      Clears our entire .pdfPlease correct my errors upvote      Clears our entire .pdf
Please correct my errors upvote Clears our entire .pdf
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
Create a link list. Add some nodes to it, search and delete nodes fro.pdf
Create a link list. Add some nodes to it, search and delete nodes fro.pdfCreate a link list. Add some nodes to it, search and delete nodes fro.pdf
Create a link list. Add some nodes to it, search and delete nodes fro.pdf
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
How do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdfHow do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdf
 
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdfHomework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
#ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.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
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 

More from Edwardw5nSlaterl

On January 19- I sent an announcement about the different types of law.pdf
On January 19- I sent an announcement about the different types of law.pdfOn January 19- I sent an announcement about the different types of law.pdf
On January 19- I sent an announcement about the different types of law.pdfEdwardw5nSlaterl
 
On January 31- a snowstorm damaged the office of a small business- and (3).pdf
On January 31- a snowstorm damaged the office of a small business- and (3).pdfOn January 31- a snowstorm damaged the office of a small business- and (3).pdf
On January 31- a snowstorm damaged the office of a small business- and (3).pdfEdwardw5nSlaterl
 
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdf
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdfOn June 1- 2013- May and Nora formed a partnership- May is to invest a.pdf
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdfEdwardw5nSlaterl
 
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdf
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdfOn January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdf
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdfEdwardw5nSlaterl
 
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdf
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdfOn January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdf
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdfEdwardw5nSlaterl
 
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdf
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdfOn January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdf
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdfEdwardw5nSlaterl
 
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdf
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdfOn January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdf
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdfEdwardw5nSlaterl
 
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdf
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdfOn January 1- 2020- A- B and C establish a joint undertaking to manufa.pdf
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdfEdwardw5nSlaterl
 
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdf
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdfOn January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdf
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdfEdwardw5nSlaterl
 
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdf
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdfOn fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdf
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdfEdwardw5nSlaterl
 
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdf
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdfOn February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdf
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdfEdwardw5nSlaterl
 
Objective Take user inputs and add them to the nested dictionary data.pdf
Objective Take user inputs and add them to the nested dictionary data.pdfObjective Take user inputs and add them to the nested dictionary data.pdf
Objective Take user inputs and add them to the nested dictionary data.pdfEdwardw5nSlaterl
 
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdf
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdfOn December 31- 20X1- the ledger of Lopez Company contained the follow.pdf
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdfEdwardw5nSlaterl
 
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdf
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdfOK- here we are with Covid-19 and flu- and the rise of other diseases.pdf
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdfEdwardw5nSlaterl
 
Of the adult population in the United States- 47- have hypertension- A.pdf
Of the adult population in the United States- 47- have hypertension- A.pdfOf the adult population in the United States- 47- have hypertension- A.pdf
Of the adult population in the United States- 47- have hypertension- A.pdfEdwardw5nSlaterl
 
Obtain the demand functions of x and y for the following utility funct.pdf
Obtain the demand functions of x and y for the following utility funct.pdfObtain the demand functions of x and y for the following utility funct.pdf
Obtain the demand functions of x and y for the following utility funct.pdfEdwardw5nSlaterl
 
Obtain a copy of the City of Orlando government's annual operating bud.pdf
Obtain a copy of the City of Orlando government's annual operating bud.pdfObtain a copy of the City of Orlando government's annual operating bud.pdf
Obtain a copy of the City of Orlando government's annual operating bud.pdfEdwardw5nSlaterl
 
Obtain a copy of the City of Orlando government's annual operating bud (1).pdf
Obtain a copy of the City of Orlando government's annual operating bud (1).pdfObtain a copy of the City of Orlando government's annual operating bud (1).pdf
Obtain a copy of the City of Orlando government's annual operating bud (1).pdfEdwardw5nSlaterl
 
Obtain a copy of the City of Orlando government's annual operating bud (4).pdf
Obtain a copy of the City of Orlando government's annual operating bud (4).pdfObtain a copy of the City of Orlando government's annual operating bud (4).pdf
Obtain a copy of the City of Orlando government's annual operating bud (4).pdfEdwardw5nSlaterl
 
Obtain a copy of the City of Orlando government's annual operating bud (2).pdf
Obtain a copy of the City of Orlando government's annual operating bud (2).pdfObtain a copy of the City of Orlando government's annual operating bud (2).pdf
Obtain a copy of the City of Orlando government's annual operating bud (2).pdfEdwardw5nSlaterl
 

More from Edwardw5nSlaterl (20)

On January 19- I sent an announcement about the different types of law.pdf
On January 19- I sent an announcement about the different types of law.pdfOn January 19- I sent an announcement about the different types of law.pdf
On January 19- I sent an announcement about the different types of law.pdf
 
On January 31- a snowstorm damaged the office of a small business- and (3).pdf
On January 31- a snowstorm damaged the office of a small business- and (3).pdfOn January 31- a snowstorm damaged the office of a small business- and (3).pdf
On January 31- a snowstorm damaged the office of a small business- and (3).pdf
 
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdf
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdfOn June 1- 2013- May and Nora formed a partnership- May is to invest a.pdf
On June 1- 2013- May and Nora formed a partnership- May is to invest a.pdf
 
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdf
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdfOn January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdf
On January 4- 2019- the DJIA opened at 11-739-19- The divisor at that.pdf
 
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdf
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdfOn January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdf
On January 1-1988- Antonio invests $9-400 in an investment fund- On Ja.pdf
 
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdf
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdfOn January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdf
On January 1- Southwest College received $1-270-000 in Unearned Tuitio.pdf
 
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdf
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdfOn January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdf
On January 1- 2020- Pharoah Corporation had 96-000 shares of no-par co.pdf
 
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdf
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdfOn January 1- 2020- A- B and C establish a joint undertaking to manufa.pdf
On January 1- 2020- A- B and C establish a joint undertaking to manufa.pdf
 
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdf
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdfOn January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdf
On January 1 - Daniel borrows $5100 with a fixed annual interest rate.pdf
 
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdf
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdfOn fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdf
On fune 1- 20v7- Young Corporation paid $20-000 cash for machinery tha.pdf
 
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdf
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdfOn February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdf
On February 1- 2023- Tessa Williams and Audrey Xie formed a partnershi.pdf
 
Objective Take user inputs and add them to the nested dictionary data.pdf
Objective Take user inputs and add them to the nested dictionary data.pdfObjective Take user inputs and add them to the nested dictionary data.pdf
Objective Take user inputs and add them to the nested dictionary data.pdf
 
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdf
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdfOn December 31- 20X1- the ledger of Lopez Company contained the follow.pdf
On December 31- 20X1- the ledger of Lopez Company contained the follow.pdf
 
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdf
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdfOK- here we are with Covid-19 and flu- and the rise of other diseases.pdf
OK- here we are with Covid-19 and flu- and the rise of other diseases.pdf
 
Of the adult population in the United States- 47- have hypertension- A.pdf
Of the adult population in the United States- 47- have hypertension- A.pdfOf the adult population in the United States- 47- have hypertension- A.pdf
Of the adult population in the United States- 47- have hypertension- A.pdf
 
Obtain the demand functions of x and y for the following utility funct.pdf
Obtain the demand functions of x and y for the following utility funct.pdfObtain the demand functions of x and y for the following utility funct.pdf
Obtain the demand functions of x and y for the following utility funct.pdf
 
Obtain a copy of the City of Orlando government's annual operating bud.pdf
Obtain a copy of the City of Orlando government's annual operating bud.pdfObtain a copy of the City of Orlando government's annual operating bud.pdf
Obtain a copy of the City of Orlando government's annual operating bud.pdf
 
Obtain a copy of the City of Orlando government's annual operating bud (1).pdf
Obtain a copy of the City of Orlando government's annual operating bud (1).pdfObtain a copy of the City of Orlando government's annual operating bud (1).pdf
Obtain a copy of the City of Orlando government's annual operating bud (1).pdf
 
Obtain a copy of the City of Orlando government's annual operating bud (4).pdf
Obtain a copy of the City of Orlando government's annual operating bud (4).pdfObtain a copy of the City of Orlando government's annual operating bud (4).pdf
Obtain a copy of the City of Orlando government's annual operating bud (4).pdf
 
Obtain a copy of the City of Orlando government's annual operating bud (2).pdf
Obtain a copy of the City of Orlando government's annual operating bud (2).pdfObtain a copy of the City of Orlando government's annual operating bud (2).pdf
Obtain a copy of the City of Orlando government's annual operating bud (2).pdf
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
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
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
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
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
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
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf

  • 1. Need Help!! C++ #include<iostream> #include"linkedlist.h" using namespace std; /** * @brief Destructor to destroy all nodes and release memory */ LinkedList::~LinkedList() { //TODO: Add code here. Make sure memory is released properly. } /** * @brief Purpose: Checks if the list is empty * @return true if the list is empty, false otherwise */ bool LinkedList::isEmpty() const { // TODO: Add code here return count == 0; } /** * @brief Get the number of nodes in the list * @return int The number of nodes in the list */ int LinkedList::length() const{ //TODO: Add code here } /** * @brief Convert the list to a string * */ string LinkedList::toString() { string str = "["; Node *ptr = front; if (ptr != nullptr) { // Head node is not preceded by separator str += to_string(ptr->val); ptr = ptr->next; } while (ptr != nullptr) { str += ", " + to_string(ptr->val); ptr = ptr->next;
  • 2. } str += "]"; return str; } /** * @brief Displays the contents of the list */ void LinkedList::displayAll() { cout << toString() << endl; } //TODO: Add comments void LinkedList::addRear(T val) { // TODO: Add code here // consider the two cases of whether the list was empty } //TODO: Add comments void LinkedList::addFront(T val) { // TODO: Add code here // consider the two cases of whether the list was empty } //TODO: Add comments bool LinkedList::deleteFront(T &OldNum) { // TODO: Add code here // consider if the list was empty and return false if the list is empty // consider the special case of deleting the only node in the list } //TODO: Add comments bool LinkedList::deleteRear(T &OldNum) { // TODO: Add code here // consider if the list was empty and return false if the list is empty // consider the special case of deleting the only node in the list } /* --- harder ones for test 2 and 3 -- */ /** * @brief Delete a node at a given position from the list. The * node at position pos is deleted and the value of the deleted node is returned in val. * The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node. * @param pos: position of the node to be deleted * @param val: it is set to the value of the node to be deleted
  • 3. * @return true: if the node was deleted successfully * @return false: if the node was not deleted successfully because the position was out of range */ bool LinkedList::deleteAt(int pos, T &val) { //TODO: Add code here // check if the pos is valid first, then move the ptr to the rigth positon // consider the special case of deleting the first node and the last node // Do not forget to set value. } /** * @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to count+1. * The value will be inserted before the node at the specified position. if pos = 1, the value will be inserted * at the front of the list. if pos = count+1, the value will be inserted at the rear of the list. * @param pos: position to insert the value at. * @param val: value to insert. * @return true: if the value was inserted. * @return false: if the value was not inserted because pos is out of the range. */ bool LinkedList::insertAt(int pos, T val) { //TODO: Add code here // check if the pos is valid first, then move the ptr to the rigth positon // consider the special case of inserting the first node and the last node } /** * @brief Copy Constructor to allow pass by value and return by value of a LinkedList * @param other LinkedList to be copied */ LinkedList::LinkedList(const LinkedList &other) { // Start with an empty list front = nullptr; rear = nullptr; count = 0; // TODO: Add code here. Interate through the other list and add a new node to this list // for each node in the other list. The new node should have the same value as the other node. } /** * @brief Overloading of = (returns a reference to a LinkedList) * @param other LinkedList to be copied * @return reference to a LinkedList */
  • 4. LinkedList &LinkedList::operator=(const LinkedList &other) { if(this != &other) { // check if the same object // Delete all nodes in this list // TODO: Add code here // Interate through the other list and add a new node to this list // Be sure to set the front and rear pointers to the correct values // Be sure to set the count to the correct value // TODO: Add code here } return *this; } --------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------- LinkedList.h //INSTRUCTION: //Linkedlist class - header file template //You must complete the TODO parts and then complete LinkedList.cpp. Delete "TODO" after you are done. //You should always comments to each function to describe its PURPOSE and PARAMETERS #pragma once // ======================================================= // Your name: ??? (TODO: Add your name) // Compiler: g++ // File type: headher file linkedlist.h //======================================================= #include <string> using namespace std; // Datatype T : element type definition typedef int T; // int for now but can change later //a list node is defined here as a struct Node for now struct Node { T val; // stored value Node *next; // pointer to the next node // Constructor Node(T val = 0, Node *next = nullptr) { this->val = val; this->next = next; } }; //---------------------------------------------------------
  • 5. class LinkedList { private: Node *front; // pointer to the front node Node *rear; // pointer to the rear node int count; // the number of nodes in the list public: LinkedList() { // constructor to create an empty list front = nullptr; rear = nullptr; count = 0; } ~LinkedList(); // destructor to destroy all nodes and release memory /** * @brief Copy Constructor to allow pass by value and return by value of a LinkedList * @param other LinkedList to be copied */ LinkedList(const LinkedList &other); /** * @brief Overloading of = (returns a reference to a LinkedList) * @param other LinkedList to be copied * @return reference to a LinkedList */ LinkedList &operator=(const LinkedList &other); /** * @brief Purpose: Checks if the list is empty * @return true if the list is empty, false otherwise */ bool isEmpty() const; /** * @brief Get the number of nodes in the list * @return int The number of nodes in the list */ int length() const; /** * @brief Convert the contents of the list to a string */ string toString();
  • 6. /** * @brief Displays the contents of the list * */ void displayAll(); //TODO: Add comments void addFront(T val); //TODO: Add comments void addRear(T val); //TODO: Add comments bool deleteFront(T &val); //TODO: Add comments bool deleteRear(T &val); /** * @brief Delete a node at a given position from the list. The * node at position pos is deleted and the value of the deleted node is returned in val. * The valid range of pos is 0 to count-1. pos = 0 for the first node, and pos = count-1 for the last node. * @param pos: position of the node to be deleted * @param val: it is set to the value of the node to be deleted * @return true: if the node was deleted successfully * @return false: if the node was not deleted successfully because the position was out of range */ bool deleteAt(int pos, T &val); /** * @brief Insert a value at a specified position in the list. The valid pos is in the range of 0 to count. * The value will be inserted before the node at the specified position. if pos = 0, the value will be inserted * at the front of the list. if pos = count, the value will be inserted at the rear of the list. * @param pos: position to insert the value at. * @param val: value to insert. * @return true: if the value was inserted. * @return false: if the value was not inserted because pos is out of the range. */ bool insertAt(int pos, T val); };