2019年12月24日

循环链表

摘要: class Node{ public $data=null; public $next = null; public function __construct($data=null){ $this->data = $data; } } class LinkdList{ public $header= 阅读全文

posted @ 2019-12-24 10:50 孤灯引路人 阅读(250) 评论(0) 推荐(0) 编辑

双向链表

摘要: class Node{ public $data=null; public $next = null; public $prev=null; public function __construct($data=null){ $this->data = $data; } } class BubbleL 阅读全文

posted @ 2019-12-24 10:48 孤灯引路人 阅读(101) 评论(0) 推荐(0) 编辑

单项链表

摘要: class Node{ public $data=null; public $next=null; public function __construct($data=null){ $this->data = $data; } } class LinkNode{ public $header=nul 阅读全文

posted @ 2019-12-24 08:09 孤灯引路人 阅读(106) 评论(0) 推荐(0) 编辑

[alv]平衡二叉树

摘要: class AVLNode{ public $data; // 节点数据 public $left = null; // 左子结点 public $right = null; // 右子节点 public $bf = 0; // 平衡因子BF public $parent = null; // 存储 阅读全文

posted @ 2019-12-24 08:07 孤灯引路人 阅读(118) 评论(0) 推荐(0) 编辑

大文件归并排序

摘要: //大文件排序 function countsLines($path){ $fd = fopen($path,"r"); $total=0; while(!feof($fd)){ $total++; fgets($fd); } return $total; } $filePath = "./file 阅读全文

posted @ 2019-12-24 08:06 孤灯引路人 阅读(346) 评论(0) 推荐(0) 编辑

快速排序查找匹配元素最前面是否有对应得元素

摘要: $arr = [1,2,3,3,4,5,6]; function binSearch($arr,$num,$start,$end){ if($start > $end){ return -1; } $mid = floor(($start+$end)/2); $midValue = $arr[$mi 阅读全文

posted @ 2019-12-24 00:20 孤灯引路人 阅读(120) 评论(0) 推荐(0) 编辑

二分查找

摘要: $nums = [1, 2, 3, 4, 5, 6]; $num=5; $start = 0; $end = count($nums)-1; echo binary_search($nums,$num,$start,$end); function binary_search($nums,$num,$ 阅读全文

posted @ 2019-12-24 00:19 孤灯引路人 阅读(138) 评论(0) 推荐(0) 编辑

冒泡排序

摘要: $arr = [100,3,5,6,90,10]; for($i=0;$i<count($arr)-1;$i++){ for($j=0;$j<count($arr)-$i-1;$j++){ if($arr[$j] > $arr[$j+1]){ $tmp = $arr[$j]; $arr[$j]=$a 阅读全文

posted @ 2019-12-24 00:18 孤灯引路人 阅读(75) 评论(0) 推荐(0) 编辑

快速排序

摘要: $arr= array(2,13,42,34,56,23,67,365,87665,54,68,3); $info = quick_sort($arr); print_r($info); function quick_sort($arr){ if(count($arr) <= 1){ return 阅读全文

posted @ 2019-12-24 00:16 孤灯引路人 阅读(124) 评论(0) 推荐(0) 编辑

归并排序

摘要: $arr=array(19,7,5,1,3,10); $tmp = mergeSort($arr); print_r($tmp); function mergeSort($arr){ $start = 0; $end = count($arr)-1; if($end == 0){ return $a 阅读全文

posted @ 2019-12-24 00:15 孤灯引路人 阅读(112) 评论(0) 推荐(0) 编辑

导航