写blog的好处是,琢磨过的东西不用再琢磨第二次了。
快速排序算法的非递归实现:
#!/bin/bash declare -a inputArray=(2 3 5 0 1 5 7 1 2 9 0); declare -a startStack; declare -a endStack; #init inputArray randomly for((i=0;i<10000;i++)) do inputArray[$i]=$RANDOM; done arrayLength=${#inputArray[@]}; lastIndex=$((arrayLength-1)); startStack[0]=0; endStack[0]=$lastIndex; stackDeep=1; while [[ $stackDeep -ne 0 ]] do ## pop stack topIndex=$((stackDeep-1)); low=${startStack[$topIndex]}; hig=${endStack[$topIndex]}; stackDeep=$((stackDeep-1)); ##partition here if [[ $low -lt $hig ]]; then low1=$low; hig1=$hig; partition=0; # select the first element for the base splitor tmp=${inputArray[$low1]}; while [[ $low1 -ne $hig1 ]] do while [[ $low1 -lt $hig1 && ${inputArray[$hig1]} -ge $tmp ]] do hig1=$((hig1-1)); done if [[ $low1 -lt $hig1 ]]; then inputArray[$low1]=${inputArray[$hig1]}; low1=$((low1+1)); fi while [[ $low1 -lt $hig1 && ${inputArray[$low1]} -le $tmp ]] do low1=$((low1+1)) done if [[ $low1 -lt $hig1 ]]; then inputArray[$hig1]=${inputArray[$low1]}; hig1=$((hig1-1)); fi done inputArray[$low1]=$tmp; partition=$low1; ## push stack if [[ $low -lt $partition ]]; then lowp=$((partition-1)); startStack[$stackDeep]=$low; endStack[$stackDeep]=$lowp; stackDeep=$((stackDeep+1)); fi if [[ $hig -gt $partition ]]; then higp=$((partition+1)); startStack[$stackDeep]=$higp; endStack[$stackDeep]=$hig; stackDeep=$((stackDeep+1)); fi fi done
用栈操作模拟递归实现而已。
相关推荐
以上就是小编为大家带来的解决ssh远程登陆linux显示-bash-4.1$的问题全部内容了,希望大家多多支持软件开发网~ 您可能感兴趣的文章:浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释php $_SERVER windows系统与linux...
在centos6或rhel6 操作系统安装bash-completion-2.1-6.el7.noarch.rpm后,重启即生效
bash-3.1-MSYS-1.0.11-snapshot.tar.bz2 ffmpeg 安装用包!
#tar zxvf bash-4.4.tar.gz #cd bash-4.4 #./configure (如果centos7编译失败,请先安装#yum install gcc) #make #make install 添加环境变量 #echo‘ export PATH=/usr/local/bin:$PATH‘ >>/etc/profile #source...
Footnoted_advanced_bash-scripting_guide_2014-03-10_v.10_abs-guide Footnoted_advanced_bash-scripting_guide_2014-03-10_v.10_abs-guide Footnoted_advanced_bash-scripting_guide_2014-03-10_v.10_abs-guide ...
入门Linux-Bash-Shell,PDF文档入门教程。入门Linux-Bash-Shell,PDF文档入门教程。
AIX-6系统的bash-5安装包
git-bash.exe
离线安装包,测试可用
bash-4.1.2-15
linux下提示bash-command not found.docx
通过查看文档和自己的测试,bashdb-4.2.0-7 和centos7的bash-4.2.46版本匹配,并且编译顺利. 使用方法: 解压bashdb [root]#tar xf bashdb-4.2-0.7.tar.gz -C /usr/src 编译安装bashdb 编译安装bashdb有两种方法,...
修复redhat6 bash远程执行任意代码漏洞CVE-2014-6271
执行如下命令查看设备是否存在bash安全漏洞。 #env -i X='() { (a)=>\\' bash -c '/dev/stdout echo vulnerable' 2>/dev/null 判定依据 如果以上命令的输出为以下内容则不合规: vulnerable
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
60-Linux-Bash-Terminal-Keyboard-Shortcuts-1.pdf
windows下msys2或git-bash终端主题配置文件。 1. msys2环境,请将配置文件放在它的$HOME路径下,举例:C:\msys64\home\username\ 2. git-bash环境,请将配置文件放在windows系统的用户目录下,举例:C:\Users\...
官方离线安装包,亲测可用
redhat bash漏洞补丁包含文件:bash-4.1.2-15.el6_5.2.i686.rpmbash-4.1.2-15.el6_5.2.x86_64.rpmbash-3.0-27.el4.i386.rpmbash-3.0-27.el4.x86_64.rpmbash-3.2-33.el5_11.4.i386.r... redhat bash漏洞补丁 包含文件...
ggcom-bash-utils GotGet Common-Bash-实用程序 Install: mkdir -pv ~/ggcom/ git clone https://github.com/LTGIV/ggcom-bash-library.git ~/ggcom/ggcom-bash-library/ git clone ...