1. Registered User
Join Date
Nov 2011
Posts
2

## Need for Algorithm

Hello everyone,
i have an assignment and i would really appreciate it if any of you could help me.

The assignment is:
"You have a relation EMPLOYEES (clustered) sized B(R)>M,where M being the memory of your system.The EMPLOYEES has one attribute salary and you want to calculate the median of the salary of the employees in this relation:

SELECT MEDIAN(Employees.salary)FROM Employees.

Describe a sufficient algorithm (not SQL/code) that calculates questions as the above.
What is the cost of your algorithm"

I'd be very thankful if someone could help.
Last edited by ugabuga; 11-20-11 at 18:16.

2. Resident Curmudgeon
Join Date
Feb 2004
Location
In front of the computer
Posts
15,579
What sort of help would you like? It would be a lot easier to help you if you could ask us a specific question about your assignment instead of just posting the assignement verbatim.

-PatP
Originally Posted by ugabuga
Hello everyone,
i have an assignment and i would really appreciate it if any of you could help me.

The assignment is:
"You have a relation EMPLOYEES (clustered) sized B(R)>M,where M being the memory of your system.The EMPLOYEES has one attribute salary and you want to calculate the median of the salary of the employees in this relation:

SELECT MEDIAN(Employees.salary)FROM Employees.

Describe a sufficient algorithm (not SQL/code) that calculates questions as the above.
What is the cost of your algorithm"

I'd be very thankful if someone could help.

3. Registered User
Join Date
Nov 2011
Posts
2
I'm not sure whether the cost is going to be 2,5B(R) or 3B(R).
I mean what do you do:read from the disk and sort in the memory and then flush to disk which has cost 2B(R) and then just read by the half and you'll find the median OR write to memory once more to sort the sorted sublists and then just pull the middle tuple therefor the cost is 3B(R) plus one tuplet???

4. World Class Flame Warrior
Join Date
Jun 2003
Location
Ohio
Posts
12,595
Originally Posted by ugabuga
Hello everyone,
i have an assignment and i would really appreciate it if any of you could help me.
No problem.

Originally Posted by ugabuga
Hello everyone,
The assignment is:
"You have a relation EMPLOYEES (clustered) sized B(R)>M,where M being the memory of your system.The EMPLOYEES has one attribute salary and you want to calculate the median of the salary of the employees in this relation:
First, get some more M. M is cheap. No excuse for running low on M these days.

Originally Posted by ugabuga
Hello everyone,
SELECT MEDIAN(Employees.salary)FROM Employees.
Describe a sufficient algorithm (not SQL/code) that calculates questions as the above.
Count the number of employees. Divide by two. Step through the employees sorted by salary until you hit that number.

Originally Posted by ugabuga
Hello everyone,
What is the cost of your algorithm
\$29.99, and I accept PayPal.

Originally Posted by ugabuga
Hello everyone,
I'd be very thankful if someone could help.
Again, no problem.

5. Programming since 1BC
Join Date
Sep 2009
Location
Ontario
Posts
1,057

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•