Algorithms Test 2 Exam
Questions with Answers
stack - Correct Answers: a data structure that only allows items to be inserted and removed at one end
top - Correct Answers: the end of the stack where items are removed or inserted
bottom - Correct Answers: end of stack where things are not removed or inserted
Is access to other items in the stack allowed? - Correct Answers: no
Stacks are last in first out (LIFO) - Correct Answers: true
which of the following is NOT an operation that can be performed on a stack? - Correct Answers: Insert
when working on a stack, peek removes the value from the top of the stack - Correct Answers: false
Stacks is a last-in, first-out data structure - Correct Answers: true
stacks are used by compliers to implement recursion - Correct Answers: true
stacks can be implemented only using arrays - Correct Answers: false
which of the following would result in an error? - Correct Answers: popping an empty stack
when implementing a stack as a linked-list, you must make sure the stack isn't full before inserting an
item - Correct Answers: false
,which of the following would NOT be a good use of stack - Correct Answers: keyboard buffer
which of the following is true of implementing a stack as a linked-list - Correct Answers: the next
reference for the bottom of the stack is null
which of the following is true of an array based stack implementation? - Correct Answers: Requires an
isFull method to check if the array is full
a reference-based stack makes more efficient use of memory - Correct Answers: true
queues are first-in, first-out data structures - Correct Answers: true
if 5 items are added to a queue, the first item removed from the queue is the first item added to it -
Correct Answers: true
operations on a queue can be carried out at ___ - Correct Answers: both it's front and back
a reference based implementation of a queue that uses a linear singly linked list would need at least ___
external references - Correct Answers: two
which of the following is the code to insert a new node, referenced by newNode, into an empty queue
represented by a circularly linked lise - Correct Answers: newNode.setNext(newNode);
lastNode=newNode;
which of the following code fragments is used to delete the item at the front of the queue represented
by a circular array? - Correct Answers: front = front(+1) %MAX_QUEUE;
--count;
which of the following operations inserts the element at the end of the queue? - Correct Answers:
enqueue
, which of the following is not an ADT queue operation? - Correct Answers: push
when implementing a queue using a reference-based approach, the operation dequeueAll is not
needed. - Correct Answers: false
when implementing a queue using an array-based approach, it is not necessary to determine if the
queue is full before adding a new item to the queue - Correct Answers: false
a queue can be used as a keyboard buffer - Correct Answers: true
which of the following is not a means of implementing a queue? - Correct Answers: All of the following:
linearly linked list, linear array, circularly linked list, circular array
how many external referenced are necessary when implementing a queue using a circularly linked list? -
Correct Answers: 1
when implementing a queue, a naive approach is more efficient in terms of memory when compared to
a circular array approach - Correct Answers: false
what should algorithm analysis be independent of? - Correct Answers: data, specific implementation,
computers
a comparison of algorithms should focus on significant differences, not reductions in computing costs
based on clever coding tricks - Correct Answers: true
when assessing the efficiency of a factorial program, which of the following operations would you focus
on? - Correct Answers: multiplication
which of the following operations would you focus on in order to assess the efficiency of a sorting
algorithm? - Correct Answers: comparisons