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.

Hasznosnak találta ezt a választ?

 Kinyomtatja ezt a cikket

Olvassa el is

Where can i use command line instead of gui in cpanel?

Posted by sash_007, 03-09-2010, 08:46 AMHello friends, Just wondering whether i can use...

Script PHP to check links automatically - backlink checker

Posted by JaneP, 10-22-2012, 12:08 PMHello forum Sometimes it is necessary to check every time...

.htaccess & cpanel

Posted by compjab, 03-24-2007, 11:22 PMI've protected a directory with cPanel and the user/pwd...

a line in my crontab

Posted by cannibal, 01-13-2008, 05:50 AMhello I found this line in my crontab file 0...

Soap question

Posted by paintball12k, 09-21-2008, 04:41 AMDoes anyone know where I can find good articles on...