CS 300 Data Structures Assignment2 - Linked List Sample Main: Here are the sample usages: int main() { } SLLString str("Hello world!"); SLLString newStr = new SLLString; newStr = str; newStr += SLLString(" CS@BC"); newStr[6] = 'W'; cout << newStr << endl; // Hello World! CS@BC cout << newStr.length() << endl; //18 int loc = newStr.findSubstring(“World”); cout << loc << endl; // 6 newStr.erase('1'); //erase the letter 1. cout << newStr << endl; // Heo Word! CS@BC newStr.erase('C'); cout << newStr << endl; // Heo Word! S@B Fall 2022 TODO You are asked to: create SLLString class and provide implementations for all functions given in the assignment description use singly linked list to implement string as a linked list of characters overload << operator so that cout << works with SLLString objects apply big three rule by implementing copy constructor, assignment operator and destructor CS 300 Data Structures Assignment2 - Linked List Purpose: This assignment will help you get practice with: Singly Linked Lists C++ Rule of Big Tree (destructor. copy constructor. copy assignment operator) C++ operator overloading C++ pointers and reference variables ● TASK In many programming languages, the String class is typically implemented as an array of characters. Some other languages, such as Haskell, Erlang, and a few other functional programming languages, however, implement strings as Singly Linked List (SLL) of characters. Compared with the array implementations, the SLL ones are very easy for pattern matching because of the recursive structure of linked list. Let's not worry about recursion in this assignment. ● Assignment-2 String as Singly Linked List In this assignment, you will implement a SLLString class using SLL. Your SLLString class will include the following members: ● ● ● Fall 2022 SLLString(); //Default constructor SLLString(const string& other); //copy constructor taking a C++ string as parameter. ~SLLString(); // destructor SLLString(const SLLString& other); //copy constructor taking another SLLString SLLString& operator=(const SLLString& other); // assignment constructor int length(); // get length of this string SLLString& operator+= (const SLLString& other); // concatenation char& operator[](const int n); //get character at index n int findSubstring(const SLLString& substring); // find the index of the first occurrence of substring in the current string. Returns -1 if not found int findSubstring(const string& substring); // find the index of the first occurrence of substring in the current string. Returns -1 if not found void erase(char c); //erase all occurrences of character c from the current string support cout << operator Node* head; // the head pointer to the SLL Each Node object should contain a char data type (name it data) and a next pointer (name it next) to Node.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I got very confused by this assignment, I found one similar question but the answer didn't seem complete. Please answer with a compilable code, many thanks (BTW it's due tonight 11:59 pm).

CS 300 Data Structures
Assignment2 - Linked List
Sample Main: Here are the sample usages:
int main() {
}
SLLString str("Hello world!");
SLLString newStr = new SLLString;
newStr = str;
newStr += SLLString(" CS@BC");
newStr[6]
= 'W';
cout << newStr << endl; // Hello World! CS@BC
cout << newStr.length() << endl; //18
int loc = newStr.findSubstring(“World”);
cout << loc << endl; // 6
newStr.erase('1'); //erase the letter 1.
cout << newStr << endl; // Heo Word! CS@BC
newStr.erase('C');
cout << newStr << endl; // Heo Word! S@B
Fall 2022
TODO
You are asked to:
create SLLString class and provide implementations for all functions given in the
assignment description
use singly linked list to implement string as a linked list of characters
overload << operator so that cout << works with SLLString objects
apply big three rule by implementing copy constructor, assignment operator and
destructor
Transcribed Image Text:CS 300 Data Structures Assignment2 - Linked List Sample Main: Here are the sample usages: int main() { } SLLString str("Hello world!"); SLLString newStr = new SLLString; newStr = str; newStr += SLLString(" CS@BC"); newStr[6] = 'W'; cout << newStr << endl; // Hello World! CS@BC cout << newStr.length() << endl; //18 int loc = newStr.findSubstring(“World”); cout << loc << endl; // 6 newStr.erase('1'); //erase the letter 1. cout << newStr << endl; // Heo Word! CS@BC newStr.erase('C'); cout << newStr << endl; // Heo Word! S@B Fall 2022 TODO You are asked to: create SLLString class and provide implementations for all functions given in the assignment description use singly linked list to implement string as a linked list of characters overload << operator so that cout << works with SLLString objects apply big three rule by implementing copy constructor, assignment operator and destructor
CS 300 Data Structures
Assignment2 - Linked List
Purpose: This assignment will help you get practice with:
Singly Linked Lists
C++ Rule of Big Tree (destructor. copy constructor. copy assignment operator)
C++ operator overloading
C++ pointers and reference variables
●
TASK
In many programming languages, the String class is typically implemented as an array of
characters. Some other languages, such as Haskell, Erlang, and a few other functional
programming languages, however, implement strings as Singly Linked List (SLL) of characters.
Compared with the array implementations, the SLL ones are very easy for pattern matching
because of the recursive structure of linked list. Let's not worry about recursion in this
assignment.
●
Assignment-2
String as Singly Linked List
In this assignment, you will implement a SLLString class using SLL. Your SLLString class will
include the following members:
●
●
●
Fall 2022
SLLString(); //Default constructor
SLLString(const string& other); //copy constructor taking a C++ string as parameter.
~SLLString(); // destructor
SLLString(const SLLString& other); //copy constructor taking another SLLString
SLLString& operator=(const SLLString& other); // assignment constructor
int length(); // get length of this string
SLLString& operator+= (const SLLString& other); // concatenation
char& operator[](const int n); //get character at index n
int findSubstring(const SLLString& substring); // find the index of the first occurrence of
substring in the current string. Returns -1 if not found
int findSubstring(const string& substring); // find the index of the first occurrence of
substring in the current string. Returns -1 if not found
void erase(char c); //erase all occurrences of character c from the current string
support cout << operator
Node* head; // the head pointer to the SLL
Each Node object should contain a char data type (name it data) and a next pointer (name it
next) to Node.
Transcribed Image Text:CS 300 Data Structures Assignment2 - Linked List Purpose: This assignment will help you get practice with: Singly Linked Lists C++ Rule of Big Tree (destructor. copy constructor. copy assignment operator) C++ operator overloading C++ pointers and reference variables ● TASK In many programming languages, the String class is typically implemented as an array of characters. Some other languages, such as Haskell, Erlang, and a few other functional programming languages, however, implement strings as Singly Linked List (SLL) of characters. Compared with the array implementations, the SLL ones are very easy for pattern matching because of the recursive structure of linked list. Let's not worry about recursion in this assignment. ● Assignment-2 String as Singly Linked List In this assignment, you will implement a SLLString class using SLL. Your SLLString class will include the following members: ● ● ● Fall 2022 SLLString(); //Default constructor SLLString(const string& other); //copy constructor taking a C++ string as parameter. ~SLLString(); // destructor SLLString(const SLLString& other); //copy constructor taking another SLLString SLLString& operator=(const SLLString& other); // assignment constructor int length(); // get length of this string SLLString& operator+= (const SLLString& other); // concatenation char& operator[](const int n); //get character at index n int findSubstring(const SLLString& substring); // find the index of the first occurrence of substring in the current string. Returns -1 if not found int findSubstring(const string& substring); // find the index of the first occurrence of substring in the current string. Returns -1 if not found void erase(char c); //erase all occurrences of character c from the current string support cout << operator Node* head; // the head pointer to the SLL Each Node object should contain a char data type (name it data) and a next pointer (name it next) to Node.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY