V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
test123
V2EX  ›  数学

求助一个算法问题

  •  
  •   test123 · Jan 31, 2013 · 6543 views
    This topic created in 4838 days ago, the information mentioned may be changed or developed.
    请问有没有可能在O(nlogn)时间里同时完成排序和累积求和?
    例如:
    输入 {5, 2, 1, 3, 4}, 排序后是{1, 2, 3, 4, 5}, 再累积求和后是{1, 3, 6, 10, 15}
    输出{1, 3, 6, 10, 15}.
    10 replies    1970-01-01 08:00:00 +08:00
    013231
        1
    013231  
       Jan 31, 2013   ❤️ 1
    O(nlogn) + O(n)還是O(nlogn).
    uoryon
        2
    uoryon  
       Jan 31, 2013   ❤️ 1
    可是尝试计数排序...但是对数据有些许限制
    laskuma
        3
    laskuma  
       Jan 31, 2013   ❤️ 1
    @uoryon 数据量小的时候计数排序没优势啊。 常数项太大了。
    1楼正解
    notonlysuccess
        4
    notonlysuccess  
       Jan 31, 2013   ❤️ 1
    @laskuma
    @013231 O(nlogn+n)不就是O(nlogn)....么
    laskuma
        5
    laskuma  
       Jan 31, 2013   ❤️ 1
    @notonlysuccess 1楼意思是O(nlogn) + O(n)(依然)还是O(nlogn)
    test123
        6
    test123  
    OP
       Feb 1, 2013
    多谢回复,数量级上去了之后nlogn跟nlogn+n差距也不小呀。
    txx
        7
    txx  
       Feb 1, 2013
    @test123 不会的...



    这么看 基本上可以忽略不计了
    66450146
        8
    66450146  
       Feb 1, 2013
    @test123 数量级越大 nlogn 和 nlogn + n 差距越小的吧。。。。
    ivanlw
        9
    ivanlw  
       Feb 21, 2013
    @txx 这个什么软件,好棒……能推荐下么?
    laskuma
        10
    laskuma  
       Feb 21, 2013
    @ivanlw OSX原生grapher
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 18:14 · PVG 02:14 · LAX 11:14 · JFK 14:14
    ♥ Do have faith in what you're doing.