Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume a list has the following element: Write a series of C++ statements using the List ADT of Figure 4.1 in eBook to delete

1. Assume a list has the following element:

image text in transcribed Write a series of C++ statements using the List ADT of Figure 4.1 in eBook to delete the element with value 15. 2. Using the list ADT of Figure 4.1, write a function to interchange the first two elements in the right partition of a list. Notes: To solve the assignment, you need to write two separated C++ programs to solve each question. In each program you need to copy the list implementation in Fig. 4.1 and add necessary statements/ function to solve the problem You need to submit each program with a picture of its output

Below is the figure 4.1

template class List { // List ADT private: void operator =(const List&) {} // Protect assignment List(const List&) {} // Protect copy constructor public: List() {} // Default constructor virtual List() {} // Base destructor // Reinitialize the list. The client is responsible for // reclaiming the storage used by the list elements. virtual void clear() = 0; // Insert an element at the front of the right partition. // Return true if the insert was successful, false otherwise. virtual bool insert(const Elem&) = 0; // Append an element at the end of the right partition. // Return true if the append was successful, false otherwise. virtual bool append(const Elem&) = 0; // Remove and return the first element of right partition. virtual Elem remove() = 0; // Place fence at list start, making left partition empty. virtual void movetoStart() = 0; // Place fence at list end, making right partition empty. virtual void movetoEnd() = 0; // Move fence one step left; no change if at beginning. virtual void prev() = 0; // Move fence one step right; no change if already at end. virtual void next() = 0; // Return length of left or right partition, respectively. virtual int leftLength() const = 0; virtual int rightLength() const = 0; // Set fence so that left partition has "pos" elements. virtual void movetoPos(int pos) = 0; // Return the first element of the right partition. virtual const Elem& getValue() const = 0; };

2,23,15,5,9

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: 3

blur-text-image

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

1. Practice giving the test before you actually use it.

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago