• Nem Talált Eredményt

People usually write check in order by check number, and merchants usually cash them with reasonable dis- patch

N/A
N/A
Protected

Academic year: 2022

Ossza meg "People usually write check in order by check number, and merchants usually cash them with reasonable dis- patch"

Copied!
1
0
0

Teljes szövegt

(1)

Theory of Algorithms Final January 18, 2007

Write your name and a code of at least 5 characters, in print, onto each sheet you turn in.

The code will be used to put up the results on the web page

http://www.cs.bme.hu/~pbiro/thalg.html preserving your privacy.

1. Are the following statements true? Explain why or why not in each case.

(a) 2n+1 =O(2n) (b) 22n=O(2n)

2. Banks often record transactions on an account in order of the times of the transactions, but many people like to receive their bank statements with checks listed in order by check number. People usually write check in order by check number, and merchants usually cash them with reasonable dis- patch. The problem of converting time-of-transactions ordering to check-number ordering is therefore the problem of sorting almost-sorted input. Argue that the procedure INSERTION-SORT would tend beat the procedure QUICKSORT on this problem.

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

4. We have given an unsorted array of size n. Can we build a binary search tree from its elements in O(n) time? Explain how or why not.

5. Consider inserting the keys 6, 12, 8, 22, 37, 10 into a hash table of lenghtm = 7 using open addressing with the primary hash function h0(k) =k modm. Illustrate the result of inserting these keys using linear probing, and using quadratic probing with c1 = 3 andc2 = 1.

6. Describe a red-black tree on n keys that realizes the largest possible ratio of red internal nodes.

What is this ratio? What tree has the smallest possible ratio, and what is the ratio?

7. In our computer we work with n different types of picture-files, and we have r programs, each of them can transform one type to another one (for example, the program pi,j can transform a file with type ti to an other file with typetj). From the typeti thedistance of typetj is the minimum number of transformations that is needed to convert a file with type ti to a file with type tj. (Note, that if we have a program pi,j, then the distance from ti to tj is 1.) We would like to store our pictures using one single type t, in such a way that the maximum distance fromt to any other type should be minimal. Give an O(n(n+r))-time algorithm that finds one of these best types.

Each problem is worth 10 points, you need 28 points at least to pass. Your point total in the final exam counts for 70% of your final grade.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

Abstract— Discrete time growth optimal investment in stock markets with proportional transactions costs is consid- ered.. The market process is modeled by a first order

– transaction costs of credit-card, check, and cash based payments may be higher than the value of the transaction. – need solutions optimized for very low value transactions (perhaps

an open vessel, in order to eliminate the possible error due to the vapour pres- sure of the system itself, but the so obtained results were identical with those gained by the

d) finally, to check experimentally outcomes of the mathematical model on real huildings by constructing the physical-mathematical model of the given building, and

In order to cost-efficiently decrease the loads of a wide range of contaminants that are usually present in road runoff (posing a long-term threat to the aquatic and

2 A social and economic background to the political involvement of impaired people in Békés County In order to understand the nature of political actions launched in reaction to

Complex Event Processing deals with the detection of complex events based on rules and patterns defined by domain experts.. Many complex events require real-time detection in order

After installing the hardware, the students may try to check the output waveform of the sensor using an oscilloscope by touching AIN7 (see Fig.2.) with the