14年微软

微软2014校园招聘笔试试题

分类: 剑指Offer   9819人阅读  评论(32)  收藏  举报
转载请标明出处,原文地址: http://blog.csdn.net/hackbuteer1/article/details/12190807
1、Which statement(s) is(are) correct about thread and process?Select all that apply.(5 Points)
A、Threads share the same address space of the parent process;Processes share the same address space of the parent process.
B、Changes to the main thread(cancellation,priority change,etc.) may affect the behavior of the other threads of the process; Changes to the parent process does not affect child processes.
C、Multiple threads mar cause deadlock,while multiple processes won't cause deadlock.
D、Threads can directly communicate with other threads of its process; Processes must use inter-process communication to communicate with sibling processes.
E、None of the above.


2、Which statement(s) below regarding TCP(Transmission Control Protocol) is(are) correct? Select all that apply.(5 Points)
A、TCP provides a way for applications to send encapsulated IP datagrams and send them without having to establish a connection.
B、TCP supports multicasting.
C、Port numbers below 1024 are called well-known ports and are reserved for standard services. For example,port 21 is reserved for FTP protocol, and port 25 is for SMTP protocol.
D、TCP handles package loss reliably.
E、None of the above.

3、Initialize integer i as 0, what's the value of i after the following operation?(5 Points)

[cpp]  view plain copy
  1. i += i > 0 ? i++ : i --;  

A、-2
B、-1
C、0
D、1
E、2

4、Which of the follwing sequence(s) could not be a postorder tree walk result of a binary search tree?(5 Points)
A、1,2,3,4,5
B、3,5,1,4,2
C、1,2,5,4,3
D、5,4,3,2,1

5、When a dll is loaded into memory, which part(s) can be shared between processes?(5 Points)
A、code segment
B、static variable
C、global variable
D、external difinitions and references for linking

E、BSS segment

6、How many times is f() called when calculating f(10)?(5 Points)
[cpp]  view plain copy
  1. int f(int x)  
  2. {  
  3.     if(x <= 2)  
  4.         return 1;  
  5.     return f(x - 2) + f(x - 4) + 1;  
  6. }  
A、14
B、18
C、20
D、24
E、None of the above.

7、Asume you have an object to describe customer data:(5 Points)
{
  ID(7 digit numeric)
  Family Name(string)
  Account Balance(currency)
}
If you have 500,000 Chinese customers records represented by instances of this object type , what set of data structures is best to get fast retrieval of customers (1) get IDs from Name and (2) get Name from ID?
A、(1) Tree with Hash(100 bucket) at leaves(2) Tree with linked list at leaves.
B、(1) Tree with linked list at leaves(2) Array.
C、(1) Tree with linked list at leaves(2) Hash(10,000 buckets)
D、(1) Sort linked list(2) Array.

8、Let's assume one type of cancer may be mis-diagnosed in the examination. 5 out of 100 people with this cancer will be diagnosed as not having it , and 1 out of 100 people without this cancer will be diagnosed as having it. We know the chance of getting this cancer is around 0.1%. One person was examined and diagnosed of having this cancer, which of the following value if the closest to the chance of is really having it?(5 Points)
A、90%
B、50%
C、30%
D、10%

9、In which case(s) would you use an outer join?(5 Points)
A、The table being joined have NOT NULL columns.

B、The table being joined have only matched data.
C、The columns being joined have NULL values.
D、The table being joined have only unmatched data.
E、The table being joined have both matched and unmatched data.

10、As shown in the graph , start from node B , traverse the nodes on a Depth-First Search(DFS) algorithm , which is(are) the possible traversa sequence(s)? Select all that apply.(5 Points)


A、BADECF
B、BADEFC
C、BCAFDE
D、BCFDEA
E、BFDECA

11、The best time complexity of quick sort algorithm is:(5 Points)
A、O(lgn)
B、O(n)
C、O(nlgn)
D、O(n*n)

12、Which of the following method(s) CANNOT be used for Text-encryption:(5 Points)
A、MD5
B、RSA
C、RC4
D、DES

MD5是不可逆加密,不可以用来加密文本,DES和RC4是对称加密,RSA是不对称加密,都可以用于文本加密。
13、To speed up data access , we build cache system. In one system , The L1 cache access time is 5 ns , the L2 cache access time is 50 ns and the memory access time is 400 ns. The L1 cache miss rate is 50% , the L2 cache miss rate is 10%. The average data access time of this system is:(5 Points)
A、5
B、30
C、45
D、50
E、55

14、Which is(are) valid function pointer declaration(s) below ? Select all that apply.(5 Points)
A、void* f(int);
B、int (*f)();
C、void (*f(int , void(*)(int)))(int);
D、void (*(*f)(int))();


15、Which of the following method(s) could be used to optimize the speed of a program ? (5 Points)
A、Improve memory access pattern to decrease cache misses.
B、Use special instructions(e.g. vector instructions) to replace compiler generated assembly code.
C、Change an algorithm from recursive implementation to iterative implementation.

D、Loop unwinding.

16、Which regular expression(s) matches the sentence "www.microsoft.com" ? (5 Points)
A、^\w+\.\w+\.\w+$
B、[w]{0,3}.[a-z]*.[a-z]+
C、.[c-w.]{3,10}[.][c-w.][.][a]|.+

D、[w][w][w][microsoft]+[com]+
E、\w*

17、In the image below , if the function is designed to multiply two positive numbers which line number in the image contains the biggest functional bug(assume no overflow)? (5 Points)


A、Line 1
B、Line 2
C、Line 3
D、Line 4
E、Line 5

18、Which of the following can be referred to as attack method(s)? Select all that apply.(5 Points)
A、Vulnerability scan
B、SQL Injection
C、Drive-by downloading

D、Brute force

19、A table CANNOT have one or more of the following index configurations.(5 Points)
A、No indexes
B、A clustered index
C、clustered index and many non-clustered indexes
D、Many clustered index


20、Which of the following is(are) true about providing security to database servers ? Select all that apply.(5 Points)
A、Do not host a database server on the same server as your web server
B、Do not host a database server on a server based system
C、Do not use blank password for SA account

D、Employ a centralized administration model

第二部分测试时间为60分钟,满分50分。请务必在回答问题前仔细阅读变成题目。您可以选用C、C++、C#或者Java 其中任何一种编程语言,并且保证您的代码可以正确编译和有正确的结果。另外,请一定要注意您的代码的质量。
21、Given a singly linked list L: (L0 , L1 , L2...Ln-1 , Ln). Write a program to reorder it so that it becomes(L0 , Ln , L1 , Ln-1 , L2 , Ln-2...).

[cpp]  view plain copy
  1. struct Node  
  2. {  
  3.     int val_;  
  4.     Node* next;  
  5. };  
Notes:
1、Space Complexity should be O(1) 
2、Only the ".next" field of a node is modifiable.
代码:

[cpp]  view plain copy
  1. //转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/12190807  
  2. struct Node  
  3. {    
  4.     int val_;    
  5.     Node* next;    
  6. };  
  7. Node* reverse_list(Node* phead)   //链表反转  
  8. {  
  9.     Node *temp ,*curr , *pre , *reverse_head;  
  10.     pre = NULL;  
  11.     curr = phead;  
  12.     while(curr->next)  
  13.     {  
  14.         temp = curr->next;  
  15.         curr->next = pre;  
  16.         pre = curr;  
  17.         curr = temp;  
  18.     }  
  19.     curr->next = pre;  
  20.     reverse_head = curr;  
  21.     return reverse_head;  
  22. }  
  23.   
  24. Node* Merge(Node* slow , Node* fast)  
  25. {  
  26.     if(fast == NULL)  
  27.         return slow;  
  28.     if(slow == NULL)  
  29.         return fast;  
  30.     Node *head , *result;  
  31.     result = NULL;  
  32.     int i = 0;  
  33.     while(slow && fast)  
  34.     {  
  35.         if(0 == i)  
  36.         {  
  37.             if(NULL == result)  
  38.             {  
  39.                 head = result = slow;  
  40.                 slow = slow->next;  
  41.             }  
  42.             else  
  43.             {  
  44.                 result->next = slow;  
  45.                 slow = slow->next;  
  46.                 result = result->next;  
  47.             }  
  48.         }  
  49.         else  
  50.         {  
  51.             if(NULL == result)  
  52.             {  
  53.                 head = result = fast;  
  54.                 fast = fast->next;  
  55.             }  
  56.             else  
  57.             {  
  58.                 result->next = fast;  
  59.                 fast = fast->next;  
  60.                 result = result->next;  
  61.             }  
  62.         }  
  63.         i ^= 1;  
  64.     }//while  
  65.     if(slow)  
  66.     {  
  67.         result->next = slow;  
  68.     }  
  69.     if(fast)  
  70.     {  
  71.         result->next = fast;  
  72.     }  
  73.     return head;  
  74. }  
  75.   
  76. Node* reorder_list(Node* phead)  
  77. {  
  78.     Node *r_head , *slow , *fast;  
  79.     r_head = slow = fast = phead;  
  80.     while(fast->next != NULL && fast->next->next != NULL)  
  81.     {  
  82.         slow = slow->next;  
  83.         fast = fast->next->next;  
  84.     }  
  85.     if(slow->next == NULL)  
  86.         return r_head;  
  87.     fast = slow->next;  
  88.     slow->next = NULL;  
  89.     slow = phead;  
  90.     fast = reverse_list(fast);      //链表的后半部分反转  
  91.     r_head = Merge(slow , fast);    //链表归并  
  92.     return r_head;  
  93. }  

转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/12190807

参考答案:(仅供参考,待修正)

1. BD

线程可以共享主进程的内存空间,但是栈拥有自己的栈以及寄存器,子进程不能共享主进程的内存地址,子线程可以被主线程影响,子进程独立于主进程。

线程或进程争夺资源都可以造成锁。线程由于可以共享主进程的内存地址,窃以为可以直接相互通信。进程要通过管道、信号量等来通信。

2.CD

tcp是传输协议,不含有ip地址信息,只有端口信息。tcp支持广播。1024以下的端口号为知名端口号,其中21为ftp,23为telnet,25为smtp,80为http。

tcp提供可靠的传输,会处理丢包。正规的资料都说tcp不支持组播,B不对。网上有个帖子说jgroup可以让tcp支持组播,貌似是邪门歪道?

3.B

这个应该没啥疑问吧。

4.B

后续遍历序列,必须保证最后一个数能把前面的分为两部分,左边都比它小,右边都比它大。

5.AD

群里大神说是AD,对dll调用不很有把握。窃以为是只能共享代码文本跟文件描述符。

6.A

画个二叉树,数了数是14.

7.B

名字可能重复,编号不会重复。查找名字用二叉查找树,找到节点后,会有若干个编号,所以每个节点存一个单链表。

如果查找名字,编号是无重复的,有50万个,10000个桶不够用啊,觉得用数组更直接。

8.D

贝叶斯概率公式。

@软件-北京-hdfx 指出问题的易错点,并纠正为D。

9.CDE

外连接可以将未匹配的字段显示出来。也可以显示NULL字段。

10.BDE

深搜必须无路可走才能回退。

11.C

无疑义吧。

12.A

谢谢留言的指教,大家可以看留言为什么选A。

13.D

概率公式,求期望。

14.BD

无疑义吧。

@BUAA-CS-仲唐  指出c是返回值为函数指针且参数有函数指针的函数。

15.ABCD

减少高速缓存的丢页率、将递归转化为循环结构都能加快程序运行。

@北邮-电子-米 循环展开是一种古老的优化方法,在特别追求效率的程序中(如游戏)仍能见到踪迹。故应该选上d。

 @BUAA-CS-仲唐 指出  b是sse2之类的优化 也应该选 b

16.ABC

\w  代表 a-z A-Z 0-9

^ 代表 开头 $ 代表结尾  

\. 代表字符 .

.  代表任意一个字符( 除了 \n)

| 代表或的意思

17.D

应为 C+=A

18.ABCD

四个选项分别为:a选项资料链接:http://wiki.answers.com/Q/What_is_a_Vulnerability_scan_attack ,sql注射攻击,偷渡下载攻击,暴力攻击。

19.D

聚集索引一个表只能有一个,因为聚集索引是影响物理存贮地址的。

20.ABCD

数据库要与服务器分离。sa用户要设置强力密码。应用集中管理模式,可以加强党的领导。

 

 

编程题参考答案:

 Node * Reverse(Node *  head)

{

     Node * aux=new Node,* result=aux;

      aux->next=NULL;

       while( head)

       {

         Node *  t=head->next;

   head->next=aux->next;

         aux->next=head;

         aux=head->next;

   head=t;

       }

       aux=result; result=result->next;

       delete aux;

       return result;

}

Node * f( Node * root)

{

      if(!root||!(root->next)) return root;

      Node * Sow=root->next, * Fast=Slow;

      int size=0;

      while(Fast->next&&Fast->next->next)

     {  Slow=Slow->next; Fast=Fast->next->next; size++;}

     if(Fast->next==NULL) Fast=Slow->next;

     else Fast=Slow->next->next;

     Slow=root;

     Fast=Reverse(Fast);

     for(int i=0;i!=size;++i)

     {

         Node * t=Slow->next;

         Node * s=Fast->next;

         Slow->next=Fast;

          Fast->next=t;

          Slow=Fast->Next;

   Fast=s;

      }

  return root;

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值