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.

Bu mövzu kifayət qədər köməkçi oldu mu?

 Çap

Digər Başlıqlar

Domain names diferent servers.

Posted by shakybaky, 06-26-2008, 02:34 PMhello i have two nix vps's One of the vps is setup and...

Rsync Error!

Posted by rkm11, 09-16-2007, 12:26 AMI type rsync and after the man page, it says Any Ideas?...

CACTI with cPanel

Posted by hosteur, 05-07-2007, 07:29 AMMy other box gear by DedicatedPlace and they guys still...

Cronjob issue

Posted by CymraegWalesHosting, 11-16-2012, 11:25 PMHi all, Hopefully this is a simple fix....

Reselling SSL certificates

Posted by luxor, 09-28-2001, 11:11 AMHi: Does anyone know which company is the most...