944,202 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1175
  • C RSS
Apr 27th, 2007
0

how to writ this kind of algorithem

Expand Post »
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.
Similar Threads
Reputation Points: 9
Solved Threads: 0
Newbie Poster
shamma is offline Offline
7 posts
since Apr 2007
Apr 27th, 2007
1

Re: how to writ this kind of algorithem

No. Gently caress you. Do your own homework.
Team Colleague
Reputation Points: 1135
Solved Threads: 173
Super Senior Demiposter
Rashakil Fol is offline Offline
2,480 posts
since Jun 2005
Apr 27th, 2007
0

Re: how to writ this kind of algorithem

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: How to view the code
Next Thread in C Forum Timeline: Query on Structures





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC