Alorithm help

Posted by Red_wolf6, 03-07-2010, 04:41 PM
Hello, I have a Question - I couldn't solved it We have an unordered List, I want to find the phone number of john and it's position in the table names. NAME : http://i47.tinypic.com/x572he.png TELEPHONE: http://i47.tinypic.com/dysidy.png Any idea what to do?

Posted by UNIXy, 03-07-2010, 05:20 PM
There's isn't much of a sophisticated algorithm one can use against an unordered list. You just have to iterate through each of the list's elements until you find John. So for an unordered list, the algorithm is going to be O(n) no matter what. It's usually best to sort the list first (perhaps based on person's name) and then implement one of the many efficient algorithms on ordered lists. Sorting the list once makes subsequent searches much more efficient. Regards Joe / UNIXY

Posted by Mark Edwards, 03-09-2010, 12:36 AM
Honestly though if the list is only 1000 people long, no big deal. Just loop it getting name/phone number and checking if name is John. Or have two arrays and use the indexes appropriately. Both work.

Hjalp dette svar dig?

 Print denne artikel

Læs også

SPAM died me

Posted by Tiva, 03-19-2007, 05:43 AMhi, my support and sales mailbox almost get full of spam and...

Exchange Replication?

Posted by regmac01, 09-16-2007, 12:19 AMWhat would be the best way to replicate two exchange...

SMS sending script

Posted by stjoenetworks, 01-16-2008, 11:35 PMAnyone know a decent/good script for sending SMS...

Delete files created on a specific date

Posted by Acroplex, 06-28-2008, 08:16 PMIs there a quick shell command to find (inside a...

WordPress sitemap plugin problem or no ?

Posted by SimonDevise, 11-06-2012, 05:25 AMI have use WordPress sitemap plugin 2-3 month, but I...