Starting from:

$25

SNEG1120-Assignment 1 Solved

You are required to build the infrastructure to manipulate data related to text. Your client further specifies that you are to create a class named LinkedList to store individual tokens. The LinkedList will store each token in a Node of the list, using the class string. 

 

 

ASSIGNMENT TASK 

You are required to use a doubly-linked list, as discussed in lectures, to create your own implementation of the LinkedList class. It will use instances of Node to store instances of value_type (in this assignment, each Node will be used to store an instance of string). 

 

The LinkedList class will be used by a main program, to be supplied to you, as well as a makefile. You will need to design LinkedList and Node in a way that it communicates seamlessly with the main program and compiles with the makefile also supplied. Please refer to the lecture slides and recordings for guidance on how to implement both classes. 

 

You will need to implement constructors, overloaded operators, and a method that sorts the content of the linked list. You can use any sorting algorithm, but we recommend bubble sort. It is not efficient, but is very easy to implement (https://www.geeksforgeeks.org/bubble-sort/). 

 

  

 

Here is a screenshot of the expected output  

 

  

 

 

 

 

 

 

 

 

 

 

CES236-7DXQJX2+Alex@CES236-7DXQJX2 ~/Assignment1 

$ make clean rm -rf *.o core 

 

CES236-7DXQJX2+Alex@CES236-7DXQJX2 ~/Assignment1 

$ make 

g++ -c -Wall -c LinkedListDemo.cpp g++ -c -Wall -c LinkedList.cpp g++ -c -Wall -c Node.cpp 

g++  LinkedListDemo.o LinkedList.o Node.o -o assignment1 

 

CES236-7DXQJX2+Alex@CES236-7DXQJX2 ~/Assignment1 $ ./assignment1.exe 

Start lists: 

List 1: the black cat was sitting on the black mat that was on the black floor 

List 2: the dog scared the cat and the cat ran away 

 

Concatenating the two lists onto list '1': 

List 1: the black cat was sitting on the black mat that was on the black floor the dog scared the cat and the cat ran away 

List 2: the dog scared the cat and the cat ran away 

 

Removing the word 'was' from list '1': 

List 1: the black cat sitting on the black mat that on the black floor the dog scared the cat and the cat ran away 

List 2: the dog scared the cat and the cat ran away 

 

Removing the word 'away' from list '2': 

List 1: the black cat sitting on the black mat that on the black floor the dog scared the cat and the cat ran away 

List 2: the dog scared the cat and the cat ran 

 

Removing the word 'cat' from both lists: 

List 1: the black sitting on the black mat that on the black floor the dog scared the and the ran away 

List 2: the dog scared the and the ran 

 

Number of occurrences of 'black' in list 1: 3 

 

Sorting list 1: and away black black black dog floor mat on on ran scared sitting that the the the the the the  

The program has finished. 

 

CES236-7DXQJX2+Alex@CES236-7DXQJX2 ~/Assignment1 



 

 

 

 

 

Dan and Alex  v1.0 2020-08-20 v1.01 2020-09-08

More products