Skip to content

Commit

Permalink
补充菲波那切数列递归算法
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexchent committed Jul 4, 2021
1 parent 1d4e291 commit f167763
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions Http/HttpCode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# HTTP 常见状态码## 1xx## 2xx200 请求成功 ## 3xx301 永久重定向302 暂时重定向## 4xx401 未授权 一般表示未登录403 拒绝访问 一般表示没有权限 404 请问的资源不存在## 5xx500 服务器错误
Expand Down
2 changes: 1 addition & 1 deletion Linux/linux.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## shell- 解压```1.tar命令 格式tar,gz,rar解包:tar xzvf FileName.tar打包:tar czvf FileName.tar DirName压缩:tar czvf FileName.tar.gz DirName2.gzip命令压缩:gzip FileName 只对单个文件压缩解压:gzip -d FileName.gz3.bzip2命令压缩:bzip2 FileName 只对单个文件压缩解压:bzip2 -d FileName.gz4.zip命令解压:unzip FileName.zip压缩:zip -r FileName.zip DirName4.7z命令压缩 7z a filename.7z dirname解压到包所在目录 7z x filename -p密码```>[7z](压缩/7z.md)>[zip](压缩/zip.md)
## shell- 解压```1.tar命令 格式tar,gz,rar解包:tar xzvf FileName.tar打包:tar czvf FileName.tar DirName压缩:tar czvf FileName.tar.gz DirName2.gzip命令压缩:gzip FileName 只对单个文件压缩解压:gzip -d FileName.gz3.bzip2命令压缩:bzip2 FileName 只对单个文件压缩解压:bzip2 -d FileName.gz4.zip命令解压:unzip FileName.zip压缩:zip -r FileName.zip DirName5.7z命令压缩 7z a filename.7z dirname解压到包所在目录 7z x filename -p密码```>[7z](压缩/7z.md)>[zip](压缩/zip.md)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
### 基本功
- 快速排序
- 冒泡排序
- [斐波那契数列](/suanfa/fibonacci_sequence.php)
- [斐波那契数列](/suanfa/Base/fibonacci_sequence.php)
- [topK 最大顶堆](/suanfa/topk.php)

### 算法练习题
- [二分查找](/suanfa/binarySearch.php)
- [二分查找](/suanfa/Base/binarySearch.php)
- [猴群选举](/suanfa/monkey.php)
- [给定一个二维数组,数组每行从左到右都是递增的;每列也是递增的。
请完成一个函数,输入如上二维数组和一个整数,函数功能为判断该整数是都存在于数组中。
Expand Down
2 changes: 1 addition & 1 deletion laboratory/magicFunction/__invoke.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php/** * 测试__invoke * 当对象实例被当做方法调用时触发 * [laravel框架中关于单个行为控制器的实现就是基于————invoke](https://learnku.com/docs/laravel/6.x/controllers/5138) * * * * Created by PhpStorm. * User: chentao * Date: 2020/1/16 * Time: 10:09 PM */class A { public function __invoke() { // TODO: Implement __invoke() method. echo 'this is invoke'; }}$obj = new A();$obj();
<?php/** * 测试__invoke * 当对象实例被当做方法调用时触发 * [laravel框架中关于单个行为控制器的实现就是基于————invoke](https://learnku.com/docs/laravel/6.x/controllers/5138) * * * * Created by PhpStorm. * User: chentao * Date: 2020/1/16 * Time: 10:09 PM */class A { public function __invoke() { // TODO: Implement __invoke() method. echo 'this is invoke'; } public function __call($name, $arguments) { // TODO: Implement __call() method. var_dump($name); var_dump($arguments); } public static function __callStatic($name, $arguments) { // TODO: Implement __callStatic() method. echo "没有这个静态方法".PHP_EOL; var_dump($name); } public function __clone() { // TODO: Implement __clone() method. echo "我被克隆了"; }}$obj = new A();$obj();$obj->hi(1,2);A::hi(2);$obj2 = clone $obj;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function fib($n, $a, $b) {
return $arr[$n];
};

//时间复杂度 O(n)
function fib2($n, $a, $b) {

if ($n == 1) return $a;
Expand All @@ -30,4 +31,14 @@ function fib2($n, $a, $b) {
return $c;
}

var_dump(fib2(6,1,2));
//递归实现 求数列的第n个数 时间复杂度O(2^n) 优点是算法简单
function fib3($n)
{
if ($n < 2) return $n;
return fib3($n-2) + fib3($n-1);
}

//var_dump(fib2(6,1,2));


var_dump(fib3(4));

0 comments on commit f167763

Please sign in to comment.