Skip to content

Commit

Permalink
fix some ci warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed Oct 4, 2023
1 parent 5817388 commit b814cf2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Graphs/BreadthFirstSearch.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

/**
* Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property.
* Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies
* a given property.
* (https://en.wikipedia.org/wiki/Breadth-first_search).
*
* This is a non-recursive implementation.
Expand Down
35 changes: 16 additions & 19 deletions Searches/ExponentialSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,32 @@
**** if it were in the list.
* In the second stage, a binary search is performed on this range.
*/
/**
* @param Array $arr
* @param int $value
* @param int $floor
* @param int $ceiling
* @return int
**/

/**
* @param Array $arr
* @param int $value
* @param int $floor
* @param int $ceiling
* @return int
**/
function binarySearch($arr, $value, $floor, $ceiling)
{

// Get $middle index
// Get $middle index
$mid = floor(($floor + $ceiling) / 2);
// Return position if $value is at the $mid position
if ($arr[$mid] === $value) {
return (int) $mid;
}
//Return -1 is range is wrong
//Return -1 is range is wrong
if ($floor > $ceiling) {
return -1;
}
// search the left part of the $array
// If the $middle element is greater than the $value

// search the left part of the $array
// If the $middle element is greater than the $value
if ($arr[$mid] > $value) {
return binarySearch($arr, $value, $floor, $mid - 1);
}
// search the right part of the $array
// If the $middle element is lower than the $value
else {
} else { // search the right part of the $array If the $middle element is lower than the $value
return binarySearch($arr, $value, $mid + 1, $ceiling);
}
}
Expand All @@ -47,13 +45,12 @@ function binarySearch($arr, $value, $floor, $ceiling)
*/
function exponentialSearch($arr, $value)
{

// If $value is the first element of the $array return this position
// If $value is the first element of the $array return this position
if ($arr[0] === $value) {
return 0;
}

// Find range for binary search
// Find range for binary search
$i = 1;
$length = count($arr);
while ($i < $length && $arr[$i] <= $value) {
Expand Down
2 changes: 0 additions & 2 deletions tests/Ciphers/CiphersTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use function PHPUnit\Framework\assertEquals;

use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../vendor/autoload.php';
Expand Down
Loading

0 comments on commit b814cf2

Please sign in to comment.