PHP code example of yousafsyed / algorithms

1. Go to this page and download the library: Download yousafsyed/algorithms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yousafsyed / algorithms example snippets


        4;
		$list = array(5,2,3,4,1);
	//Sort Algorithms examples
		$list = Algorithms\Sort::insertion_sort($list);
		$list = Algorithms\Sort::insertion_sort($list);
		$list = Algorithms\Sort::comb_sort($list);
		$list = Algorithms\Sort::selection_sort($list);
		$list = Algorithms\Sort::heap_sort($list);
		$list = Algorithms\Sort::bubble_sort($list);
	
	
	// Search Algorithms examples
	
		echo Algorithms\Search::binary_search($list, $x);
		echo Algorithms\Search::jump_search($x, $list);
		echo Algorithms\Search::kmp_search("ABC ABCDAB ABCDABCDABDE", "ABCDABD"); // 15
	
	
	// Stack Example
		$stack = new  Containers\Stack();
		$stack->push("hellow");
		$stack->push(2);
		$stack->push(3);
		$stack->push(4);
		$stack->push(5);
		echo $stack->top();