Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Consider the following loop nest: int sum = 0; for(int j = 0; j < N * N; j += 2) for(int i = 2*N;

Consider the following loop nest:

int sum = 0; for(int j = 0; j < N * N; j += 2) for(int i = 2*N; i > 0; i--) sum++;

What is the Big-O behavior?

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

2.Consider the following loop nest:

int sum = 0; for(int j = 1; j < N; j *= 2) for(int i = 0; i < N; i += 2) sum++;

What is the Big-O behavior?

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

3.Consider the following loop nest:

int sum = 0; for(int j = 0; j < N; j++) for(int i = 2*N; i > 0; i--) sum++;

What is the Big-O behavior?

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

4.Which of the following step commands in Eclipse's debugger causes the code inside a method that is called to be skipped when examining the execution of a program?

Group of answer choices

step into

step over

step return

Fill in the blank: SimplePriorityQueue ___________ PriorityQueue.

Group of answer choices

is a

has a

is not related to

What should the Big-O behavior of the findMin method be?

public E findMin() throws NoSuchElementException;

/** * Retrieves, but does not remove, the minimum element in this priority * queue. * * @return the minimum element * @throws NoSuchElementException if the priority queue is empty */

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

What should the Big-O behavior of the deleteMin method be?

public E deleteMin() throws NoSuchElementException;

/** * Retrieves and removes the minimum element in this priority queue. * * @return the minimum element * @throws NoSuchElementException if the priority queue is empty */

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

Flag this Question

Recall that the insert method must maintain the descending, sorted order of the priority queue's backing array. Therefore, the method must first search for the correct location in which to place the new item, using a binary search. Then, the method must shift all array items at and beyond this location in order to make space for the new item.

What should the Big-O behavior of the binary search part of the insert method be?

public void insert(E item);

/** * Inserts the specified element into this priority queue. * * @param item - the element to insert */

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

What should the Big-O behavior of the array element shifting part of the insert method be?

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

Flag this Question

Question 101 pts

Combining the binary search and array shifting parts appropriately, what should the Big-O behavior of the entire insert method be?

Group of answer choices

O(1)

O(log N)

O(N)

O(N log N)

O(N2)

O(N3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions