Created
July 7, 2019 20:55
-
-
Save manish-manghwani/772af678c82e74b8d7d669c7056d9915 to your computer and use it in GitHub Desktop.
Trying to find why allocate memory exceeds 500MB even when there are 2 entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function quickSort($unsortedArray){ | |
| $leftArray = []; | |
| $rightArray = []; | |
| $arrayCount = count($unsortedArray); | |
| //considering middle of array | |
| $pivot = $unsortedArray[(int)floor($arrayCount / 2)]; | |
| for($i = 0; $i < $arrayCount ; $i++){ | |
| if($unsortedArray[$i] < $pivot){ | |
| array_push($leftArray,$unsortedArray[$i]); | |
| }else{ | |
| array_push($rightArray,$unsortedArray[$i]); | |
| } | |
| } | |
| $tempRight = quickSort($rightArray); | |
| $sortedRight = array_push($pivot,$tempRight); | |
| $tempLeft = quickSort($leftArray); | |
| $sortedLeft = array_push($tempLeft,$sortedRight); | |
| return array_push($sortedRight,$sortedRight); | |
| } | |
| $unsortedArray = [200,100]; | |
| var_dump($unsortedArray); | |
| $sortedArray = quickSort($unsortedArray); | |
| var_dump($sortedArray); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment