Download the PHP package slince/tree-samples without Composer

On this page you can find all versions of the php package slince/tree-samples. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tree-samples

PHP版本二叉树遍历算法

Build Status Coverage Status Latest Stable Version Scrutinizer

包含深度优先算法与广度优先算法; 本示例采用的是非递归算法;借用 SplStackSplQueue 实现两种算法的遍历。在开始讲算法之前,我们先创建一个二叉树节点类 Node,源码:

深度优先(DFS)

此算法我们使用的是 Stack,栈的特性是先入后出,借此我们有了如下思路:

  1. 创建一个空的堆栈 SplStack 对象
  2. 将需要遍历的二叉树节点对象压入栈

  3. 循环堆栈对象;
  4. 弹出栈内的第一个节点,此节点即完成遍历;
  5. 将当前访问的节点的右子节点和左子节点先后压入堆栈.

  6. 循环下去,直到堆栈内节点完全弹出即可完成二叉树的遍历。

完整代码

广度优先(BFS)

此算法我们使用的是 Queue,队列的特性是先入先出,我们的思路如下:

  1. 创建一个空的堆栈 SplQueue 对象
  2. 将需要遍历的二叉树节点对象入队

  3. 循环队列对象;
  4. 弹出对首的节点,此节点完成访问;
  5. 将当前访问的节点的左子节点和由子节点先后入队.

  6. 循环下去,直到队列内元素完全弹出。

完整代码

Usage

Installation:

Basic Usage:

LICENSE

MIT 协议;


All versions of tree-samples with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slince/tree-samples contains the following files

Loading the files please wait ....