原创 02-線性結構4 Pop Sequence (25分)

Sample Input: 5 7 5 1 2 3 4 5 6 7 3 2 1 7 5 6 4 7 6 5 4 3 2 1 5 6 4 3 7 2 1 1 7 6 5 4 3 2 Sample Output: YES NO NO YE

原创 03-樹2 List Leaves (25分)

Given a tree, you are supposed to list all the leaves in the order of top

原创 05-樹9 File Transfer (25分)

We have a network of computers and a list of bi-directional connections. E

原创 01-複雜度1 最大子列和問題 (20分)

#include <stdio.h> #include <stdlib.h> int maxsubsum(int *, int); int main(void) { int n, i = 0; int *a;

原创 02-線性結構3 Reversing Linked List (25分)

Sample Input: 00100 6 4 00000 4 99999 00100 1 12309 68237 6 -1 33218 3 00000 99999 5 6823712309 2 33218 Sample Output

原创 05-樹8 堆中的路徑 (25分)

輸入樣例: 5 3 46 23 26 24 10 5 4 3 輸出樣例: 24 23 10 46 23 10 26 10 #include<stdio.h> #include<stdlib.h> #define Mindata -1

原创 03-樹3 Tree Traversals Again (25分)

Sample Input: 6 Push 1 Push 2 Push 3 Pop Pop Push 4 Pop Pop Push 5 Push 6 Pop Pop Sample Output: 3 4 2 6 5 1 //由前序和中序建

原创 04-樹5 Root of AVL Tree (25分)

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node d

原创 04-樹4 是否同一棵二叉搜索樹 (25分)

給定一個插入序列就可以唯一確定一棵二叉搜索樹。然而,一棵給定的二叉搜索樹卻可以由多種不同的插入序列得到。例如分別按照序列{2, 1, 3}和{2,

原创 02-線性結構2 一元多項式的乘法與加法運算 (20分)

設計函數分別求兩個一元多項式的乘積與和。 輸入格式: 輸入分2行,每行分別先給出多項式非零項的個數,再以指數遞降方式輸入一個多項式非零項係數和指數(絕對值均爲不超過1000的整數)。數字間以空格分隔。 輸出格式: 輸出分2行,分別以指數遞

原创 02-線性結構1 兩個有序鏈表序列的合併 (15分)

02-線性結構1 兩個有序鏈表序列的合併   (15分) 本題要求實現一個函數,將兩個鏈表表示的遞增整數序列合併爲一個非遞減的整數序列。 函數接口定義: List Merge( List L1, List L2 ); 其中List結構定義

原创 03-樹1 樹的同構 (25分)

給定兩棵樹T1和T2。如果T1可以通過若干次左右孩子互換就變成T2,則我們稱兩棵樹是“同構”的。例如圖1給出的兩棵樹就是同構的,因爲我們把其中一棵樹的結點A、B、G的左右孩子互換後,就得到另外一棵樹。而圖2就不是同構的。 現給定兩棵樹,

原创 01-複雜度2 Maximum Subsequence Sum (25分)

#include <stdio.h> #include <stdlib.h> #define N 10000 int main(void) { int arr[N]; int n, i = 0; int *a = arr;

原创 11-散列2 Hashing (25分)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the

原创 11-散列1 電話聊天狂人 (25分)

給定大量手機用戶通話記錄,找出其中通話次數最多的聊天狂人。 輸入格式: 輸入首先給出正整數N(≤10^5),爲通話記錄條數。隨後N行,每行給出一條通話記錄。簡單起見,這裏只列出撥出方和接收方的11位數字構