Data Structures and Algorithms Test 2
to initialize or construct the queue, set: front to ____ back to _____ count to ______
0 MAX_QUEUE-1 0
how many external referenced are necessary when implementing a queue using a circularly linked list?
1
int[] array = {22,18,23,16,19,26,15,13}; sorted using selection sort. what would be the arrangement after the fourth pass through the array?
13 15 16 18 19 26 23 22
What is the value of the prefix expression: -*38+65
13`
A full binary tree with height 4 has _____ nodes
15
consider the following java array definition: int[] array = {22,18,23,16,19,26,15,13}; suppose this list was to be sorted with recursive mergeSort mehtod. How many times would the mergeSort method be invoked to successfully sort the given array?
15
int[] array = {22,13,23,15,19,16,26,18}; bubble sort algorithm how many comparisons would be made in order to arrange the data into ascending order if we use the basic version bubble sort algorith?
28
which of the following growth functions would represent the most inefficient algorithm for solving the problem?
2^n
given the following array: 4 15 8 3 28 21 for an ascending sort, which of the following represents the array after the second pass of the selection sort?
3 4 8 15 28 21
suppose that the following list: 469 681 532 94 353 760 was input to the radix sort algorithm. What would the arrangement of the list after the second pass of the algorithm?
532 353 760 479 681 94
which of the following is not a means of implementing a queue?
All of the following: linearly linked list, linear array, circularly linked list, circular array
which of the following is NOT an operation that can be performed on a stack?
Insert
in the best case, a sequential search is ___
O(1)
in the worst case, a binary search is_____
O(log2n)
worst case of binary search
O(log2n)
in an array-based implementation of a heap, the heapDelete operation is ______
O(logn)
the heapsort is ______ in the worst case
O(n*logn)
given the fact that a sort of n items requires n^2/2 +5 *n/2 - 3 major operations, the sort is
O(n^2)
the quicksort is _____ in the worst case.
O(n^2)
the value of which of the following frowth-rate functions grows the fastest
O(n^2)
which of the following is true of an array based stack implementation?
Requires an isFull method to check if the array is full
a merge sort is used to sort an array of 1000 values in ascending order. which of the following statements is true?
The sort is the same, no matter what the order of the original elements
A subtree of node n is a subtree rooted at___
a child of node n
stack
a data structure that only allows items to be inserted and removed at one end
which of the following is not a property of a complete binary tree of height h
all leaves are at level h
SatckInterface provides the specifications for
all the implementations of a stack
a n ode on the path from the root to (but not including) node n is a ______ of node n
ancestor
each node in a general tree has
at most one parent
each node in a binary tree has
at most two childer
in _______, the left and right subtrees of any node has heights that differ by at most 1
balanced binary tree
operations on a queue can be carried out at ___
both it's front and back
operations on a queue can be carried out at ________
both its front and back
another name for selection sort
brute-force algorithm
applications of stack
checking balanced expressions, recognizing palindromes, evaluation algebraic expressions
to sort a list of data items, the basic operation is
comparison
which of the following operations would you focus on in order to assess the efficiency of a sorting algorithm?
comparisons
A _______________ of height h is full down to the level h-1, with level h filled in from left to right
complete binary tree
a heap is a
complete binary tree
what should algorithm analysis be independent of?
data, specific implementation, computers
items from the front of the queue use an operation called ____
dequeue
bottom
end of stack where things are not removed or inserted
which of the following operations inserts the element at the end of the queue?
enqueue
According the following statements: -Algorithm A requires time propoertional to n^2 -Algorithm B requires time propertional to nlog2n Algorithm A's time requirements increase at a slower rate than algorithm B's time requirement
false
in a reference-based implementation of a stack, it is necessary to call the isFull() method before invoking the push method
false
stacks can be implemented only using arrays
false
the binary search algorithm is a quadratic algorithm
false
the efficiency of the selection sort depends on the initial arrangement of the data
false
the peek operation of the ADT stack changes the stack
false
the values of the growth-rate function O(log2n) grow faster than the values of the growth-rate function O(n).
false
when implementing a queue using a reference-based approach, the operation dequeueAll is not needed.
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
false
when implementing a queue, a naive approach is more efficient in terms of memory when compared to a circular array approach
false
when implementing a stack as a linked-list, you must make sure the stack isn't full before inserting an item
false
when the infix expressions are converted to postfix expressions, the operators always stay in the same order with respect to one another
false
when working on a stack, peek removes the value from the top of the stack
false
which of the following code fragments is used to delete the item at the front of the queue represented by a circular array?
front = front(+1) %MAX_QUEUE; --count;
in a _____ of height h, all nodes that are at a level less than h have two children each
full binary tree
the maximum number of comparisons for a retrieval operation in a binary search tree is the
height of the tree
In an array-based implementation of a heap, the parent of the node in items [i] is always stored in
item[(i-1)/2]`
which of the following would NOT be a good use of stack
keyboard buffer
deleting an item from a one-element referenced based queue is a special case: code is:
lastNode-null;
the minimum height of a binary tree of n nodes is
log2(n+1)
A heap in which the root contains the item with the largest search key is called a
maxheap
when assessing the efficiency of a factorial program, which of the following operations would you focus on?
multiplication
in the worst case, the insertion sort's comparison occurs how many times/
n*(n-1)/2
a bubble sort requires at most how many passes to sort an array of n items?
n-1
the maximum height of a binary tree of n nodes is
n/2
suppose that a selection sort of n items requires n^2/2+5*n/2-3 basic operations -- the selection sort is
n^2
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
newNode.setNext(newNode); lastNode=newNode;
Is access to other items in the stack allowed?
no
an algorithm's execution time is related to the number of ____ it requires
operations
def of postfix expressions
operator appears after its operands
def of prefix expressions
operator appears before its operands
def of infix expressions
operator appears between operands
method to retrieve from the stack the item that was added most recently, but does not remove
peek
the _____ method of the ADT stack removes the element at the top of the stack
pop
which of the following would result in an error?
popping an empty stack
the________ method of the ADT stack adds an item to the top of the stack
push
which of the following is not an ADT queue operation?
push
which of the following methods of the ADT stack accepts a parameter?
push
in a tree, the children of the same parent are called
siblings
top
the end of the stack where items are removed or inserted
which of the following is true of implementing a stack as a linked-list
the next reference for the bottom of the stack is null
in an array based representaiton of a complete binary tree (presuming subscripting beginning at 0), which of the following represents the parent of node tree[i]?
tree[(i-1)]
in an array based representation of a complete binary tree (presuming subscripting beginning at 0), which of the following represents the right child of noe tree[i]?
tree[2*i+2]
Stacks are last in first out (LIFO)
true
Stacks is a last-in, first-out data structure
true
a comparison of algorithms should focus on significant differences, not reductions in computing costs based on clever coding tricks
true
a queue can be used as a keyboard buffer
true
a reference-based stack makes more efficient use of memory
true
a stack is an instance
true
before dequeue, always determine if the queue is empty
true
if 5 items are added to a queue, the first item removed from the queue is the first item added to it
true
infix to postfix: operands always stay in the same order
true
low-order terms can be ignored in an algorithm's growth-rate function
true
prefix and postfix expressions don't need order of operations
true
queues are first-in, first-out data structures
true
stacks are used by compliers to implement recursion
true
a reference based implementation of a queue that uses a linear singly linked list would need at least ___ external references
two
worst case, avg case, and best case for sequential search
worst case: O(n) average case: O(n) best case: O(1)