Question 110?pts

A dynamic stack has a ________ size, and is implemented as a(n) ________.

?
?
?

Question 210?pts

The following statement:

 

???? stack< int, vector<int> > iStack;

 

indicates:

?
?
?

Question 310?pts

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)

 

??????????????? 1?? myStack.push(0);

??????????????? 2?? myStack.push(1);

??????????????? 3?? myStack.push(2);

??????????????? 4?? myStack.pop(value);

??????????????? 5?? cout << value << endl;

Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable.

 

What will the statement in line 5 display?

?
?

?

Question 410?pts

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)

 

??????????????? 1?? myStack.push(0);

??????????????? 2?? myStack.push(1);

??????????????? 3?? myStack.push(2);

??????????????? 4?? myStack.pop(value);

??????????????? 5?? myStack.pop(value);

??????????????? 6?? myStack.pop(value);

??????????????? 7?? cout << value << endl;

Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable.

 

What will the statement in line 7 display?

?
?
?

Question 510?pts

 

) In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)

 

??????????????? 1?? myQueue.enqueue(0);

??????????????? 2?? myQueue.enqueue(1);

??????????????? 3?? myQueue.enqueue(2);

??????????????? 4?? myQueue.dequeue(value);

??????????????? 5?? cout << value << endl;

Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable.

What will the statement in line 5 display?

?
?
?

Question 610?pts

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)

 

??????????????? 1?? myQueue.enqueue(0);

??????????????? 2?? myQueue.enqueue(1);

??????????????? 3?? myQueue.enqueue(2);

??????????????? 4?? myQueue.dequeue(value);

??????????????? 5?? myQueue.enqueue(3);

??????????????? 6?? myQueue.dequeue(value);

??????????????? 7???cout << value << endl;

 

Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable.

 

What will the statement in line 7 display?

?
?
?

Question 710?pts

The advantage a linked list has over a vector is:

?
?
?
?

Question 810?pts

Find as many errors as you can in the way the code implements the linked list.

void NumberList::appendNode(double num)

{

ListNode *newNode, *nodePtr;

// Allocate a new node & store num

newNode = new listNode;

newNode–>value = num;

// If there are no nodes in the list

// make newNode the first node.

if (!head)

head = newNode;

else // Otherwise, insert newNode.

{

// Find the last node in the list.

while (nodePtr–>next)

nodePtr = nodePtr–>next;

// Insert newNode as the last node.

nodePtr–>next = newNode;

}

}

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?

0 words

?
?
?
?

Question 910?pts

Find as many errors as possible.

NumberList::~NumberList()

{

ListNode *nodePtr, *nextNode;

nodePtr = head;

while (nodePtr != nullptr)

{

nextNode = nodePtr–>next;

nodePtr–>next = nullptr;

nodePtr = nextNode;

}

}

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?

0 words

?
?
?
?

Question 1010?pts

Write code that defines an STL list container for holding float values

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?