# Algorithms – notes

• http://raghibm.com/blog/checklist-for-a-softwareEng-interview/
• https://www.movable-type.co.uk/scripts/latlong.html

Calculate distance, bearing and more between Latitude/Longitude points; must read; has code sample; has equations; reference; Haversine algorithm.

• https://www.plumislandmedia.net/mysql/haversine-mysql-nearest-loc/

must-read; dude give this nice SQL construct (MySQL) :

``````  SELECT id, zipcode, latitude, longitude, distance_km
FROM (
SELECT c.id,
a.zip AS zipcode,
a.latitude, a.longitude,
FROM company c
JOIN ( -- these are the query parameters
SELECT  :latpoint  AS latpoint,
:longpoint AS longpoint,
:distance_unit AS distance_unit
) AS p ON 1=1
WHERE a.latitude IS NOT NULL
AND a.longitude IS NOT NULL
AND a.latitude BETWEEN p.latpoint  - (p.radius / p.distance_unit)
AND p.latpoint  + (p.radius / p.distance_unit)
) AS result -- sub-result.
ORDER BY distance_km
``````

Ex. query with Doctrine :

``````  \$result = \$this->getEntityManager()
->getConnection()
->fetchAll(\$sql, [ 'latpoint'  => \$latitude,
'longpoint' => \$longitude,
'distance_unit' => 111.045 ],
[ \PDO::PARAM_STR, \PDO::PARAM_STR,
\PDO::PARAM_STR, \PDO::PARAM_STR ]);
\$company_ids = array_map(function(array \$row) { return \$row['id']; }, \$result);
\$companies = \$this->findBy(['id' => \$company_ids]);
``````

### Lists

• One-way linear list “is a sequence of cells each of which (except the last) points to its successor.”

### Heap, priority queues

https://en.wikipedia.org/wiki/Heap_(data_structure)

## Hash/map

•  [New Concurrent Hash Maps for C++ 2016, Jeff Preshing](http://preshing.com/20160201/new-concurrent-hash-maps-for-cpp/) (as well as [Using Quiescent States to Reclaim Memory 2016, Jeff Preshing](http://preshing.com/20160726/using-quiescent-states-to-reclaim-memory/)).

## Other concepts

•  [What is RCU, Fundamentally ? 2007, lwn.net](https://lwn.net/Articles/262464/)

EOF