What is the time complexity of this insert method in a Heap Priority Queue? public void insert(E key) { heap.add(key); // Step 1 upheap(heap.size() – 1); // Step 2 }
Blog
What is the auxiliary bspace/b complexity of the standard Me…
What is the auxiliary bspace/b complexity of the standard Merge-Sort algorithm, and why?
Why is sorting data a critical prerequisite for algorithms l…
Why is sorting data a critical prerequisite for algorithms like Binary Search?
What is the worst-case time complexity for a search operatio…
What is the worst-case time complexity for a search operation in a Hash Table (assuming all keys collide)?
Which of the following best defines the Heap-Order Property…
Which of the following best defines the Heap-Order Property for a Min-Heap?
Consider the following snippet from an UnsortedListPQ implem…
Consider the following snippet from an UnsortedListPQ implementation. What is its time complexity? int minIndex = 0; for (int i=1; i < data.size(); i++) { if (data.get(i).compareTo(data.get(minIndex)) < 0) { minIndex = i; } } return data.remove(minIndex);
According to the lecture slides, what is the time complexity…
According to the lecture slides, what is the time complexity of removeMin for the Sorted List implementation (assuming efficient removal from the front)?
The “Combine” phase (or “merge” step) of Merge-Sort, which c…
The “Combine” phase (or “merge” step) of Merge-Sort, which combines two already sorted lists (S1 and S2) into one final sorted list (S), runs in ______ time. (Use Big-O notation, e.g., O(n)).
What does the following upheap condition check for? while (…
What does the following upheap condition check for? while (j > 0) { int parent = (j – 1) / 2; if (heap.get(j).compareTo(heap.get(parent)) >= 0) break; // swap logic… }
Which of the following sorting algorithms have an average-ca…
Which of the following sorting algorithms have an average-case time complexity of O(n log n)? (Select all that apply)