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

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

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); };