Share
Explore BrainMass

C++ Functions and Responses

C++. See attached file for full problem description.

Question 21
Refer to the figure above. Which of the following members in the UML diagram adds an element to the front of the queue?

front

addQueue

back

None of the above

Question 22

An effective way to implement a priority queue is to use a(n) ____ structure.

stack

array

varied

treelike

Question 23

//Program to test the queue operations
#include <iostream>
#include "linkedList.h"
#include "queueLinked.h"

using namespace std;

int main()
{
linkedQueueType<int> queue;
linkedQueueType<int> copyQueue;

int num;

cout<<"Queue Operations"<<endl;
cout<<"Enter numbers ending with -999"<<endl;
cin>>num;

while(num != -999)
{
queue.addQueue(num); //add an element to the queue
cin>>num;
}

copyQueue = queue; //copy the queue into copyQueue

cout<<"Queue contains: ";
while(!copyQueue.isEmptyQueue())
{
cout<<copyQueue.front()<<" ";
copyQueue.deleteQueue(); //remove an element from
//the queue
}

cout<<endl;

return 0;
}

Based on the figure above, if you wanted to print out the contents of copyQueue in reverse order, which statement would do the job?

cout<<copyQueue.front();

cout<<copyQueue.back();

cout<<copyQueue.remove();

cout<<copyQueue.addQueue();

Question 24

One way to implement a priority queue is to use an ordinary ____.

linked-list

array

stack

list

Question 25

FIFO closely resembles which of the following?

the order in which print jobs of the same priority are executed by a printer

the order in which customers are serviced in a bank

the order in which shoppers are serviced on line to pay for their items

All of the above

Question 26

Refer to the figure above. Which of the following members in the UML diagram keeps track of the number of elements in a queue at a given point in time?

maxQueueSize

isFullQueue

count

num

Question 27

The function destroyQueue does which of the following?

uses one queue to delete another

deletes all instances of the queue

copies the queue into backup memory

removes all elements from the queue leaving an empty queue

Question 28

In a queuing system the time it takes for the server to serve the customer is known as the ____ time.

initiation

transaction

response

wait

Question 29

//Program to test the queue operations
#include <iostream>
#include "linkedList.h"
#include "queueLinked.h"

using namespace std;

int main()
{
linkedQueueType<int> queue;
linkedQueueType<int> copyQueue;

int num;

cout<<"Queue Operations"<<endl;
cout<<"Enter numbers ending with -999"<<endl;
cin>>num;

while(num != -999)
{
queue.addQueue(num); //add an element to the queue
cin>>num;
}

copyQueue = queue; //copy the queue into copyQueue

cout<<"Queue contains: ";
while(!copyQueue.isEmptyQueue())
{
cout<<copyQueue.front()<<" ";
copyQueue.deleteQueue(); //remove an element from
//the queue
}

cout<<endl;

return 0;
}

Refer to the figure above. Assume you add the numbers 23, 76, 64 in this order. The output of the program will be which of the following?

Queue contains: 64 76 23

Queue contains: 23 76 64

Queue contains: 23 64 76

Queue contains: 76 64 23

Question 30

The function addQueue does which of the following?

adds all the contents from one queue to another

appends one queue to the back of another

adds a new element to the front of the queue

adds a new element to the rear of the queue

Attachments

Solution Summary

The expert examines C++ functions and responses. The members in the UML diagrams which add an element to the front of the queue is determined.

$2.19