$practiceDB = new Database('algorithm_practice'); $query = $practiceDB->db->prepare("SELECT * FROM sorting WHERE id < {$limit}"); try { $query->execute(); $unsortedArray = $query->fetchAll(PDO::FETCH_COLUMN, 1); } catch (PDOException $e) { echo 'Query error: ' . $query->errorCode(); exit; } $searchTree = new BinarySearchTree($unsortedArray); echo "Checking for values that should be present<br>"; $present = selectPresentValues($unsortedArray, $limit / 2); $present[] = 3685; // the first number in the DB, make sure the root is OK; foreach ($present as $valueToFind) { $foundPresent = $searchTree->search($valueToFind); if (!$foundPresent) { echo "Problem: couldn't find {$valueToFind}<br/>"; } } echo "Checking for values that should not be present<br>"; $notPresent = selectNotPresentValues($unsortedArray, $limit / 2); foreach ($notPresent as $shouldNotFind) { $foundNotPresent = $searchTree->search($shouldNotFind); if ($foundNotPresent) { echo "Problem: found {$shouldNotFind}<br/>"; } } echo "Removing elements and checking that they and only they have been removed<br>"; $toRemove = array_slice($present, 0, $limit / 4); //$toRemove = [6331, 6298];