Midterm Review CSDP 250

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

In stacks, elements are pushed at the _____________ and pop out elements from the _________________.

top; top

In a circular doubly linked list equation, if the modification is on the LHS your execution is at the ____

starting point

What is written to the screen for the input "carpets" in a stack

steprac

Here is an INCORRECT pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced:

( ( ( ) )

If data is a circular array of CAPACITY elements, and last is an index into that array, what is the formula for the index after last?

(last + 1) % CAPACITY

To implement stacks, we can use _______________ to store contents of stacks; while the way(s) to implement queues is/are ____________________.

both arrays and linked lists; linked lists

What are 6 concerns of data structure

empty, full, how to push, how to insert, delete, display

In a circular doubly linked list equation, if the modification is on the RHS your execution is at the ____

endpoint

Queues are ______ in and _______ out.

first; first

Stacks are _____ in and ______ out;

last; first

Given a sequence, we need to add or delete elements frequently. Which one you will choose, array or linked list?

linked list

The operation for removing an entry from a stack is traditionally called:

pop

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?

3

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). What is the maximum number of parentheses that will ever appear on the stack AT ONE TIME during the computation?

2

A queue has only ______ exit(s) for elements to be pushed in and popped out; A stack has ________ exit(s) for elements to push in and pop out.

2; 1

In a single linked list, each node contains _____elements, which are _______________.

2; data value, next pointer

Here is an infix expression: 4+3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. What is the maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

3

In a double linked list, each node contains _____ elements, which are _______________.

3; data value, next pointer, previous pointer

If the characters 'D', 'C', 'B', 'A' are placed in a stack (in that order), and then removed one at a time, in what order will they be removed?

ABCD

n the linked list implementation of the stack class, where does the push member function place the new entry on the linked list?

At the head

In the linked list implementation of the queue class, where does the push member function place the new entry on the linked list?

At the tail

Consider the implementation of the queue using a circular array. What goes wrong if we try to keep all the items at the front of a partially-filled array (so that data[0] is always the front).

B. The get_front function would require linear time.

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into an EMPTY queue?

Both change

Consider the implementation of the stack using a partially-filled array. What goes wrong if we try to store the top of the stack at location [0] and the bottom of the stack at the last used position of the array?

Both push and pop would require linear time.

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

DCBA

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into a NONEMPTY queue?

Only rear_ptr changes.

One difference between a queue and a stack is:

Queues use two ends of the structure; stacks use only one.

Entries in a stack are "ordered". What is the meaning of this statement?

There is a first entry, a second entry, and so on.

I have implemented the queue with a circular array, keeping track of first, last, and count (the number of items in the array). Suppose first is zero, and last is CAPACITY-1. What can you tell me about count?

count could be zero or CAPACITY, but no other values could occur.

Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through data[9]. The CAPACITY is 42. Where does the push member function place the new entry in the array?

data [10]

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array?

data[12]

Which of the following stack operations could result in stack underflow?

is_empty

A wasted memory is a

pointer

The operation for adding an entry to a stack is traditionally called:

push

How do you display stacks

void (!stack.empty)....cout << ' ' << mystack.top();....


Ensembles d'études connexes

module 3 part 2 correlation and experimental research

View Set

Chapter 12: Biliary Tract and Upper Gastrointestinal System

View Set

java programming chapter 4: ~advanced~ strings

View Set

Chapter 9: Sleep and Biological Rhythms

View Set

Chapter 9 - Teaching and Counseling

View Set

Chapter 30 Formation and Internal Relations of General Partnerships

View Set