Ask Computer Engineering Expert

Q1. Analysis of algorithms: For each expression in the leN column, give the best matching description from the right column.

______N3

______1 + 2 + 3 + 4 + 5 + : : : + N                                         A. 1/2N2.

______1/2N2 + 100NlgN                                                          B. O(N2).

______1/2N2                                                                          C. Both A and B.

______2 + 4 + 6 + 8 + 10 + : : : +N                                        D. Neither A nor B.

______N2

______1 + 2 + 4 + 8 + 16 + : : : + N

Q2. For each quantity in the left column, give the best matching description from the right column.

______Height of a weighted quick union data structure with Nitems.                                 A. lgN in the best case.

______Height of a binary heap with N keys.                                                                   B. lgN in the worst case.

______Height of a left-leaning red-black BST with Nkeys.                                                C. Both A and B.

______Maximum function-call stack size when (top-down) merge sorting N keys.               D. Neither A norB.

______Maximum function-call stack size when quick sorting Nkeys.

______Number of compares to binary search a sorted array of sizeN.

Q3. Consider the following code fragment.

int count = 0;

int N = a.length;

Arrays.sort(a);

for (int i = 0; i < N; i++) {

for (int j = i+1; j < N; j++) {

if (Arrays.binarySearch(a, a[i] + a[j])) count++;

}

}

Suppose that it takes 1.5 second when N = 3,500. Approximately how long will it take when N = 35,000? Select the best answer:

15 seconds         

30 seconds         

1.5 minute         

30 minutes         

1.5 hours            

4.5 hours

Q4. Ordered-array implementation of a set.

Suppose you implement the set data type using an ordered array. That is, you maintain the N keys in the set in ascending order in an array.

What is the order of growth of the worst-case running time of each of the operations below? Write down the best answer in the space provided using one of the following possibilities.

1              logN       sqrt(N) N             NlogN                   N2

function

description

performance

add(key)

add the key to the set

 

contains(key)

is the key in the set?

 

ceiling(key)

smallest key in the set >= key

 

 

rank(key)

nume of keys in set smaller than given key

 

select(i)

ith largest key in the set

 

min()

smallest key in the set

 

delete(key)

delete the given key from the set

 

iterator()

iterate over all N keys in order

 

Q5. Red-black trees

Consider the following left-leaning red-black tree. Add the key Z, then add the key P

1539_Figure.png

(a) Draw the resulting left-leaning red-black tree.

(b) How many left rotations, right rotations, and color flips are performed in total to insert the two keys?

______left rotation(s)                  ______right rotation(s)                                ______color flip(s)

Q6. Hashing

Suppose that the following keys are inserted in some order into an initially empty linear- probing hash table of size 7, using the following table of hash values:

key hash

key hash

A

3

B

1

C

4

D

1

E

5

F

2

G

5

Which of the following could be the contents of the linear-probing array?

I.

0

1

2

3

4

5

6

G

B

D

F

A

C

E

II.

0

1

2

3

4

5

6

B

G

D

F

A

C

E

III.

0

1

2

3

4

5

6

E

G

F

A

B

C

D

Select the best answer.

(a) I only.

(b) I and II only.

(c) I and III only.

(d) I, II and III.

(e) None.

Q7. Hard problem identification.

You are applying for a job at a new software technology company. Your interviewer asks you to identify the following tasks as easy (E) or impossible (I).

______ Build a balanced BST containing N keys using 8N compares (where the array of keys are given to you in ascending order).

______ Build a balanced BST containing N keys using 8N compares (where the array of keys are given to you in arbitrary order).

______ Build a binary heap containing N keys using 2N compares (where the array of keys are given to you in arbitrary order).

______Build a BST containing N keys that has height at most 1/2lgN.

______Design a priority queue that does insert and delete-max in lg lgN compares per operation, where N is the number of items in the data structure.

Q8. Minimum spanning trees

Consider the following edge-weighted graph with 9 vertices and 19 edges. Note that the edge weights are distinct integers between 1 and 19.

1468_Figure1.png

(a) Complete the sequence of edges in the MST in the order that Kruskal's algorithm includes them (by specifying their edge weights).

(b) Complete the sequence of edges in the MST in the order that Prim's algorithm includes them (by specifying their edge weights).

Q9. Discuss the dramatic effect that algorithm choice can have on performance by giving example algorithms with markedly different performance characteristics when used to solve the same problem. Describe any theoretical or empirical performance results regarding the problems/algorithms you discuss.

Q10. Is the Partition problem in P or NP? Provide an argument that demonstrates your answer.

Q11. Define Big-O, Big-Theta, and Big-Omega. Describe the differences among them. Define the ~ notation and describe the key differences between it and the other three formalisms.

Q12. Define "loitering" Explain why it can matter. Give an example of code where loitering might occur and detail the changes necessary to prevent it.

Attachment:- Assignment.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92064925

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As