[Solved] CS2040C Assignment 1- Simple Linked List

$25

File Name: CS2040C_Assignment_1-_Simple_Linked_List.zip
File Size: 376.8 KB

SKU: [Solved] CS2040C Assignment 1- Simple Linked List Category: Tag:
5/5 - (1 vote)

A zip file of the solution files for MS Visual Studio (or .zip of XCode file for Mac users) is provided that contains

  • The Linked List class mentioned in lecture o h o SimpleLinkedList.cpp
  • A main file to use the Linked List:

o main.cpp

In this assignment, you should only modify ONLY ONE file, namely, LinkedList.cpp. Look into the main.cpp file. It contains the code:

int main()

{

List l;

l.insertHead(123);

l.insertHead(11);

l.insertHead(9);

l.insertHead(1);

l.insertHead(20);

for (int i = 0; i < 5; i++) { cout << The current list is: ;

l.print(); cout << Does 9 exist in the list? << (l.exist(9) ? Yes : No) << endl; l.removeHead();

}

return 0;

}

Five numbers are inserted into a linked list and it prints the list five times with one element (the head) is removed for each time. Here is the sample output for your program that it supposed to be:

At the same time, it checks if the number 9 is in the list by the function exist().

Tasks (Graded)

  1. Implement the print() member function of the class List such that it will print out all the list element(s) with cout
  2. Implement the exist(int n) member function of the class List such that it will return 1 if n is in the list, or 0 otherwise.
  3. Submit your code by pasting the two functions to coursemology. Remember to finalize your submission after you are done. But you can only finalize once, remember to do so only if you are done completely.

For more details in how to complete the assignment, please refer to the Power Point slides in the workbin in IVLE.

Extra Tasks (Not Graded)

If you are looking for extra challenges, you could try the followings by yourself.

Other Member Functions of class List

You can add and implement the following functions:

  • headItem() that will return the first item in the list if the list is not empty.
  • empty() that will return 1 if the list has nothing, and 0 otherwise.
  • tailItem() that will return the last item in the list if the list is not empty.
  • removeTail() that will removes the last item of the list if the list is not empty.

Create A Project of Your Own

You can try to create a MSVS solution or XCode project of your own. You can use the .h and .cpp files in this assignment, or some finished assignments from your previous courses. Additionally, you could try to divide your previous code into .h and .cpp files.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS2040C Assignment 1- Simple Linked List
$25