Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to use concatenate for linked lists with this format? this is what i have QueueT QueueT::concatenate(QueueT& qu, int n)const{ QueueT result = front; QueueT

How to use concatenate for linked lists with this format?

image text in transcribed

this is what i have

QueueT QueueT::concatenate(QueueT& qu, int n)const{

QueueT result = front;

QueueT re = qu;

int stop = 0;

//while it is not empty, we want to for the size n, iterate and insert the first n values

if(n > re.size()){

throw std::runtime_error("n is greater than size of param");

}

while(stop != n){

result.enqueue(re.front->data);

re.dequeue();

stop++;

}

return result;

}

and my test program calls it like this, q1.concatenate(q4, 1); but i do not know how to reach both linked lists

concatenate - has two parameters, a QueueT reference and an integer (referred to as n in this description) adds the first n values stored in its Queuet parameter to the end of the calling object, the resulting queue therefore contains its original contents - order unchanged - followed by the first n values of the parameter queue in their original order; the values added to the calling object should be removed from the parameter; both queue's sizes should be adjusted as appropriate; if n is greater than the size of the parameter a runtime_error should be thrown and no changes made to either queue

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

=+(3.14) Q((HOA) U (HenB)) = P(HOA) +P (H'nB) for A, B E 70.

Answered: 1 week ago

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago