问题 问答题

假设有12个初始归并段,其长度分别为85,68,62,9,18,60,20,3,6,8,44,30;现要进行4路外部归并排序,试画出表示归并过程的最佳归并树,并计算树的带权路径长度WPL。

答案

参考答案:应加4-(12-1)mod(4-1)-1=1个虚段。
WPL=(3+6+8)×3+(9+18+20+30+44+60+62)×2+(68+85)×1=690

解析: 如何判定附加虚段的数目呢一般情况下,对k路归并而言,容易推导到。若(m-1)mod(k-1)=0,则不需要附加虚段,否则需要附加k-(m-1)rood(k-1)-1个虚段。换句话说,第一次归并为(m-1)rood(k-1)+1个路归并。其中mod表示求模运算符。

完形填空
完形填空。
     Most adults once studied at school, had classes and did homework every day. The same    1    is going
on at school now.     2    it seems that doing weekend homework is    3    problem for the modern students.
     All the students should agree that weekend homework should be abolished (取消). It′s    4    for them
studying at school five days a week. They have a lot of interests. With homework to do on Saturday and
Sunday, when can they find    5    to help around the house, go and see a football or basketball game or a
good film, join in family recreations (娱乐), or just have    6    at home? Because of these other activities,
the homework can not be finished until    7    . So their weekend homework is usually done in such a hurry
that on Monday the    8    teachers often threaten (威胁)to fail whole class of students because they know
nothing about the    9    . If there were no weekend homework for the students to do, they would be happy
to school on Monday    10     having a good rest and to learn what the teachers teach.
( )1. A. thing           
( )2. A. Also            
( )3. A. no             
( )4. A. not enough     
( )5. A. friends        
( )6. A. a rest         
( )7. A. Monday afternoon
( )8. A. pleased        
( )9. A. lesson         
( )10. A. until         
B. school            
B. But                 
B. another             
B. enough              
B. time                
B. an exam             
B. Saturday afternoon  
B. sorry               
B. games               
B. when              
C. class         
C. Still          
C. one          
C. no good                  
C. places         
C. a lesson  
C. Friday night  
C. unhappy       
C. interests     
C. before  
D. homework       
D. Though       
D. other        
D. no use         
D. money       
D. a picnic     
D. Sunday night 
D. not worried  
D. activities      
D. after   
多项选择题