微软研发工程师笔试卷A

来源:互联网 发布:vb中sgn是什么意思 编辑:程序博客网 时间:2024/05/22 04:52

1 Initialize integer i as 0, what's the value of i after the following operation?

i += i > 0 ? i++ : i--;

-2
-1
0
1
2
//
>的优先级高于 +=    i = i + (i > 0) ? i++ : i--;
 i = i + 0 ? i++ : i--;
这是一个赋值表达式,赋值表达式的返回值是表达式的值,i+0还等于0,
因此 ? 前面整体返回0,即false,因此执行 i--
所以最后i的值是 -1

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

3 How many times is f() called when calculating f(10)?
int f(int x) {    if(x <= 2)        return 1;    return f(x - 2) + f(x - 4) + 1;}
14
18
20
24
None of the above
//15

4 Asume you have an object to describe customer data:{ 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?
(1) Tree with Hash(100 bucket) at leaves(2) Tree with linked list at leaves.
(1) Tree with linked list at leaves(2) Array.
(1) Tree with linked list at leaves(2) Hash(10,000 buckets)
(1) Sort linked list(2) Array.

5 The best time complexity of quick sort algorithm is:
O(lgn)
O(n)
O(nlgn)
O(n*n)

6 Which of the following method(s) CANNOT be used for Text-encryption:
MD5
RSA
RC4
DES
//选择A,解析:MD5是不可逆加密,不可以用来加密文本,DES和RC4是对称加密,RSA是不对称加密,都可以用于文本加密。

7 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
30
45
50
55

8 A table CANNOT have one or more of the following index configurations.
No indexes
A clustered index
clustered index and many non-clustered indexes
Many clustered index

//聚集索引:该索引中键值的逻辑顺序决定了表中相应行的物理顺序,非聚集索引:数据存储在一个地方,索引存储在另一个地方,索引带有指针指向数据的存储位置。


9 下面哪些调用转换支持可变长度参数
cdecl
stdcall
pascal
fastcal

10 下面程序执行结果:
using namespace std;class A{    public:        virtual void f() { cout << "A::f() "; }        void f() const { cout << "A::f() const "; }};class B : public A {    public:        void f() { cout << "B::f() "; }        void f() const { cout << "B::f() const "; }};void g(const A* a) {    a->f();}int main(int argc, char *argv[]) {    A* p = new B();    p->f();    g(p);    delete(p);    return 0;}
B::f() B::f() const
B::f() A::f() const
A::f() B::f() const
A::f() A::f() const

11 Windows 下进程和线程的描述,哪些是对的:
操作系统的一个程序必须有一个进程,但是不必须有一个线程
进程有自己的栈空间,而线程只共享父进程的栈空间
线程必从属于一个进程
线程可以更改从属的进程

12 下面代码段的运行结果(环境linux平台, g++编译器):
int main() {    int x = 10;    int y = 10;    x = x++;    y = ++y;    printf("%d %d", x, y);    return 0;}
10 10
10 11
11 10
11 11

13 C# 或是 Java 程序段的结果: int[][] array = new int[3][]{ new int[3]{5,6,2}, new int[5]{6,9,7,8,3}, new int[2]{3,2} }; array[2][2] 返回()
9
6
2
溢出

14 下面程序的执行结果:
class A{    public:        long a;};class B : public A {    public:        long b;};void seta(A* data, int idx) {    data[idx].a = 2;}int main(int argc, char *argv[]) {    B data[4];    for(int i=0; i<4; ++i){        data[i].a = 1;        data[i].b = 1;        seta(data, i);    }    for(int i=0; i<4; ++i){         std::cout << data[i].a << data[i].b;    }    return 0;}
11111111
12121212
11112222
21212121
22221111
//因为seta函数参数为类A的指针,所以每当指针+1,指向的是下一个long类型数据,不是data[1].a,而是data[0].b的地址,所以前面4个数据被赋值为2

15 1000 个瓶子中有一瓶毒药,一只老鼠吃到毒药一周之内会死,如果要在一周之内检测出有毒药的一瓶,问至少需要几只老鼠?
8
10
32
999

16 Which statement(s) is(are) correct about thread and process?Select all that apply.
Threads share the same address space of the parent process;Processes share the same address space of the parent process.
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.Multiple threads mar cause deadlock,while multiple processes won't cause deadlock.
Threads can directly communicate with other threads of its process;Processes must use inter-process communication to communicate with sibling processes.
None of the above.

17 Which statement(s) below regarding TCP(Transmission Control Protocol) is(are) correct? Select all that apply.
TCP provides a way for applications to send encapsulated IP datagrams and send them without having to establish a connection.
TCP supports multicasting.
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.
TCP handles package loss reliably.

None of the above.

18 When a dll is loaded into memory, which part(s) can be shared between processes?
code segment
static variable global variable
external difinitions and references for linking
BSS segment

19 In which case(s) would you use an outer join?
The table being joined have NOT NULL columns.
The table being joined have only matched data.
The columns being joined have NULL values.
The table being joined have only unmatched data.
The table being joined have both matched and unmatched data.


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


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

[w][w][w][microsoft]+[com]+
\w*

22 Which of the following can be referred to as attack method(s)? Select all that apply
Vulnerability scan
SQL Injection
Drive-by downloading
Brute force


23 Which of the following is(are) true about providing security to database servers ? Select all that apply
Do not host a database server on the same server as your web server
Do not host a database server on a server based system
Do not use blank password for SA account
Employ a centralized administration model


24 链表和数组的区别。
在有序的情况下搜索
插入和删除
随机访问

数据存储类型

25 下面说法哪些正确:
const int a; // a 是常数
int const a; // a 是常数
int const *a; // a 指向常数的指针

const int *a; // a 是常指针
int const *a; // a 是常指针
0 0
原创粉丝点击