我没算错的话,你的space complexity is good, O(N),

你的time complexity is as high as 8 O(N), which is even worse than quick sort. Normally we will trade space for speed in algorithms when I did a lot k-d data structure coding before.

所有跟帖: 

yes, both sub01 and amei has O(0) time complexity -Jamesxu- 给 Jamesxu 发送悄悄话 (0 bytes) () 02/13/2008 postreply 08:25:14

sorry, i meant O(n), not O(0) which means constant -Jamesxu- 给 Jamesxu 发送悄悄话 (0 bytes) () 02/13/2008 postreply 08:35:59

sorry I made a mistake, ur algorithm is not bad comparing to -yellowlemon- 给 yellowlemon 发送悄悄话 (47 bytes) () 02/13/2008 postreply 08:26:16

sort >= O(nlogn) -Jamesxu- 给 Jamesxu 发送悄悄话 (0 bytes) () 02/13/2008 postreply 08:28:12

yes, right. long time did not pick up algorithms book coz -yellowlemon- 给 yellowlemon 发送悄悄话 (91 bytes) () 02/13/2008 postreply 08:30:24

请您先登陆,再发跟帖!