Centos7

CentOS7安装Python3的方法CentOS7搭建L2TP服务端一键脚本CentOS7使用CertBot工具获取LetSencrypt泛域名HTTPS证书

Git

GIT删除仓库的历史提交记录脚本示例GIT进行代码量统计和贡献统计

HTTP

HTTP关于HEADER的详细解释HTTP协议对URI长度POST数据长度及COOKIE长度限制说明HTTP关于Code状态码的详细解释

JavaScript

JavaScript下的RSA对称加密DEMOJavaScript解析并遍历Excel示例代码JavaScript调用语音合成Speech Synthesis API使用ElementUI配合API数据快速渲染合并表格

Linux

Linux 信号说明列表说明Linux利用CronTab定时执行ThinkPHP命令行模式

MySQL

MySQL字符串截取MySQL腾讯云数据库导出备份到本地服务器导入MySQL设计与使用规范MySQL在5.7及以上版本中的ONLY_FULL_GROUP_BY问题处理方案

Nginx

Nginx反向代理NodeJS实现WSS协议Nginx反向代理中的Host参数传递遇到的坑Nginx配置HTTPS与HTTP2.0Nginx负载均衡的lnmp环境初始化脚本Nginx图片递归代理服务器DEMO

NodeJS

NodeJS一些冷门但实用的npm包NodeJS使用Request模块实现CURLNodeJS使用express模块无法收到phpCurl的值NodeJS使用jimp和qrcode-reader识别解析二维码NodeJS实现UDP数据报套接字通讯NodeJS实现Websocket聊天室NodeJS实现串口通讯简单例程NodeJS实现微信协议登录NodeJS实现超级方便的Git自动发布WebhookNodeJS控制台简单表格打印NodeJS转码amr到mp3NWJS配置文件

Other

C#串口通信扫码枪数据读取支付宝Schema协议列表默克尔树基础算法示例博客的升级历程

PHP

PHP下RSA对称加密超长字符串分段加密DEMOPHP下phpMyAdmin数据字典美化代码PHP下的RSA对称加解密-根证书自签与签发子证书PHP使用root权限执行系统命令和切换到www用户PHP使用独占文件指针实现阻塞少量并发PHP多进程同时处理任务示例DEMO代码PHP大文件视频上传WebUploaderPHP实现Web方式发起一个超时任务的处理请求PHP实现二叉查找树的简单代码实现PHP实现微博登录简单代码PHP微信JSSDK开发DEMOPHP的坑XML转JSONPHP简单实现QQ登录代码PHP获取URL HTTP_HOST和SERVER_NAMEPHP获取上周、本周、上月、本月、本季度、上季度时间方法PHP获取真实IP之IP代理-IP伪造-真实IPPHP解密微信小程序手机号简单DEMOPHP高精度计算常用代码

Python

Python3使用Pool进程池实现多进程并发Python3使用jieba分词并生成WordCloud词云图Python3使用request进行CURL操作Python3实现WebhookPython3使用Selenium进行自动化测试手册

Wechat

微信公众号php环境无法获取POST值微信公众号网页跳转避免出现导航栏的小技巧
PHP实现二叉查找树的简单代码实现
手机阅读

扫描二维码阅读文章
<?php
class Tree{
	public $top=null;
	public $leftChild=null;
	public $rightChild=null;
	public function Tree($top){
		$this -> top = $top;
	}
	/**
	 * 添加一个子节点
	 **/
	public function addChild($child){
		if ($this -> top > $child){
		    //如果添加的节点比当前节点小 放到左边
			if (empty($this->leftChild )){
			    //如果左边节点为空 直接给左边节点
				$this->leftChild =new Tree($child);
			}else {
			    //递归 左边节点添加子节点
				$this->leftChild ->addChild ($child);
			}
		}else if ($this->top <$child){
		    //如果添加的节点比当前节点大 放到右边
			if (empty($this->rightChild )){
			    //如果右边节点为空 直接给右边节点
				$this->rightChild =new Tree($child);
			}else {
			    //递归 右边节点添加子节点
				$this->rightChild ->addChild ($child);
			}
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 获取一个子节点
	 **/
	public function getChild ($child){
		if ($this->top >$child){
			return $this->leftChild ->getChild ($child);
		}else if ($this->top <$child){
			return $this->rightChild ->getChild ($child);
		}else {
			return $this;
		}
	}
	/**
	 * 获取指定节点下的最大节点
	 **/
	public function  getMaxChild ($node){
		if (empty($node->rightChild )){
			return $node;
		}else {
			return $this->getMaxChild ($node->rightChild );
		}
	}
	/**
	 * 获取指定节点下的最小节点
	 **/
	public function  getMinChild ($node){
		if (empty($node->leftChild )){
			return $node;
		}else {
			return $this->getMinChild ($node->leftChild );
		}
	}
	/**
	 * 删除指定的节点
	 **/
	public function  removeChild ($child){
		if ($this->top >$child){
			if (empty($this->leftChild )){
				return false;
			}else {
				if ($this->leftChild ->top ==$child){
					if (isset($this->leftChild ->leftChild ) && isset($this->leftChild ->rightChild )){
						$maxNode=$this->getMaxChild ($this->leftChild ->leftChild );
						$this->removeChild ($maxNode->top );
						$this->leftChild ->top =$maxNode->top ;
					}else if (empty($this->leftChild ->leftChild )){
						$this->leftChild =$this->getChild ($child)->rightChild ;
						return true;
					}else if (empty($this->leftChild ->rightChild )){
						$this->leftChild =$this->getChild ($child)->leftChild ;
						return true;
					}else {
						$this->leftChild =null;
						return true;
					}
				}else {
					return $this->leftChild ->removeChild ($child);
				}
			}
		}else if ($this->top <$child){
			if (empty($this->rightChild )){
				return false;
			}else {
				if ($this->rightChild ->top ==$child){
					if (isset($this->rightChild ->leftChild ) && isset($this->rightChild ->rightChild )){
						$maxNode=$this->getMaxChild ($this->rightChild ->leftChild );
						$this->removeChild ($maxNode->top );
						$this->rightChild ->top =$maxNode->top ;
					}else if (empty($this->rightChild ->leftChild )){
						$this->rightChild =$this->getChild ($child)->rightChild ;
						return true;
					}else if (empty($this->rightChild ->rightChild )){
						$this->rightChild =$this->getChild ($child)->leftChild ;
						return true;
					}else {
						$this->rightChild =null;
						return true;
					}
				}else {
					return $this->rightChild ->removeChild ($child);
				}
			}
		}else {
		    //根节点就是要删除的
			if (isset($this ->leftChild ) && isset($this ->rightChild )){
				$maxNode=$this->getMaxChild ($this -> leftChild );
				$this-> removeChild ($maxNode -> top);
				$this -> top = $maxNode->top ;
			}else if (empty($this ->leftChild )){
				$this->leftChild =$this->getChild ($this)->rightChild ;
				return true;
			}else if (empty($this ->rightChild )){
				$this->leftChild =$this->getChild ($this)->leftChild ;
				return true;
			}else {
				$this->leftChild =null;
				return true;
			}
	    }
	}
}
$tree=new Tree(15);
$tree->addChild (9);
$tree->addChild (23);
$tree->addChild (3);
$tree->addChild (12);
$tree->addChild (17);
$tree->addChild (28);
$tree->addChild (8);
$tree->addChild (1);
$tree->addChild (4);
$tree->addChild (11);
$tree->removeChild (4);
$tree->removeChild (9);
$tree->removeChild (15);
print_r($tree);

Tree Object
(
    [top] => 12
    [leftChild] => Tree Object
        (
            [top] => 8
            [leftChild] => Tree Object
                (
                    [top] => 3
                    [leftChild] => Tree Object
                        (
                            [top] => 1
                            [leftChild] => 
                            [rightChild] => 
                        )

                    [rightChild] => 
                )

            [rightChild] => Tree Object
                (
                    [top] => 11
                    [leftChild] => 
                    [rightChild] => 
                )

        )

    [rightChild] => Tree Object
        (
            [top] => 23
            [leftChild] => Tree Object
                (
                    [top] => 17
                    [leftChild] => 
                    [rightChild] => 
                )

            [rightChild] => Tree Object
                (
                    [top] => 28
                    [leftChild] => 
                    [rightChild] => 
                )

        )

)