# Optimal algorithm for scanning servers.

1. Jun 25, 2014

### noelo2014

I'm writing a piece of software and need to find an optimal algorithm for scanning servers. Basically I'm given a list of N IP addresses, each IP address has two associated datetime values: The time the server was last known to be online and the time of the last connection attempt.

Given these values I need to sort the list so the servers most likely to be online right now are at the top of the list.

2. Jun 25, 2014

### cpscdave

For sorting lists take a look at qsort I believe its nLogn and a lot of languages have built in functions for it :)

3. Jun 25, 2014

### noelo2014

I don't think you understand my question. I'm not concerned with sorting algorithms, I need a way of choosing which server to attempt to connect to based on the last time it was online and the time I last tried to connect to it.

I think I have it figured out though. As a general rule, if the (time I last attempted to connect)* was recent and (the time the server was last online)* was not, then it's unlikely this server is online.
If the situation is reversed then it's more likely the server is online right now.

* these times are relative to the max/min in each of these sets

I'm sure there's some mathematical formula that applies to scenarios like this. that's why I posted it in the maths programming forum, maybe I'll re-post in the maths forum! probably probability...