954,202 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to writ this kind of algorithem

a) Write an algorithm that finds both the smallest and largest numbers in a list of n numbers
and calculate its complexity T(n).:-/

b) Write an algorithm that finds both the smallest and largest numbers in a list of n numbers
and with complexity T(n) is at most about (1.5)n comparisons.:?:

shamma
Newbie Poster
7 posts since Apr 2007
Reputation Points: 9
Solved Threads: 0
 

No. Gently caress you. Do your own homework.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
 

I think this will work. Let's change it up a bit. Say I put some numbers in a paper bag, gave you the paper bag and said take the numbers and tell me what the biggest and smallest number in the bag was. One way you could do it is to sort the numbers (however you wanted to do that) and report the extremes. But can you think of another way you could determine the largest and smallest without sorting the numbers first? If so, try adapting that approach to your problem.

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You