参考答案和解析
参考答案:A
更多“I have to ()the profit from last month. ”相关问题
  • 第1题:

    I'll leave my bike____. I'll not need it for the time being.

    A、behind

    B、before

    C、back

    D、from


    正确答案:A

  • 第2题:

    template int SeqList::Insert(Type &x, int i) {

    if (i<0 || i>last+1 || last== MaxSize-1) return 0;

    else {

    Last++;

    for(int j=last;j

    data[i]=x;

    return 1;

    }

    }

    对于结点类型为SeqList的顺序表,以上算法的功能为:()


    正确答案::顺序表插入算法

  • 第3题:

    2、在顺序结构表示的线性表中,删除第i个元素(数组下标为i-1),需要把后面的所有元素都往前挪一位,相应的语句是: for (___________ ) PtrL->Data[j-1]=PtrL->Data[j]; 其中空缺部分的内容应该是

    A.j = i; j< = PtrL->Last; j++

    B.j =PtrL->Last; j>= i; j--

    C.j = i-1; j< = PtrL->Last; j++

    D.j =PtrL->Last; j>= i-1; j--


    O(n)

  • 第4题:

    阅读下列说明和C代码,回答问题 1 至问题 3,将解答写在答题纸的对应栏内。 【说明】 假币问题:有n枚硬币,其中有一枚是假币,己知假币的重量较轻。现只有一个天平,要求用尽量少的比较次数找出这枚假币。 【分析问题】 将n枚硬币分成相等的两部分: (1)当n为偶数时,将前后两部分,即 1...n/2和n/2+1...0,放在天平的两端,较轻的一端里有假币,继续在较轻的这部分硬币中用同样的方法找出假币: (2)当n为奇数时,将前后两部分,即1..(n -1)/2和(n+1)/2+1...0,放在天平的两端,较轻的一端里有假币,继续在较轻的这部分硬币中用同样的方法找出假币;若两端重量相等,则中间的硬币,即第 (n+1)/2枚硬币是假币。 【C代码】 下面是算法的C语言实现,其中: coins[]: 硬币数组 first,last:当前考虑的硬币数组中的第一个和最后一个下标 include <stdio.h> int getCounterfeitCoin(int coins[], int first,int last) { int firstSum = 0,lastSum = 0; int ì; If(first==last-1){ /*只剩两枚硬币*/ if(coins[first] < coins[last]) return first; return last; } if((last - first + 1) % 2 ==0){ /*偶数枚硬币*/ for(i = first;i <( 1 );i++){ firstSum+= coins[i]; } for(i=first + (last-first) / 2 + 1;i < last +1;i++){ lastSum += coins[i]; } if( 2 ){ Return getCounterfeitCoin(coins,first,first+(last-first)/2;) }else{ Return getCounterfeitCoin(coins,first+(last-first)/2+1,last;) } } else{ /*奇数枚硬币*/ For(i=first;i<first+(last-first)/2;i++){ firstSum+=coins[i]; } For(i=first+(last-first)/2+1;i<last+1;i++){ lastSum+=coins[i]; } If(firstSum<lastSum){ return getCounterfeitCoin(coins,first,first+(last-first)/2-1); }else if(firstSum>lastSum){ return getCounterfeitCoin(coins,first+(last-first)/2-1,last); }else{ Return( 3 ) } } }

    【问题一】 根据题干说明,填充C代码中的空(1)-(3) 【问题二】 根据题干说明和C代码,算法采用了( )设计策略。 函数getCounterfeitCoin的时间复杂度为( )(用O表示)。 【问题三】 若输入的硬币数为30,则最少的比较次数为( ),最多的比较次数为( )。


    正确答案:问题1
    (1)first+(last-first)/2 或(first+last)/2                 
    (2)firstSum<lastSum
    (3)first+(last-first)/2 或(first+last)/2
    问题2
    (4)分治法
    (5)O(nlogn)
    问题3
    (6)2     (7)4

  • 第5题:

    Questions 41-43 refer to the following e-mail.
    From: Brad Taylor
    To: Arlene Petronos
    Subject: Book reviews
    Date: Thurs, Nov 22 2007
    Dear Ms. Petronos,
    Allow me to congratulate you again on becoming part of our online magazine writing team. As you
    learned in an earlier communication, you will be writing reviews of recently published non-fiction
    books.
    By Monday next week, you will receive your() assignment parcel, which will contain copies of the

    A.almost
    B.late
    C.first
    D.last

    答案:C
    解析:

  • 第6题:

    在顺序结构表示的线性表中,删除第i个元素(数组下标为i-1),需要把后面的所有元素都往前挪一位,相应的语句是: for (___________ ) PtrL->Data[j-1]=PtrL->Data[j]; 其中空缺部分的内容应该是

    A.j = i; j< = PtrL->Last; j++

    B.j =PtrL->Last; j>= i; j--

    C.j = i-1; j< = PtrL->Last; j++

    D.j =PtrL->Last; j>= i-1; j--


    O(n)