算法and数据结构
2018-04-26 本文已影响0人
饥人谷_sunny
算法
冒泡排序
流程图选择排序
流程图计数排序
a = {
'0':0,
'1':2,
'2':1,
'3':6,
'4':4,
'5':9,
'6':3,
'length':7
}
hash = [];
index = 0;
maxIndex = 0;
while index < a['length']
number = a[index]
if hash[number] == undefined // hash[number] 不存在
hash[number] = 1
else
hash[number] = hash[number] ++
while a[maxIndex] < a[index]
maxIndex = index
index = index ++
end
index2 = 0
max = a[maxIndex] // 最大值9
newArr = []
while index2 <= max
count =0
if count < has[index2]
newArr.push(index2)
count = count ++
end
index2 = index2 ++
end
print newArr
end
image.png