I wrote a blog about Quick Sort before. Let's talk more about it.

  If you don't think that the implementation in the blog mentioned is easy to remember and understand.

You can send your implementation to me by E-mail(lxw.ucas@gmail.com). Now let's look at some other

implementations that are not so amazing:

  A new implementation in python is shown here:

def qs(arr):
if not arr:
return []
low = []
high = []
for x in arr[1:]:
if x <= arr[0]:
low.append(x)
else:
high.append(x)
low = qs(low)
high = qs(high)
return low + arr[:1] + high # low + arr[0] + high is NOT OK! --> ERROR PROMPT: 'can only concatenate list(not int) to list'

  It seemed not so amazing and easy to understand as the former one. But it's ok as well. : ) Let's look

at another new implementation in python:

def quickSort(arr, start, end):
if start >= end: # EXIT
return
i = start
j = end
target = arr[i]
while i < j:
while arr[i] <= target and i < end:
i += 1
while arr[j] > target and j > start:
j -= 1
if i < j:
arr[i], arr[j] = arr[j], arr[i]
arr[start] = arr[j]
arr[j] = target
quickSort(arr, start, j - 1)
quickSort(arr, j + 1, end)

  Now, which way of implementation do you prefer? Do you think the implementation in the blog mentioned

is easy to understand and remember?

最新文章

  1. Git同步原始仓库到Fork仓库中
  2. Linux的NTP配置总结
  3. 写日志 log 到文件夹
  4. char wchar 互转 多字符 宽字符 的N种方式
  5. css小知识之伪元素
  6. centos 7.0最小化安装 查看yum 所有安装的软件包~
  7. 客户端请求、服务器响应及其HTTP状态码
  8. ORACLE在存储过程中记录日志的处理包
  9. EF6多线程与分库架构设计之Repository
  10. jqueryui sortable拖拽后保存位置
  11. vxworks for x86读取bios时间的解决方法
  12. 15、TypeScript-函数
  13. 开发第一个flutter程序 hello world
  14. AtCoder Grand Contest 031 简要题解
  15. AOP 如果被代理对象的方法设置了参数 而代理对象的前置方法没有设置参数 则无法拦截到
  16. [Spring Boot] Singleton and Prototype
  17. android图片等比例缩放 填充屏幕
  18. CAN网要不要共地?
  19. iOS开发之JSONKit
  20. 在VS2015中用C++编写可被其它语言调用的动态库DLL

热门文章

  1. C语言基础(16)-指针
  2. 分分钟学会一门语言之Python篇
  3. mock实例方法
  4. java中的static方法和实例方法区别
  5. flume 中的 hdfs sink round 和roll
  6. Java并发编程(十三)在现有的线程安全类中添加功能
  7. csla 与高cpu
  8. Emoji表情图标在iOS与PHP之间通信及MySQL存储
  9. [已解决]windows下python3.x与python2.7共存版本pip使用报错问题
  10. Spring4 MVC+Hibernate4 Many-to-many连接表+MySQL+Maven实例