Question 1 (0.24 points) A language-independent specification for a group of val
ID: 3726147 • Letter: Q
Question
Question 1 (0.24 points)
A language-independent specification for a group of values and operations on those values is called a/a:
Question 1 options:
abstract data type
data structure
collection
primitive
Save
Question 2 (0.24 points)
Which method removes one occurrence of a particular entry from a bag if possible?
Question 2 options:
clear
remove
delete
empty
Save
Question 3 (0.24 points)
Which behavior(s) change the contents of a bag?
Question 3 options:
getFrequency
contains
toArray
add
Save
Question 4 (0.24 points)
Sets that adhere to the standard interface in the Java Class library
Question 4 options:
do not contain a pair of objects x and y such that x.equals(y) is true
are completely compatible with the bag interface
allow duplicate entries
order the objects contained in the set
Save
Question 5 (0.24 points)
Which of the following methods is a good candidate for a core method:
Question 5 options:
add
clear
contains
remove
Save
Question 6 (0.24 points)
An incomplete definition of a method is called a _____.
Question 6 options:
core method
fail-safe method
stub
security problem
Save
Question 7 (0.24 points)
The most efficient approach to dealing with a gap left in an array after removing an entry from a bag is to
Question 7 options:
replace the entry being removed with null
shift subsequent entries and replace the duplicate reference to the last entry with null
replace the entry being removed with the first entry in the array and replace the first entry with null
replace the entry being removed with the last entry in the array and replace the last entry with null
Save
Question 8 (0.24 points)
Which of the following is a disadvantage of using an array to implement the ADT bag?
Question 8 options:
increasing the size of the array requires time to copy its entries
adding an entry to a bag is fast
removing an unspecified entry from the array is fast
all of the above
Save
Question 9 (0.24 points)
What is an advantage of using a chain for a Bag ADT?
Question 9 options:
It has a fixed size which is easier to manage.
It avoids moving data when adding or removing bag entries.
It can be resized to provide as much space as needed.
All of the above.
Save
Question 10 (0.24 points)
In the LinkedBag implementation, the numberOfEntries field
Question 10 options:
records the number of entries in the current bag
records the number of nodes in the chain
is set to zero in a new chain
all of the above
Save
Question 11 (0.24 points)
Given the following chain, what does the resultant chain look like after adding the node with an entry “U” in it?
“J”, “X”, “F”, “K”, “L”, null
Question 11 options:
“J”, “X”, “F”, “K”, “L”, “U”, null
“U”, “J”, “X”, “F”, “K”, “L”, null
you cannot determine where the entry will go in a bag chain implementation
none of the above
Save
Question 12 (0.24 points)
The clear method
Question 12 options:
traverses the chain and deallocating each node until it reaches the end
returns true if it succeeds
sets the firstNode to null
all of the above
Save
Question 13 (0.24 points)
When you write a program for an algorithm and it is taking much longer than expected you should
Question 13 options:
buy a faster computer
try to design a better algorithm
rewrite the algorithm in a different language
ignore the problem
Save
Question 14 (0.24 points)
To measure the time requirement of an algorithm, we must
Question 14 options:
run the algorithm for different problem sizes
code the algorithm in several different languages and compare the run times
find an appropriate growth rate function
all of the above
Save
Question 15 (0.24 points)
If an algorithm requires 7 basic operations for an algorithm with a problem size of n, the algorithmic complexity is
Question 15 options:
O(1)
O(7)
O(n)
O(7n)
Save
Question 16 (0.24 points)
What is the best-case time complexity for searching a linked-based bag ADT for a particular entry?
Question 16 options:
O(n)
O(n2)
negligible
O(1)
Save
Question 17 (0.24 points)
When you add an item to a stack, you place it
Question 17 options:
on the bottom
on the top
in the middle
it doesn’t matter where
Save
Question 18 (0.24 points)
The precedence of an operator in a postfix expression
Question 18 options:
is implied by the order in which the operators and operands occur
is always left to right
is always right to left
depends on the compiler implementation
Save
Question 19 (0.24 points)
During program execution, the _____ references the current instruction.
Question 19 options:
stack
frame
activation record
program counter
Save
Question 20 (0.24 points)
What is the entry returned by the peek method after the following stack operations.
push(A), push(R), pop(), push(D), pop(), push(L), pop(), push(J), push(S), pop(), pop()
Question 20 options:
S
A
L
D
Save
Question 21 (0.24 points)
The Stack ADT may be implemented with
Question 21 options:
a linked-chain
an array
a vector
all of the above
Save
Question 22 (0.24 points)
In an array-based chain implementation of a Stack ADT, what is the performance of the ensureCapacitymethod when the array is not full?
Question 22 options:
O(1)
O(n)
O(n log n)
O(n2)
Save
Question 23 (0.24 points)
Which statement is true about the VectorStack class methods?
Question 23 options:
they invoke the methods of the Vector class
they require slightly more execution time than the ArrayStack methods
both a & b
none of the above
Save
Question 24 (0.24 points)
A method that calls itself is called a
Question 24 options:
base method
iterative method
recursive method
dynamic method
Save
Question 25 (0.24 points)
What question should you keep in mind when debugging a recursive method?
Question 25 options:
Should a for-loop be included in the method?
If the method returns a value, does each of the cases return a value?
Are the activation records correct?
All of the above.
Save
Question 26 (0.24 points)
When method X calls method Y, and method Y calls method X, this is called
Question 26 options:
mutual recursion
tail recursion
associative recursion
an error
Save
Question 27 (0.24 points)
Arranging items into ascending or descending order is called
Question 27 options:
organizing
arranging
sorting
linking
Save
Question 28 (0.24 points)
The selection sort requires _____ swaps for an array of n items.
Question 28 options:
O(n2)
O(n)
O(2n)
O(n log n)
Save
Question 29 (0.24 points)
The best-case performance for an array of n items using insertion sort is
Question 29 options:
O(n)
O(n2)
O(1)
there is no best-case
Save
Question 30 (0.24 points)
Which sorting method divides an array into halves, sorts them and merges them back into one sorted array?
Question 30 options:
quick sort
radix sort
merge sort
insertion sort
Save
Question 31 (0.24 points)
The class Arrays in the package java.util has several static methods to sort arrays of Objects into ascending order. Which sort is used?
Question 31 options:
quick sort
merge sort
shell sort
insertion sort
Save
Question 32 (0.24 points)
The average-case performance of quick sort for n items is
Question 32 options:
O(log n)
O(n)
O(n2)
O(n log n)
Save
Question 33 (0.24 points)
Radix sort
Question 33 options:
partitions the array
merges the array back into place
distributes digits into buckets
all of the above
Save
Question 34 (0.24 points)
Which of the following real-world events could be simulated using a queue?
Question 34 options:
bank line
a shared network printer
restaurant reservation list
all of the above
Save
Question 35 (0.24 points)
A common alias for the queue method enqueue is
Question 35 options:
put
add
insert
all of the above
Save
Question 36 (0.24 points)
The Java Class Library interface Queue method that retrieves and removes the entry at the front of a queue and throws a NoSuchElementException if the queue was empty is
Question 36 options:
poll
retrieve
remove
get
Save
Question 37 (0.24 points)
The _____ ADT that has operations to add, remove, or retrieve entries at both the front and back of a queue is called a
Question 37 options:
deque
reversible queue
reversible stack
all of the above
Save
Question 38 (0.24 points)
If we use a chain of linked nodes with only a head reference to implement a queue which statement is true?
Question 38 options:
You must traverse the entire chain to access the last node.
Accessing the last node is very inefficient.
Both a & b
none of the above
Save
Question 39 (0.24 points)
In an array-based implementation of a queue, a possible solution to dealing with the full condition is to
Question 39 options:
maintain a count of queue items
check for frontIndex equal to backIndex
wait for an arrayFullExcetion to be thrown
all of the above
Save
Question 40 (0.24 points)
In a circular linked chain, when a node is removed from the queue
Question 40 options:
it is moved to a separate list
it is ignored
it is deallocated
none of the above
Save
Question 41 (0.24 points)
When a linked chain contain nodes that reference both the next node and the previous node, it is called a(n)
Question 41 options:
ordinary chain
multi-linked chain
two-way linked chain
doubly linked chain
Save
Question 42 (0.24 points)
In the ADT list, new entries are typically added
Question 42 options:
at the beginning of the list
at the end of the list
at a computed place in the list depending on the number of elements
none of the above
Save
Question 43 (0.24 points)
In the interface ListInterface, the method
public void add(int newPosition, T newEntry);
Question 43 options:
adds a new entry at the specified position in the list
increases the list size by 1
moves entries originally at or above the specified position one position higher
all of the above
Save
Question 44 (0.24 points)
A new entry is added to an array-based implementation of the ADT list
Question 44 options:
immediately after the last occupied position
immediately before the first occupied position
in the last array position
in the location returned by the new operator
Save
Question 45 (0.24 points)
In an array-based implementation of the ADT list, what is the performance of adding an entry at the end of the list if you amortize the cost of resizing the array over all additions to the list?
Question 45 options:
O(log n)
O(1)
O(n)
O(n2)
Save
Question 46 (0.24 points)
In an array-based implementation of the ADT list, what is the best case performance of the replace method?
Question 46 options:
O(log n)
O(n)
O(1)
O(n2)
Save
Question 47 (0.24 points)
A linked implementation of a list
Question 47 options:
uses memory only as need for new entries
returns unneeded memory to the system when an entry is removed
avoids moving data when adding or removing entries
all of the above
Save
Question 48 (0.24 points)
Moving through a linked implementation of a list from one node to another is called
Question 48 options:
traversing
walking
hopping
none of the above
Save
Question 49 (0.24 points)
In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if
Question 49 options:
the list is empty
the list only contains one entry
the list is full
all of the above
Save
Question 50 (0.24 points)
In a linked-based implementation of the ADT list with a tail reference, which method has a time efficiency of O(1)?
Question 50 options:
adding an entry to the end of the list
adding an entry to the beginning of the list
clear
all of the above
Save
abstract data type
data structure
collection
primitive
Explanation / Answer
If you post more than 1 question, as per chegg guidelines i have to solve oly 1 question.
Ques 2. Answer : (b) remove
clear empties the bag. So, it removes all the elements.
empty empties the bsag.
Ques 3. (d) add
add function adds a new element to the bag, so the bag is changed.