PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Yousaf Syed   PHP Array Sort and Search Algorithms   examples.php   Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Array Sort and Search Algorithms
Search and sort arrays using common algorithms
Author: By
Last change:
Date: 9 years ago
Size: 749 bytes
 

Contents

Class file image Download
<?php
include ('autoload.php');

$x = 4;
$list = array(5,2,3,4,1);


//Sort Algorithms examples
// $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();