Google Answers Logo
View Question
 
Q: Data Structure and Algoritm in Java ( No Answer,   1 Comment )
Question  
Subject: Data Structure and Algoritm in Java
Category: Computers > Algorithms
Asked by: math01-ga
List Price: $5.00
Posted: 03 Jun 2003 23:40 PDT
Expires: 08 Jun 2003 23:38 PDT
Question ID: 212832
Give an O(n + klogn) algorithm to compute the kth smallest number in a
given list of n elements. Clearly describe the steps and how much time
they take. Justify the complexity of the complete algorithm.

Request for Question Clarification by secret901-ga on 04 Jun 2003 00:05 PDT
Hello math01,
Do you want the algorithm given in Java or would pseudocode be OK?

Clarification of Question by math01-ga on 04 Jun 2003 23:38 PDT
Hi secret901-ga,

pseudocode is ok but providing the java code as well will not be bad.

Thanks
Answer  
There is no answer at this time.

Comments  
Subject: Re: Data Structure and Algoritm in Java
From: gustavolacerda-ga on 05 Jun 2003 21:53 PDT
 
Build a (max)heap on the N elements (O(N) time)
Perform k deleteMax operations       (O(klogN) time)
The last element extracted from the heap is the answer.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy