how to writ this kind of algorithem

Reply

Join Date: Apr 2007
Posts: 7
Reputation: shamma is an unknown quantity at this point 
Solved Threads: 0
shamma shamma is offline Offline
Newbie Poster

how to writ this kind of algorithem

 
0
  #1
Apr 27th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: how to writ this kind of algorithem

 
1
  #2
Apr 27th, 2007
No. Gently caress you. Do your own homework.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,681
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 264
Lerner Lerner is offline Offline
Posting Virtuoso

Re: how to writ this kind of algorithem

 
0
  #3
Apr 27th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC