Results 1 to 5 of 5
  1. #1
    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. #2
    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
    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.

  3. #3
    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. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    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"
    www.LobsterShot.blogspot.com

  5. #5
    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
  •