$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]; foreach ($toRemove as $remove) { $searchTree->delete($remove); $foundRemoved = $searchTree->search($remove); if ($foundRemoved) { echo "Problem: found {$remove}<br/>"; } } $remaining = array_diff($present, $toRemove); foreach ($remaining as $valueToFind) { $foundPresent = $searchTree->search($valueToFind); if (!$foundPresent) { echo "Problem: couldn't find {$valueToFind}<br/>"; } } echo "Done.";