Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programing Help needed - Visual Studio is the IDE. ( Follow the Instructions Properly) Node.h, LinkedList.h, LLDriver.cpp Program description: You will implement and test

C++ Programing Help needed - Visual Studio is the IDE. ( Follow the Instructions Properly)

Node.h, LinkedList.h, LLDriver.cpp

Program description:

You will implement and test an ORDERED linked list class that uses nodes to store items.

Add a second header file to the project named LinkedList.h. Place the standard #ifndef statement (and the associated #define and #endif) in the file.

This file will contain the definition of the templated class "LinkedList"

The LinkedList Class will have just one data member that is a pointer to the first node in the list. You may not add any other member variables

The Node class should have two member variables ( a data and a pointer ). You may not add any other member variables

Node.h (struct)

Default Constructor

Data should be set to 0 and pointer should be set to nullptr

Overloaded Constructor

Set private data members to be the parameters

LinkedList.h

Constructor

Initializes all private data members

Destructor

Deletes all dynamically allocated memory to prevent memory leaks

Insert

Takes a single argument representing the value to be inserted into the list. The item is inserted into the list in the correct order. Returns a bool (success) to indicate if the insertion was successful.

remove

Takes an argument (by reference) which holds the key of the item to be removed from the list. This item will hold the record (data) that has been deleted upon completion. Only the first occurrence of the value should be removed. This function should return a bool (success).

retrieve

Takes an argument (by reference) which holds the key of the item to be retrieved from the list. That same argument will be used to hold the data once it has been found (think about the retrieve function we did last week. Return a bool (success). This is an accessor function

viewFront

Takes an argument (by reference) that will be used to hold the data found in the first Node of the list. Return a bool (success). This is an accessor function

viewBack

Takes an argument (by reference) that will be used to hold the data found in the last Node of the list. Return a bool (success). This is an accessor function

isEmpty

Returns a bool to indicate if the list is empty. This is an accessor function

isFull

Returns a bool to indicate if the list is full. This is an accessor function

clearList

Removes all elements in the linked list. Returns a false value if the list is empty

display

Displays all values currently stored in the list, only in a display functin you can use standard output (cout). This is an accessor function. Return false if no value in the list

getSize

Count and returns the current size of the list. This is an accessor function

Requirements:

1. Declare your LinkedList object like this:

LinkedList ll; // you can use different data types

2. Sample call to the member functions, please dont ignore the returned Boolean value!:

val = 1;

if (ll.insert(val) == false)

{

// or you can say if (!ll.insert(val))

cout << "insert didn't work" << endl;

// you can use a more meaningful message

}

Note: use (nothrow) in the constructor. for example: template

bool LinkedList : : LinkedList(int c)

{ ......etc etc ;

numValues = 0;

list = new (no throw)Type[ etc etc ] ;

}

Sample output:

1 1 1 2 3 4 5 6

After inserting 3: 1 1 1 2 3 3 4 5 6 7

After removing 4: 1 1 1 2 3 3 5 6 7

front value is: 1

last value is: 7

Not Empty

Not full

Currently has 9 nodes

attempting to retrieve 10

not found

attempting to retrieve 3

found 3

after calling clearlist 0 elements remaining

press any key to continnue . . .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago