随笔分类 -  算法

算法之大数相加Java版
摘要:一道面试题,就是用字符串表示两个数,求这两个数的加法。(不能使用内置类BigInteger) 我一开始想到的就是把字符串转成字符数组,然后使用mergesort的思路来处理。 一开始使用的是Integer.parsetInt(String.valueOf(char))有些麻烦,后来改成了'9'-'0 阅读全文

posted @ 2021-07-03 11:35 tneduts 阅读(171) 评论(1) 推荐(0)

python Quicksort demo
摘要:__author__ = 'student' ''' quicksort step 1, choose one pivot, such as pivot=la[0] step 2, scan the data from right side, find data less than pivot, then swap this with pivot pivot=1 [4] 5 7 3 20 9 ... 阅读全文

posted @ 2015-05-09 13:42 tneduts 阅读(535) 评论(0) 推荐(0)

Python HeapSort
摘要:__author__ = 'student' print 'hello world hello python' ''' heap sort root leftchild 2n+1 rightchild 2n+2 compare them and get the maxnode step by step think way one step write the perfect program i... 阅读全文

posted @ 2015-05-09 11:39 tneduts 阅读(756) 评论(0) 推荐(0)

导航