【文件属性】:
文件名称:sort-insertion-asc:数值数组的插入排序
文件大小:8KB
文件格式:ZIP
更新时间:2021-07-09 18:16:28
JavaScript
排序插入升序
插入( arr )
使用排序将未排序的数值数组按升序排序。
例子
var data = [ 4 , 9 , 2 , 6 , 3 , 1 , 7 , 10 , 5 , 8 ] ;
insert ( data ) ;
// modifies data into ascending order
要从*应用程序目录运行示例代码,
$ node ./examples/index.js
笔记
表现
对于大小为 n 的未排序数组,使用插入排序对数组进行排序的时间为:
n
时间(毫秒)
5
9.5
50
10.25
500
12.08
5000
35.25
50000
2274
测试
单元
单元测试使用带有断言的测试框架。 要运行测试,请在*应用程序目录中执行以下命令:
$ make test
所有新功能开发都应该有相应的单元测试来验证正确的功能。
【文件预览】:
sort-insertion-asc-master
----.jshintrc(1KB)
----.gitignore(711B)
----package.json(1KB)
----Makefile(2KB)
----.travis.yml(73B)
----LICENSE(1KB)
----examples()
--------index.js(383B)
----README.md(2KB)
----lib()
--------index.js(883B)
----TODO.md(97B)
----.npmignore(482B)
----test()
--------test.js(1KB)
----.editorconfig(169B)