JAVA 3
PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!!
Question 12 pts
Which is a valid constructor for Thread?
Thread ( Runnable r, int priority ); |
|
Thread ( Runnable r, String name ); |
Thread ( int priority ); |
|
Thread ( Runnable r, ThreadGroup g ); |
Flag this Question
Question 22 pts
What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds?
pause(). |
|
sleep(). |
hang(). |
|
kill(). |
Flag this Question
Question 32 pts
In order to modify the front entry of a queue
you need a set method defined. |
|
you need to dequeue the front entry, modify the contents, and then use the requeue method to place it back on the front of the queue. |
you cannot modify it under any circumstances. |
|
none of the above. |
Flag this Question
Question 42 pts
Which statement is true about the VectorStack class methods?
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 |
Flag this Question
Question 52 pts
When a counter enumerates simulated time units, it is called a(n):
clock simulation |
|
even-driven simulation |
time-driven simulation |
|
all of the above. |
Flag this Question
Question 62 pts
The rate of growth for the Towers of Hanoi problem as the number of disks increases is:
quadratic |
|
exponential |
linear |
|
constant |
Flag this Question
Question 72 pts
The method __________ can be used to determine the number of elements in an ArrayList.
length(). |
|
vectorLength(). |
size(). |
|
vectorSizes(). |
Flag this Question
Question 82 pts
In a vector implementation of a Stack ADT, you remove an entry from the top of a stack using which vector method?
pop |
|
retrieve |
remove |
|
none of the above. |
Flag this Question
Question 92 pts
To use Java's Vector class, yhou must import the ___________ package.
java.Math |
|
java.Exception. |
java.util. |
|
java.lang. |
Flag this Question
Question 102 pts
Using the evaluatePostfix algorithm, evaluate the following postfix expression.. w x + y * z /
Assume that w = 3, x = 4, y = 2, z = 7
28 |
|
18 |
21 |
|
2 |
Flag this Question
Question 112 pts
The number of levels in a tree is called the:
node count. |
|
branch level. |
height. |
|
size. |
Flag this Question
Question 122 pts
The idel situation in quick sort is when the pivot moves:
to the beginning of the array. |
|
to the end of the array. |
to the center of the array. |
|
to a random place in the array. |
Flag this Question
Question 132 pts
In a vector implementation of a Stack ADT, you clear all of the contents of a stack using which vector method?
delete |
|
deleteAll |
clear |
|
none of the above |
Flag this Question
Question 142 pts
The Java Class Library interface Queue method to put an entry on the back of a queue that returns false if the method fails is:
add. |
|
put. |
offer. |
|
poll. |
Flag this Question
Question 152 pts
A binary tree has at most two children called:
the left child. |
|
the right child. |
both a & b. |
|
none of the above. |
Flag this Question
Question 162 pts
A subtree of a node is a tree rooted at:
a child of that node. |
|
the root of the tree. |
a sibling of that node. |
|
the node itself. |
Flag this Question
Question 172 pts
When searching an array for the smallest value, which case is most useful?
the average case. |
|
the best case. |
the worst case. |
|
none of the above. |
Flag this Question
Question 182 pts
Computing the sum of the first n integers using the formulat n * (n+1)/2 has a growth rate
independent of n. |
|
of n * n |
of n*n + n |
|
all of the above |
Flag this Question
Question 192 pts
In quick sort, the partition step takes at most _________ comparisons for n items.
1 |
|
2n |
n2 |
|
n |
Flag this Question
Question 202 pts
In a vector implementation of a Stack ADT, you retrieve the top entry without removing it using which vector method?
peek |
|
look |
lastElement |
|
none of the above. |
Flag this Question
Question 212 pts
The primary interface/interfaces for a collection class is/are:
Collection<T>. |
|
Set<T>. |
List<T>. |
|
all of the above. |
Flag this Question
Question 222 pts
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:
poll. |
|
remove. |
retrieve. |
|
get. |
Flag this Question
Question 232 pts
In a vector implementation of a Stack ADT, you check for an empty stack using which vector method?
isEmpty |
|
empty |
stackEmpty |
|
none of the above |
Flag this Question
Question 242 pts
Which of the following are valid Thread states?
Dead, Sleeping, Pausing, New. |
|
Ready, Running, Dead, New. |
Ready, Sleeping, New, Restarting. |
|
Runnable, Sleeping, Napping, Dead. |
Flag this Question
Question 252 pts
The average-case performance of quick sort for n items is:
O(log n) |
|
O(n log n) |
O(n) |
|
O(n2) |
Flag this Question
Question 262 pts
Any node and its descendants form a ________ of the original tree.
subtree. |
|
nested. |
super tree. |
|
separate tree. |
Flag this Question
Question 272 pts
Which programming statements used to accomplish a threads task should be included in the method:
start(); |
|
init(). |
run(). |
|
none of the above. |
Flag this Question
Question 282 pts
In quick sort, having every partition form sub arrays of roughly the same size
is optimal. |
|
creates more work because of repeated comparisons |
slows the processing down. |
|
all of the above. |
Flag this Question
Question 292 pts
The best-case scenario for an selection sort is:
the elements are in reverse sorted order. |
|
the elements are in random order. |
there is no best-case scenario. |
|
the elements are already in sorted order. |
Flag this Question
Question 302 pts
When method X calls method Y, and method Y calls method X, this is called:
tail recursion |
|
associative recursion |
an error. |
|
mutual recursion. |
Flag this Question
Question 312 pts
During program execution, the ________________ references the current instruction.
program counter |
|
stack |
frame |
|
activation record |
Flag this Question
Question 322 pts
Given the following infix expression, which one of the following is the corresponding postfix expression?
( a + b ) * ( c - d ) / ( e + f )
a b c d e f + * - / + |
|
a b + c d - e f + * / |
a b + c d - * e f + / |
|
none of the above. |
Flag this Question
Question 332 pts
Which three are methods of the 'Object' class.
notify(), notifyAll(), and interrupt(). |
|
notify(), sleep(), and synchronized(). |
notify(), notifyAll(), wait ( long msecs ) |
|
wait(), isinterrupted(), and notify(). |
Flag this Question
Question 342 pts
The O(n2) analysis of insertion sort is a(n) _____________ analysis.
worst-case. |
|
best-case. |
average-case. |
|
unknown. |
Flag this Question
Question 352 pts
To properly evaluate the effectiveness of an algorithm, you need to determine
the average case. |
|
the best case. |
the worst case. |
|
all of the above |
Flag this Question
Question 362 pts
Using the evaluatePostfix algorithm, evaluate the following postfix expression. 7 2 + 4 *
36 |
|
13 |
15 |
|
18 |
Flag this Question
Question 372 pts
Using the evaluatePostfix algorithm, evaluate the following postfix expression. a b + c d - *
Assume that a = 5, b = 7, c = 6, and d = 2
39 |
|
48 |
55 |
|
none of the above. |
Flag this Question
Question 382 pts
All of the following are members of Java's Collection class except:
Queue<T>. |
|
LinkedList<T>. |
Vector<T>. |
|
Set<T>. |
Flag this Question
Question 392 pts
When the last action in a recursive method is a recursive call, it is called:
final recursion. |
|
delayed recursion. |
latent recursion |
|
tail recursion |
Flag this Question
Question 402 pts
What is the efficiency of the iterative selection sort method for a chain of n linked nodes?
O(n2) |
|
O(2n) |
O(n) |
|
O(log n) |
Flag this Question
Question 412 pts
The Java Class Library interface Queue method to put an entry on the back of a queue that throws an exception of the method fails is:
offer. |
|
put. |
add. |
|
poll. |
Flag this Question
Question 422 pts
The best-case performance for an array of n items using insertion sort is:
O(n2) |
|
O(n) |
O(1) |
|
n |
Flag this Question
Question 432 pts
The __________ node is the only node that has no parent.
child. |
|
binary. |
n-ary. |
|
root. |
Flag this Question
Question 442 pts
When searching an array for a particular value, which case is most useful?
the best case |
|
the worst case. |
the average case. |
|
none of the above. |
Flag this Question
Question 452 pts
When method X calls method Y, method Y calls Method Z, and method Z calls method X, this is called:
mutual recursion |
|
tail recursion |
indirect recursion |
|
an error. |
Flag this Question
Question 462 pts
The best-case scenario for an insertion sort is:
the elements are in reverse sorted order. |
|
the elements are in random order. |
the elements are already in sorted order. |
|
there is no best-case scenario. |
Flag this Question
Question 472 pts
If an algorithm requires 7 basic operations for an algorithm with a problem size of n, the algorithmic complexity is:
O(7). |
|
O(1), |
O(n). |
|
O(7n). |
Flag this Question
Question 482 pts
The efficiency for solving the Towers of Hanoi problem recursively is:
O(2n) |
|
O(n2) |
O(n) |
|
O(log n) |
Flag this Question
Question 492 pts
Duplicate entries are NOT ALLOWED in chich of the following interfaces?
Set. |
|
Collection. |
List. |
|
Map. |
Flag this Question
Question 502 pts
The best-case performance of quick sort for n items is:
O(n log n) |
|
O(log n) |
O(n) |
|
O(n2) |
PLEASE FOR ANSWERS ASAP!!!
JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...
JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The best-case performance for a shell sort is: --- O(1) O(n2) O(n) O(n log n) Signaler cette question Question 22 points The best-case performance for an array of n items using insertion sort is: --- O(n2) O(n) O(1) there is no best-case Signaler cette question Question 3 2 points A recursive method that processes a chain of linked nodes --- uses the first node in...
Can you please help with the below? 1) Which of the following is true about using a 2-3-4 tree? a. It is designed to minimize node visits while keeping to an O(log n) search performance b. It is designed to self-balance as new values are inserted into the tree c. As soon as a node becomes full, it performs the split routine d. None of the above 2) Which of the following is true about a binary search tree? a. ...
Let us suppose that there are n elements in the un-sorted array. Answer the following? q1: How is merge sort different from quick sort? q2: What is the split ratio in merge sort? q3: What is the worst-case/average-case/best-case running time of Merge Sort? q4: Why is the worst case running time of Merge sort O(n log n) always? q5: Why does Merge Sort use a static tree in the recursion process? (It is worth noting that the Quick Sort use...
(5 marks; questions to Reza) In Lecture 5, Travis said you can prove QuickSort takes N(n log n) time in the best case the same way he proved any comparison-based sorting algorithm takes (n log n) time in the worst case. Give that proof. Notice it doesn't follow directly: e.g., Insertion Sort takes O(n) time in the best case. You can assume QuickSort divides each array into elements less than or equal to the pivot (including the pivot itself) and...
Here is the recursion tree for the above: I need to know the formula that counts the nodes in that recursion tree. An example: the recursion tree for a selection sort with an array of 4 in the worst case scenario looks like this: That is the type of solution I am looking for. Please determine the formula to count the number of nodes in the recursion tree for the insertion sort with an array size of 5 (n=5) where...
hheeelppp copying and comparing QUESTION 24 How many comparisons does insertion sort make on an input array that is already sorted? O(1) O(n) o(na) O(log n) 4 QUESTION 25 A linear list of elements in which deletion can be done from one end and insertion can take place only at the othe Queue Stack Array Click Save and Submit to save and submit. Click Save All Answers to save all answers HUAWEI
how do I change my code to generic form *********************************************************************** public class UnboundedStackQueue { //question#3 } class Stack { Node head; int size; Stack() //default constructor { this.head=null; this.size=0; } //Input = data //Output = void (just adds value to list) // method pushes elements on stack // time: O(1) // space: O(1) public void push(int data) { Node node=new Node(data); node.next=head; head=node; size++; } //Input = none //Output = top of stack // method pops value from top of...
C++ Question 5 5 pts In a min-heap of N elements, if we want to find the max element, we have to search all the leaves. What is the big-o running time of findMax? O(N^2) Oſlog N) O(N) OIN log N) Question 6 5 pts An AVL tree is a Binary Search Tree that has the following additional property for every node in the tree, the height of the left and right subtrees is the same none of the above...
Which of the following terms is NOT associated with a stack? push top get bottom Flag this Question Question 21 pts Which of the following terms is NOT associated with a queue? add front FIFO enqueue pop Flag this Question Question 31 pts A stack exhibits what kind of behavior? Last In, First Out (LIFO) First In, First Out (FIFO) Last In, Last Out (LILO) Read-Only Write-Only Flag this Question Question 41 pts What are the final contents of myQueue...
Please answer this programming question as fast as possible. Will upvote 45 pts Question 2 Let BSTree be the following class which implements Binary Search Tree (BST). a. (5 points) Write the method public int maxElement 0 that returns the element of the tree with maximum value if the BST is not empty and returns -1 otherwise. b. (10 points) Write the method public void preOrderPrint 0 that prints out all the elements in the BST in the order of...