2017年臘八節作文
時(shí)間2013-10-13;

地點(diǎn)復旦大學(xué)第四教學(xué)樓;
網(wǎng)申職位:軟件開(kāi)發(fā)工程師
因自己準備不是很充分,這次百度筆試考得不好,當炮灰了,繼續努力準備,加油!
1、 描述OSI(開(kāi)放系統互聯(lián)基本參考模型)七層結構。
2、 寫(xiě)出進(jìn)程間數據共享的方式,至少三種。
3、 描述TCP和UDP的區別,并各寫(xiě)出一個(gè)他們的上層協(xié)議。
程序與算法設計
1、 給出數組A={a_0,a_1,a_2,...,a_n}(n是可變的),打印出所有元素的組合
2、 數組A中任意兩個(gè)相鄰元素大小相差1,現給定這樣的數組A和目標整數t,找出t在數組A中的位置。
3、 求二叉樹(shù)的面積(高乘寬),高為二叉樹(shù)根到葉子節點(diǎn)的最大距離,寬為二叉樹(shù)最多的節點(diǎn)數。
#include
#include
/pic/p>
typedef struct BiTNode {
char data;
struct BiTNode *lChild, *rChild;
} BiTNode, *BiTree;
/pic/p>
typedef struct QNode {
BiTree data;
struct QNode *next;
} QNode, *Queue;
/pic/p>
typedef struct {
Queue front;
Queue rear;
} LinkedQueue;
/pic/p>
void createBiTree(BiTree &T) {
char c = getchar();
if(c == '*') {
T = NULL;
} else {
T = (BiTree)malloc(sizeof(BiTNode));
T->data = c;
createBiTree(T->lChild);
createBiTree(T->rChild);
}
}
/pic/p>
void printTree(BiTree T) {
if(T) {
printTree(T->lChild);
printf("%c ", T->data);
printTree(T->rChild);
}
}
/pic/p>
void initQueue(LinkedQueue &Q) {
Q.front = Q.rear = (Queue)malloc(sizeof(QNode));
Q.front->next = NULL;
}
/pic/p>
void enQueue(LinkedQueue &Q, BiTree T) {
Queue p = (Queue)malloc(sizeof(QNode));
p->data = T;
p->next = NULL;
Q.rear->next = p;
Q.rear = p;
}
/pic/p>
void deQueue(LinkedQueue &Q, BiTree &T) {
if(Q.rear == Q.front) {
T = NULL;
return ;
}
Queue p = Q.front->next;
T = p->data;
Q.front->next = p->next;
if(p == Q.rear) Q.rear = Q.front;
free(p);
}
int max(int a, int b) {
return a>b ? a: b;
}
/pic/p>
int treeDepth(BiTree T) {
if(T) {
return max(treeDepth(T->lChild), treeDepth(T->rChild)) + 1;
} else {
return 0;
}
}
/pic/p>
int maxLayer(BiTree T) {
if(!T) return 0;
LinkedQueue Q;
initQueue(Q);
int max=0, pre = 1, h = 0, i = 0;
BiTree p = T;
enQueue(Q, p);
while(Q.front != Q.rear) {
while(i < pre) {
deQueue(Q, p);
if(p->lChild) {
h ++;
enQueue(Q, p->lChild);
}
if(p->rChild) {
h ++;
enQueue(Q, p->rChild);
}
i ++;
}
if(h > max) {
max = h;
}
pre = h;
i = 0;
h = 0;
}
return max;
}
void main() {
BiTree T;
printf("請輸入二叉樹(shù)結點(diǎn)的值:\n");
createBiTree(T);
printf("中序遍歷的結果為:\n");
printTree(T);
int a, b;
a = treeDepth(T);
b = maxLayer(T);
printf("\n樹(shù)的深度為:%d\n", a);
printf("樹(shù)的各層結點(diǎn)數的最大值:%d\n", b);
printf("樹(shù)的繁茂度為:%d\n", a * b);
}
系統設計題
給了一個(gè)百度地圖的截圖,對于地圖上的某一點(diǎn),需要在地圖上標注該點(diǎn)的信息,將信息抽象成一個(gè)矩形,可以在該點(diǎn)的左邊標記,也可以在該點(diǎn)右邊標記。但是任意兩點(diǎn)標記后的矩形是不能有覆蓋的,否則刪除其中一個(gè)點(diǎn)
問(wèn)題1,現給一固定區域,有n個(gè)點(diǎn),設計一個(gè)算法,要求標記足夠多的點(diǎn)
問(wèn)題2,當點(diǎn)足夠多時(shí)候,算法會(huì )遇到性能瓶頸,需要對算法重新優(yōu)化。
【臘八節作文】相關(guān)文章:
臘八節作文06-29
【精選】臘八節作文04-25
[精選]臘八節作文01-15
臘八節作文(經(jīng)典)02-26
臘八節作文[經(jīng)典]01-25
臘八節的作文05-13
臘八節關(guān)于臘八粥作文10-25
有關(guān)臘八節的作文04-25
(優(yōu)秀)臘八節作文01-16
臘八節作文實(shí)用01-15