If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Need for Algorithm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-20-11, 17:13
ugabuga ugabuga is offline
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 17:16.
Reply With Quote
  #2 (permalink)  
Old 11-21-11, 18:08
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Quote:
Originally Posted by ugabuga View Post
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.
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 11-23-11, 18:04
ugabuga ugabuga is offline
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???
Reply With Quote
  #4 (permalink)  
Old 11-30-11, 13:19
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Quote:
Originally Posted by ugabuga View Post
Hello everyone,
i have an assignment and i would really appreciate it if any of you could help me.
No problem.

Quote:
Originally Posted by ugabuga View Post
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.

Quote:
Originally Posted by ugabuga View Post
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.

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

Quote:
Originally Posted by ugabuga View Post
Hello everyone,
I'd be very thankful if someone could help.
Again, no problem.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #5 (permalink)  
Old 12-02-11, 17:13
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 626
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On