Question
need help with the alphabetical part in the explicitconstructor m_list_driver.cpp #include #include #include m_list.h using namespace std; int main() { //m_list zero_list; //m_list first_list(data1.txt); //m_list
need help with the alphabetical part in the explicitconstructor
m_list_driver.cpp
#include
#include
#include "m_list.h"
using namespace std;
int main()
{
//m_list zero_list;
//m_list first_list("data1.txt");
//m_list second_list("data2.txt");
////Test#1: Testing default constructor,explicit-value constructor, add, length and operator //cout //cout //cout //cout //cout //cout //cout //cout //cout //Test#2: Testing merge, is_Equal, add, length andoperator ///*cout //cout //cout //cout //zero_list.merge(first_list);
//cout
//if (zero_list.is_Equal(first_list) == true)
//{
// cout //}
//else
//{
// cout //}
//cout //first_list.merge(second_list);
//cout //cout //cout //cout //cout ////Test#3: Testing search, remove, length, andoperator //cout //cout //cout //cout //first_list.remove("albert");
//first_list.remove("mary");
//first_list.remove("zebra");
//first_list.remove("lofton");
//cout //cout //cout //cout
return 0;
}
m_list.h
#include
#include
using namespace std;
#ifndef M_LIST_H
#define m_LIST_H
class m_node
{
public:
string term;
m_node* next;
};
class m_list
{
public:
//m_list(); //The default constructor creates an emptylist; front and back are set to null.
//m_list(const string & filename);//Theexplicit-value constructor will initialize your statevariables
//with the strings stored in a data file. The name of the data fileis passed
//in variable "filename". The strings will be loaded into thelinked-list in alphabetical order.
//~m_list(); //The destructor will de-allocate allmemory allocated to the list, and print the
//message "destructor called" inside the body of thedestructor.
//int length(); //The function "length" determines thelength of list; length is just the number of nodes.
//void add(string & s); //The function "add" addsa term (string) in alphabetical order to the linked list.
//friend ostream& operator //as a friend function with chaining to print list A;
//Note:each item in the list will be printed on a separate line.
//m_node * search(const string& s); //The functionreturns a pointer to the node that contains the strng "s";otherwise null is returned.
//void remove(const string & s); //The functiondeletes the first occurrence of the string "s" from the list;
//void merge(m_list & B); //The function"merge" merges the current (object) list A with list B inapphabetical order. When the function is complete,
//a copy of the items in list B will be contained in list A.
//bool is_Equal(m_list & B); //The functionreturns true if lists are equal (contain same items); falseotherwise.
private:
m_node* front, * back; //pointers to the front andback of the list.
};
#endif
m_list.cpp
#include
#include
#include
#include "m_list.h"
using namespace std;
m_list::m_list()
m_list::m_list(const string & filename)
...
data1.txt
nicole
applebee
albre
zebra
cobra
bamba
jimmie
ella
sammie
jamie
dennis
nina
tami
joy
helene
jean
jessica
barbara
joanna
ian
albert
isabella
sofia
sandra
kempie
barnie
rasaman
avi
danny
tom
data2.txt
thore
elizabeth
mary
ethel
paulette
loraine
mark
maryon
goofy
esther
paula
john
philip
puran
myra
Data Structure and Algorithm Analysis---COP3530 Module 6 Total Points: 25 NO LATE ASSIGNMENTS WILL BE ACCEPTED!! Objectives: This assignment will access your C++ language skills and understanding of linked lists. After completing this assignment you will be able to do the following: (1) Manage a singly-linked list with pointers to the front and back of the list, (2) allocate memory dynamically (3) implement a default and explicit-value constructor, (4) a destructor, (5) add a node to a singly-linked list in order, (6) search for a string in a list, (7) determine if two lists are identical, and (8) delete a node anywhere in a singly-linked list. You will implement the M_LIST ADT (abstract data type) using a singly-linked list of strings. The SM LIST ADT is defined below. Call the class you implement "m_list". Remember, a singly-linked list is composed of nodes. You will also implement a class called "m_node" that has two fields: a string field called "term"; and a pointer field called "next". Essentially, each m_node is really a node in the linked list, and m_list is the singly-linked list. Consider the following declaration of a m_node. A m_list is composed of m_nodes: class m_node { public: string term; m_node *next; }; The state (private data members) of your "m_list" class should contain a pointer to the front of the list of m_nodes called "front" and a pointer to the back of the list called "back". You may add more members to the state and more member functions to the behavior of the class if you determine necessary. Store the definition of your class in a file called "m_list.cpp." and the declaration of your class in a file called "m_list.h." You will implement all the code necessary to maintain a m_list. See the ADT below. Test the complete functionality of the class "m_list". You must use the file "m_list_driver.cpp" to help you understand and test all the required functionality of the class. If you discover that you need more tests while implementing the functionality of the m_list class, then add more tests to your driver, but your final code must be submitted with the given driver.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started