2017年臘八節作文
時間2013-10-13;

地點復旦大學第四教學樓;
網申職位:軟件開發工程師
因自己準備不是很充分,這次百度筆試考得不好,當炮灰了,繼續努力準備,加油!
1、 描述OSI(開放系統互聯基本參考模型)七層結構。
2、 寫出進程間數據共享的方式,至少三種。
3、 描述TCP和UDP的區別,并各寫出一個他們的上層協議。
程序與算法設計
1、 給出數組A={a_0,a_1,a_2,...,a_n}(n是可變的),打印出所有元素的組合
2、 數組A中任意兩個相鄰元素大小相差1,現給定這樣的數組A和目標整數t,找出t在數組A中的位置。
3、 求二叉樹的面積(高乘寬),高為二叉樹根到葉子節點的最大距離,寬為二叉樹最多的節點數。
#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("請輸入二叉樹結點的值:\n");
createBiTree(T);
printf("中序遍歷的結果為:\n");
printTree(T);
int a, b;
a = treeDepth(T);
b = maxLayer(T);
printf("\n樹的深度為:%d\n", a);
printf("樹的各層結點數的最大值:%d\n", b);
printf("樹的繁茂度為:%d\n", a * b);
}
系統設計題
給了一個百度地圖的截圖,對于地圖上的某一點,需要在地圖上標注該點的信息,將信息抽象成一個矩形,可以在該點的左邊標記,也可以在該點右邊標記。但是任意兩點標記后的矩形是不能有覆蓋的,否則刪除其中一個點
問題1,現給一固定區域,有n個點,設計一個算法,要求標記足夠多的點
問題2,當點足夠多時候,算法會遇到性能瓶頸,需要對算法重新優化。
【臘八節作文】相關文章:
臘八節作文06-29
【精選】臘八節作文04-25
[精選]臘八節作文01-15
臘八節作文(經典)02-26
臘八節作文[經典]01-25
臘八節的作文05-13
臘八節關于臘八粥作文10-25
有關臘八節的作文04-25
(優秀)臘八節作文01-16
臘八節作文實用01-15