SlideShare a Scribd company logo
This will need to be in a header file called "LinkedList.h"
//Insertion
void AddHead(const T& data); //(Create a new Node at the front of the list to store the passed in
parameter.)
void AddTail(const T& data); //(Create a new Node at the end of the list to store the passed in
parameter.)
void AddNodesHead(const T* data, unsigned int count); //Given an array of values, insert a node
for each of those at the beginning of the list, maintaining the original order.
void AddNodesTail(const T* data, unsigned int count); //except adding to the end of the list
//Accessors
unsigned int NodeCount() const;
//Behaviors
void PrintForward() const; //Iterator through all of the nodes and print out their values, one a
time.
void PrintReverse() const; //Exactly the same as PrintForward, except completely the opposite
//Default Constructor
LinkedList(); //
//Destructor
~LinkedList(); //(Delete all the nodes created by the list.)
main.cpp:
#include
#include
#include
#include "LinkedList.h"
using namespace std;
void TestAddHead();
void TestAddTail();
void TestAddingArrays();
int main()
{
int testNum;
cin >> testNum;
if (testNum == 1)
TestAddHead();
else if (testNum == 2)
TestAddTail();
else if (testNum == 3)
TestAddingArrays();
return 0;
}
void TestAddHead()
{
cout << "=====Testing AddHead() functionality====" << endl;
LinkedList data;
for (int i = 0; i < 12; i += 2)
data.AddHead(i);
cout << "Node count: " << data.NodeCount() << endl;
cout << "Print list forward:" << endl;
data.PrintForward();
cout << "Print list in reverse:" << endl;
data.PrintReverse();
}
void TestAddTail()
{
cout << "=====Testing AddTail() functionality====" << endl;
LinkedList data;
for (int i = 0; i <= 21; i += 3)
data.AddTail(i);
cout << "Node count: " << data.NodeCount() << endl;
cout << "Print list forward:" << endl;
data.PrintForward();
cout << "Print list in reverse:" << endl;
data.PrintReverse();
}
void TestAddingArrays()
{
cout << "=====Testing AddNodesHead() and AddNodesTail() =====" << endl;
string values[5];
values[0] = "*";
values[1] = "**";
values[2] = "***";
values[3] = "****";
values[4] = "*****";
LinkedList list;
list.AddHead("**");
list.AddHead("***");
list.AddHead("****");
list.AddHead("*****");
list.AddHead("******");
list.AddHead("*******");
list.AddHead("********");
list.AddHead("*********");
list.AddHead("********");
list.AddHead("*******");
list.AddHead("******");
list.AddNodesHead(values, 5);
list.AddNodesTail(values, 5);
list.PrintForward();
}

More Related Content

PDF
This assignment and the next (#5) involve design and development of a.pdf
DOCX
C++ Please write the whole code that is needed for this assignment- wr.docx
DOCX
4) 15 points- Linked Lists- Consider the linked list template-type.docx
PDF
Lec-4_Linked-List (1).pdf
PDF
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
PDF
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
DOCX
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
DOCX
C++ please put everthing after you answer it- thanks Complete the stub.docx
This assignment and the next (#5) involve design and development of a.pdf
C++ Please write the whole code that is needed for this assignment- wr.docx
4) 15 points- Linked Lists- Consider the linked list template-type.docx
Lec-4_Linked-List (1).pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
C++ please put everthing after you answer it- thanks Complete the stub.docx

Similar to This will need to be in a header file called LinkedList.hInser.pdf (20)

PDF
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
PDF
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
PDF
package linkedLists- import java-util-Iterator- --- A class representi.pdf
PDF
How do you stop infinite loop Because I believe that it is making a.pdf
PDF
Consider a double-linked linked list implementation with the followin.pdf
DOCX
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
PDF
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
PDF
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
PPTX
Link List Programming Linked List in Cpp
PPT
dynamicList.ppt
PDF
please i need help Im writing a program to test the merge sort alg.pdf
PDF
In C++Write a recursive function to determine whether or not a Lin.pdf
PDF
you will implement some sorting algorithms for arrays and linked lis.pdf
PDF
Write a program to implement below operations with both singly and d.pdf
DOC
C program to insert a node in doubly linked list
PDF
Let n = size of the hash table hashTable = array of size n, w.pdf
PDF
Please help solve this in C++ So the program is working fin.pdf
PPT
Jhtp5 20 Datastructures
PDF
could you implement this function please, im having issues with it..pdf
DOCX
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
Consider a double-linked linked list implementation with the followin.pdf
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Homework 05 - Linked Lists (C++)(1) Implement the concepts of a un.pdf
Link List Programming Linked List in Cpp
dynamicList.ppt
please i need help Im writing a program to test the merge sort alg.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
you will implement some sorting algorithms for arrays and linked lis.pdf
Write a program to implement below operations with both singly and d.pdf
C program to insert a node in doubly linked list
Let n = size of the hash table hashTable = array of size n, w.pdf
Please help solve this in C++ So the program is working fin.pdf
Jhtp5 20 Datastructures
could you implement this function please, im having issues with it..pdf
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
Ad

More from cleanhome88 (7)

PDF
The U.S. monthly inflation rate for 2016 is shown belowComp.pdf
PDF
The Xerox Alto42 Imagine the value of cornering the technological mark.pdf
PDF
The SQL database needs to be able to meet the requirements for some .pdf
PDF
The senior class was on an overnight field trip. School administration.pdf
PDF
Umatilla Bank and Trust is considering giving Oriole Company a loan..pdf
PDF
Tucker is an unmarried, 29-year-old taxpayer. He received the follow.pdf
PDF
The Pennington Corporation issued a new series of bonds on January 1.pdf
The U.S. monthly inflation rate for 2016 is shown belowComp.pdf
The Xerox Alto42 Imagine the value of cornering the technological mark.pdf
The SQL database needs to be able to meet the requirements for some .pdf
The senior class was on an overnight field trip. School administration.pdf
Umatilla Bank and Trust is considering giving Oriole Company a loan..pdf
Tucker is an unmarried, 29-year-old taxpayer. He received the follow.pdf
The Pennington Corporation issued a new series of bonds on January 1.pdf
Ad

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
master seminar digital applications in india
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Structure & Organelles in detailed.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Sports Quiz easy sports quiz sports quiz
PDF
01-Introduction-to-Information-Management.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Final Presentation General Medicine 03-08-2024.pptx
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
master seminar digital applications in india
Microbial diseases, their pathogenesis and prophylaxis
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Institutional Correction lecture only . . .
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Complications of Minimal Access Surgery at WLH
Cell Structure & Organelles in detailed.
102 student loan defaulters named and shamed – Is someone you know on the list?
Sports Quiz easy sports quiz sports quiz
01-Introduction-to-Information-Management.pdf
RMMM.pdf make it easy to upload and study
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O5-L3 Freight Transport Ops (International) V1.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf

This will need to be in a header file called LinkedList.hInser.pdf

  • 1. This will need to be in a header file called "LinkedList.h" //Insertion void AddHead(const T& data); //(Create a new Node at the front of the list to store the passed in parameter.) void AddTail(const T& data); //(Create a new Node at the end of the list to store the passed in parameter.) void AddNodesHead(const T* data, unsigned int count); //Given an array of values, insert a node for each of those at the beginning of the list, maintaining the original order. void AddNodesTail(const T* data, unsigned int count); //except adding to the end of the list //Accessors unsigned int NodeCount() const; //Behaviors void PrintForward() const; //Iterator through all of the nodes and print out their values, one a time. void PrintReverse() const; //Exactly the same as PrintForward, except completely the opposite //Default Constructor LinkedList(); // //Destructor ~LinkedList(); //(Delete all the nodes created by the list.) main.cpp: #include #include #include #include "LinkedList.h" using namespace std; void TestAddHead(); void TestAddTail(); void TestAddingArrays(); int main() { int testNum; cin >> testNum; if (testNum == 1) TestAddHead(); else if (testNum == 2)
  • 2. TestAddTail(); else if (testNum == 3) TestAddingArrays(); return 0; } void TestAddHead() { cout << "=====Testing AddHead() functionality====" << endl; LinkedList data; for (int i = 0; i < 12; i += 2) data.AddHead(i); cout << "Node count: " << data.NodeCount() << endl; cout << "Print list forward:" << endl; data.PrintForward(); cout << "Print list in reverse:" << endl; data.PrintReverse(); } void TestAddTail() { cout << "=====Testing AddTail() functionality====" << endl; LinkedList data; for (int i = 0; i <= 21; i += 3) data.AddTail(i); cout << "Node count: " << data.NodeCount() << endl; cout << "Print list forward:" << endl; data.PrintForward(); cout << "Print list in reverse:" << endl; data.PrintReverse(); } void TestAddingArrays() { cout << "=====Testing AddNodesHead() and AddNodesTail() =====" << endl; string values[5]; values[0] = "*"; values[1] = "**"; values[2] = "***";
  • 3. values[3] = "****"; values[4] = "*****"; LinkedList list; list.AddHead("**"); list.AddHead("***"); list.AddHead("****"); list.AddHead("*****"); list.AddHead("******"); list.AddHead("*******"); list.AddHead("********"); list.AddHead("*********"); list.AddHead("********"); list.AddHead("*******"); list.AddHead("******"); list.AddNodesHead(values, 5); list.AddNodesTail(values, 5); list.PrintForward(); }