C++ - Fastest way to add an item to a sorted array

后端 未结 8 1102
孤城傲影
孤城傲影 2021-01-23 05:18

I\'ve got a database with approximately 200 000 items, which is sorted by username. Now when I add an item to end of array and call my quick sort function to sort that array it

8条回答
  •  盖世英雄少女心
    2021-01-23 06:00

    int add(Container c, int r, int l, Unit t)
    {
        if(c[r]>t)
            return r;
        if(c[l]t)
              return add(c,m,l,t);
        if(c[m]

    It will probably give you the index you need to add...I hope it can help.It assumes you do not need to add when its already in.

提交回复
热议问题