Is it true that any function which is O(log n) is also O(n)?
Is it true that searching an array is asymptotically faster than searching a liniked list?
You have a method foobar(X) that iterates over each element in a one-dimensional
array X. What is the time complexity of the following code?
String [ ][ ] str = new String[n][n];
for(int k = 0; k < n; k++)
What is the runtime complexity of the following method?
public Stack crazyStackMethod(int a)
Stack stack = new Stack();
for(int i = 0; i < a.length; i++)
for(int j = 0; j < a.length; j++)
Stack tempStack = new Stack();
stack = tempStack;
What is the best-case runtime complexity of searching an array?
What is the average-case runtime complexity of searching an array?
What does amortized cost mean?
What is the amortized cost of push() on a dynamic array-based Stack?
What is the worst-case cost of push() on a dynamic array-based Stack?
An alternative to a standard deletion strategy is known as lazy deletion.
When deleting elements from a singly linked list, we delete them logically but not physically.
This is done by marking the node as deleted (using a boolean value). The numbers of deleted
and not-deleted elements in the list are kept as part of the list. If at some point the
number of deleted elements is equal to the number of notdeleted
elements, we traverse the list actually deleting all of the "lazily deleted" elements. How does
this strategy improve runtime complexity of deletion?
Given a Stack class implemented using one FIFO Queue.
public class Stack
private Queue Q = new Queue();
public E pop()
int k = 1;
while( k++ < Q.size() )Q.enqueue(Q.dequeue());
public void push(E o)
If Q.enqueue(o) and Q.dequeue() takes O(1) time what is the worst-case runtime
complexities of push(o) and pop()?