{"id":13791499,"url":"https://github.com/m9rco/algorithm-php","last_synced_at":"2025-05-15T15:08:00.446Z","repository":{"id":48257254,"uuid":"94601472","full_name":"m9rco/algorithm-php","owner":"m9rco","description":"🍭🍭uniting the internal work in a way that is in PHP","archived":false,"fork":false,"pushed_at":"2023-12-08T06:48:31.000Z","size":234,"stargazers_count":1390,"open_issues_count":8,"forks_count":488,"subscribers_count":80,"default_branch":"master","last_synced_at":"2025-04-07T20:11:21.230Z","etag":null,"topics":["arithmetic","composer","learning","php","php-library","php5","php7","phper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m9rco.png","metadata":{"files":{"readme":"README-EN.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-06-17T04:53:07.000Z","updated_at":"2025-03-03T00:38:19.000Z","dependencies_parsed_at":"2024-02-08T19:09:14.855Z","dependency_job_id":"18bdb080-3f6e-45fd-b4e6-a06c1a75f5db","html_url":"https://github.com/m9rco/algorithm-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m9rco%2Falgorithm-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m9rco%2Falgorithm-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m9rco%2Falgorithm-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m9rco%2Falgorithm-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m9rco","download_url":"https://codeload.github.com/m9rco/algorithm-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","composer","learning","php","php-library","php5","php7","phper"],"created_at":"2024-08-03T22:01:01.045Z","updated_at":"2025-05-15T15:07:55.414Z","avatar_url":"https://github.com/m9rco.png","language":"PHP","funding_links":[],"categories":["Uncategorized","PHP"],"sub_categories":["Uncategorized"],"readme":"​\u003ch1 align=\"center\"\u003e:whale:A collection of algorithms that are implemented in PHP:whale: \u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/PuShaoWei/arithmetic-php#简易结构\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/php-done-brightgreen.svg\" alt=\"php\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/PuShaoWei/arithmetic-php\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues-pr-raw/arithmetic-php/cdnjs.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/PuShaoWei/arithmetic-php\"\u003e\n    \u003cimg src=\"https://img.shields.io/codacy/grade/e27821fb6289410b8f58338c7e0bc686.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/PuShaoWei/arithmetic-php\"\u003e\n    \u003cimg src=\"https://img.shields.io/travis/rust-lang/rust.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/PuShaoWei/arithmetic-php\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e \u003ca href=\"./README.md\"\u003e中文版\u003c/a\u003e　\u003cp\u003e\n\n## Simple structure,\n\n```\n├──Package\n│    ├── Sort  \n│    │    ├── BubbleSort.php          \n│    │    ├── QuickSort.php           \n│    │    ├── ShellSort.php           \n│    │    ├── MergeSort.php           \n│    │    ├── InsertSort.php          \n│    │    └── SelectSort.php          \n│    │ \n│    ├── Query 查找篇\n│    │    ├── BinaryQuery.php         \n│    │    ├── InseertQuery.php        \n│    │    ├── FibonacciQuery.php      \n│    │    ├── BFSQuery.php      \n│    │    ├── Kmp.php                 \n│    │    ├── DijkstraQuery.php      \n│    │    └── QulickQuery.php         \n│    │     \n│    └── Other 其他 \n│         ├──  MonkeyKing.php         \n│         ├──  DynamicProgramming.php \n│         ├──  Fibonacci.php          \n│         ├──  StealingApples.php     \n│         ├──  HanoiGames.php       \n│         ├──  BidirectionalQueue.php     \n│         ├──  ColorBricks.php        \n│         ├──  GetCattle.php          \n│         ├──  OnlyNumbers.php        \n│         ├──  Interval.php        \n│         ├──  Maze.php        \n│         ├──  AntsClimb.php        \n│         ├──  Encryption.php        \n│         ├──  ElevatorDispatch.php      \n│         ├──  kmp.php      \n│         ├──  TraversalOfBinary.php      \n│         ├──  PointInTriangle.php      \n│         └──  BigSmallReplace.php    \n│         └──  Knapsack.php    \n│         └──  Solution.php    \n│         └──  RotationSort.php    \n│         └──  Square.php    \n│         └──  Prim.php    \n│         └──  CartesianProduct.php \n│         └──  Square.php \n│         └──  Judge.php \n│         └──  Factorial.php \n|         └──  HashTable.php\n|         └──  RotateSort.php  \n│     \n├──LICENSE \n└──README.md\n```\n\n## What to do？\n\n```\nTo record their understanding algorithms, data structure, the process of simple comprehensive and detailed as possible, let the learning algorithm using flexible, refueling(ง •̀_•́)ง\n```\n\n## logarithmic\n\nlog\u003csub\u003e10\u003c/sub\u003e100 It's equivalent to saying, \"how many tens do you multiply?\" the answer is, of course, two\nso log\u003csub\u003e10\u003c/sub\u003e100=2，The logarithmic operation is the inverse of the power operation\n\n| left               | right                 |\n| ------------------ | --------------------- |\n| 2\u003csup\u003e3\u003c/sup\u003e = 8  | log\u003csub\u003e2\u003c/sub\u003e8 = 3  |\n| 2\u003csup\u003e4\u003c/sup\u003e = 16 | log\u003csub\u003e2\u003c/sub\u003e16 = 4 |\n| 2\u003csup\u003e5\u003c/sup\u003e = 32 | log\u003csub\u003e2\u003c/sub\u003e32 = 5 |\n\nIf you don't, we won't wait for you\n\n## The elapsed time\n\nTake binary search for example, how much time can you save by using it? Simply look for the Numbers and if the list contains 100 Numbers, you need to guess 100 times.\nIn other words, the number of guesses is the same as the length of the list, which is called linear time, while binary search is different if the list contains 100 elements\nIt takes up to seven times, and if the list contains four billion digits, it should be guessed 32 times, while the running time of the subsearch is logarithmic time `O(log)`\n\n## Big O notation\n\nThe big O notation is a special representation of how fast the algorithm can be. There's a diaosi. In fact, you often have to copy other people's code.\nIn this case, you know how fast these algorithms are\n\n- The running time of the algorithm increases at different speeds\n  - For example, the difference between a simple find and a binary search\n\n| element       | Easy to find | Binary search |\n| ------------- | ------------ | ------------- |\n| 100           | 100ms        | 7ms           |\n| 10000         | 10s          | 14ms          |\n| 1 000 000 000 | 11day        | 30ms          |\n\n- ` O ` said hair is pointed out that how fast algorithms, such as list contains ` n ` element, a simple search need to check each element, so you need to perform ` n ` time operations\n  Using large ` O ` said ` O (n) to make this operation `, binary search need to perform log\u003csub\u003en\u003c/sub\u003e using large ` O ` said to`O(log n)`\n  - Some common big O runtime\n- O(log n) ,It's also called log time, and this algorithm includes binary algorithms\n- O(n),Also known as linear time, this algorithm includes simple lookups.\n- O(n * log n) Quick sort\n- O(n\u003csub\u003e2\u003c/sub\u003e),Selection sort\n- O(n!) Factorial time\n  - Here is the point\n- The speed of the algorithm is not the time, but the growth of operands\n- When we talk about the speed of the algorithm, what we're talking about is how fast will it run as the input increases\n- The running time of the algorithm is expressed in large O notation\n- O(log n) is faster than O (n), and the more elements that need to be searched, the more the former is faster than the latter\n\n## A simple comparison of recursion and loops：\n\n1. From a procedural point of view, the recursion manifests itself as calling itself, and the loop does not have this form.\n2. Recursive proceed from the ultimate goal of the problem, and gradually to a complex problem into a simple problem, and simple question solution and complicated problem, at the same time the presence of the benchmark, can eventually get a problem, is the reverse. And the circulation is from the simple question, step by step forward development, finally get the question, is positive.\n3. Any cycle can be represented by recursion, but it is necessary to use the loop to achieve recursion (except for one-way recursion and tail recursion), and the stack structure must be introduced to stack the stack.\n   4.In general, non-recursive efficiency is higher than recursion. And recursive function calls are expensive and recursive times are limited by stack size.\n\n## Progressive learning\n\n1. Fork 我的项目并提交你的 `idea`\n2. Pull Request \n3. Merge \n\n## 纠错\n\nIf you find something wrong, you can initiate a [issue](https://github.com/PuShaoWei/designPatterns-go/issues)or [pull request](https://github.com/PuShaoWei/designPatterns-go/pulls),I will correct it in time\n\n\u003e 补充:发起pull request的commit message请参考文章[Commit message 和 Change log 编写指南](http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html)\n\n## Contributors\n\nThanks for the issue or pull request of the following friends:\n\n- [hailwood ](https://github.com/hailwood)\n\n- [zhangxuanru](https://github.com/zhangxuanru)\n\n- [ifreesec](https://github.com/ifreesec)\n\n- [openset](https://github.com/openset)\n\n- [Neroxiezi](https://github.com/Neroxiezi)\n\n  ## License\n\nMIT \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm9rco%2Falgorithm-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm9rco%2Falgorithm-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm9rco%2Falgorithm-php/lists"}