This file contains 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 | |
class Heap { | |
private $items = []; | |
public function peek() { | |
if ( $this->items ) { | |
return $this->items[0]; | |
} |
This file contains 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 heapSort( $arr ) { | |
$arr = createHeap( $arr ); | |
$sorted = []; | |
$arrLength = count( $arr ); | |
for ( $i = 1; $i <= $arrLength; $i ++ ) { | |
$last = count( $arr ); | |
array_unshift( $sorted, $arr[1] ); | |
$arr[1] = $arr[ $last ]; |
This file contains 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 | |
class Node { | |
public $id; | |
public $edges = []; | |
public $colorId; | |
public function __construct( $id, $colorId ) { | |
$this->id = $id; |
This file contains 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
SELECT node, IF(parent IS NULL, 'Root', IF( (select count(*) from btree as b2 where b1.node = b2.parent)>0, 'Inner', 'Leaf' )) FROM btree as b1 |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 14/11/19 | |
* Time: 16:37 | |
*/ | |
function numberOfConnections( $gridOfNodes ) { |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 11/11/19 | |
* Time: 21:51 | |
*/ | |
function programmerStrings( $s ) { | |
$possibleLetters = getPossibleLetters(); |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 11/11/19 | |
* Time: 13:47 | |
*/ | |
class Node { |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 10/11/19 | |
* Time: 20:17 | |
*/ | |
class Node { |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 09/11/19 | |
* Time: 18:18 | |
*/ | |
class Vertex { |
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: adriano | |
* Date: 09/11/19 | |
* Time: 13:18 | |
*/ | |
class Node { |