Introduction to algorithms

Assignment Help Basic Computer Science
Reference no: EM13849779

All problem / exercise numbers are from the 3nd edition of Introduction to Algorithms (the 1st and 2nd editions are different!) Note the difference between problems and exercises!

1. Special Cases of Select:

(a) Give an algorithm to find the second smallest element in a list of n elements in at most n + |lg n| - 2 comparisons. Note: Your algorithm can use no more than n + |lg n| - 2 total comparisons in the worst case. Hint: Find the smallest element, too.

(b) Give an algorithm to find the 3rd smallest element in a list, using the smallest number of worst-case comparisons. Exactly how many comparisons does your algorithm take in the worst case? Hint: Use your solution to part a - you will need to find the smallest and second-smallest element as well!

2. Exercise 9.3-6 quantiles

The kth quantiles of an n-element set ar the k -1 order statistics that divide the sorted set into k equal-sized sets (to within 1). Give an O(n lg k)-time algorithm to list the k-th quantiles of a set. Elements within each quantitle can be listed in any order.

3. Exercise 9.3-8 Finding the median of two lists of numbers

Let X[1 . . . n] and Y [1 . . . n] be two arrays, each containing n elemetns already in sorted order. Give an O(lg n)-time algorithm to find the median of all 2n elements in arrays X and Y .

4. Does inserting and then immmediately deleting a unique element from a Binary Search Tree always leave the same tree? Does inserting and then immediatley deleting a unique element from a Red/Black tree always leave the same tree?

5. Exercise 14.3-6 (MIN-GAP) Show how to extend a red-black tree to support the operation MIN-GAP, which gives the magnitude of the difference of the two closest numbers in the tree. For example, if Q = {1, 5, 9, 15, 18, 22} then MIN-GAP(Q) returns 18-15 = 3 since 15 and 18 are the two closest numbers in Q.

Reference no: EM13849779

Questions Cloud

Limitations prevent the forecasts from being foolproof : Give examples of how ratios gleaned from the financial statements can be used as a tool in helping a firm plan for the future. What do these ratios tell an individual analyzing them? What limitations prevent the forecasts from being foolproof?
Presentation on reward is better than punish : Explanation Presentation- Topic: Reward is better than punish when training animals. Students will explain a complicated subject related to the course theme in 4 minutes to a classmate. The listener will be randomly assigned on the day of the prese..
What is the size of the last payment : Land is purchased for 75000. It is agreed for the land to be paid for over a 5 year period with compounding annual interest at 12%. Each payment is 3000 more than the previous. What is the size of the last payment?
What factors impact sourcing decisions : What factors impact sourcing decisions? The custom duties can be paid after the product has been acquired by the customer. True or False
Introduction to algorithms : All problem / exercise numbers are from the 3nd edition of Introduction to Algorithms (the 1st and 2nd editions are different!) Note the difference between problems and exercises!
Explain the various definitions of disability : Explain the various definitions of disability that are found in disability-income insurance. Explain the following disability insurance income provisions
What would you recommend smith do to help the situation : Evelyn Smith, the new president of Texas Wings Inc., had been recruited to the company in 2004 by a disgruntled investor who had lost faith in the business's management team and profitability prospects. What would you recommend Smith do to help the..
Complete a chart with recommended coverage : What should the Parkers consider when deciding what insurance coverage they need. Do they have sufficient insurance coverage. If not, what type of insurance coverage do you recommend for them
Explain how much total tax does he pay on the stock sale : How much principal must be invested today for 5 years. during a period when the inflation rate is 2%, if the investor is in the 25% Federal and 4% State tax bracket for ordinary income but taxed at a 15% Federal rate for dividend income, to accumu..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Describe the graphical coordinate system in java

Describe the graphical coordinate system in Java. Where is the origin? What units apply to the x,y coordinates?

  Describe what fraud is and how it could be conducted

Describe what fraud is and how it could be conducted.

  Write a program that generates 5 random numbers

write a program that generates 5 RANDOM numbers between 60 and 100 and calculates the smallest of the five numbers import java.util.Random; public class RandomNumbers

  Prepare a paper on supercomputing

Consider any of the supercomputing examples we discussed in class, and find a scientific paper describing it. you must find an article in a valid IEEE or ACM publication (journal, conference, etc.)

  Creating presentation to law school class on digital crime

You have been asked to present a presentation to law school class on digital crime. After presentation, a student asks why so few people are really prosecuted for computer crime.

  Start by identifying all the hazards and potential causes

Start by identifying all the hazards and potential causes of harm to the IT infrastructure and functionality (for example, what are you going to do if the VIU main web site goes down, or what happens if viruses get into VIU computer systems, or..

  Ray henry is considering expanding the activities

1. Ray Henry is considering expanding the activities at his book stores to include movies. He has some ideas for how he wants to do this and he needs you to help with database design activities to address these ideas. In particular, he would l..

  What is the purpose of the finally block

How does a method declare that it can throw an exception? How does it actually throw an exception? Use Java code to illustrate your answer.

  Make report to print gross earnings and tax payable

Your report is to print the gross earnings, tax payable, medical levy and net earnings for each employee. At the end of the report, print the total gross earnings, total tax, total medical levy and total net earnings.

  Complete set of logic gates

Do 2-input AND gates which have one input inverted form a complete set of logic gates? Rationalize your answer.

  Timberline technology manufactures membrane circuits

Timberline Technology manufactures membrane circuits in its Northern California plant

  Customer from the first part of this discussion

Suppose that you learn that the customer from the first part of this discussion is unsure as to whether the database is going to run only during normal business hours or whether it needs to run 24 hours / 7 days a week. Assess the importance of kn..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd