GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

What is the time complexity of this insert method in a Heap…

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 }

Read Details

What is the value of `parent` in the following code if j = 5…

What is the value of `parent` in the following code if j = 5? int parent = (j – 1) / 2;

Read Details

Which of the following best defines the Heap-Order Property…

Which of the following best defines the Heap-Order Property for a Min-Heap?

Read Details

public V put(K key, V value) { for (Entry e : list) { if (e….

public V put(K key, V value) { for (Entry e : list) { if (e.getKey().equals(key)) { V old = e.getValue(); e.setValue(value); return old; } } list.add(new Entry(key, value)); return null; } What is the worst-case time complexity of the put operation shown above for a map with n entries?

Read Details

Why is sorting data a critical prerequisite for algorithms l…

Why is sorting data a critical prerequisite for algorithms like Binary Search?

Read Details

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)

Read Details

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… }

Read Details

You are given the array: [ 5, 1, 4, 2, 8 ]. After two passes…

You are given the array: [ 5, 1, 4, 2, 8 ]. After two passes of the outer loop (i=1 and i=2) of an Insertion Sort, what will be the state of the array?

Read Details

Which sorting algorithm is conceptually described as “mimics…

Which sorting algorithm is conceptually described as “mimics how humans sort a hand of playing cards”?

Read Details

In all the sorting code snippets (Bubble, Insertion, Quick-S…

In all the sorting code snippets (Bubble, Insertion, Quick-Sort), we see the line: comp.compare(a, b) > 0. What is the purpose of using this comp object instead of just writing a > b?

Read Details

Posts pagination

Newer posts 1 … 38 39 40 41 42 … 82,377 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top