原创 1135 Is It A Red-Black Tree (30 分) 判斷紅黑樹

1135 Is It A Red-Black Tree (30 分) There is a kind of balanced binary search tree named red-black tree in the data stru

原创 1102 Invert a Binary Tree (25 分) 翻轉二叉樹並輸出層次遍歷和中序遍歷

1102 Invert a Binary Tree (25 分) The following is from Max Howell @twitter: Google: 90% of our engineers use the softw

原创 1110 Complete Binary Tree (25 分) 判斷是否爲一棵完全二叉樹

Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains o

原创 1108 Finding Average (20 分) 字符串處理 sscanf和sprintf 格式化

The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complica

原创 1109 Group Photo (25 分) 結構體排序

Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following

原创 【MOOC-浙大數據結構】第十週的編程作業——排序

1.統計工齡 int a[105]; int main() { memset(a,0,sizeof a); int n,i,x; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",

原创 【MOOC-浙大數據結構】第十一週的編程作業——查找

1.電話聊天狂人 #include <stdio.h> #include <string.h> #include <string> #include <map> #include <vector> #include <queue> #i

原创 1138 Postorder Traversal (25 分) 給出先序和中序遍歷,求後序遍歷的第一個結點

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal seq

原创 1136 A Delayed Palindrome (20 分) 字符串相加

Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0≤a​i​​<10 fo

原创 11-散列4 Hashing - Hard Version (30 分) 散列表反向思維——用拓撲排序做

Given a hash table of size N, we can define a hash function H(x)=x%N. Suppose that the linear probing is used to solve

原创 中國大學MOOC-陳越、何欽銘-數據結構-2019夏期末考試

  1-1對一棵平衡二叉樹,所有非葉結點的平衡因子都是0,當且僅當該樹是完全二叉樹。(2分)   F 1-2n!是O(n​^n​​)的。 (2分)  T 1-3若用平方探測法解決衝突,則插入新元素時,若散列表容量爲質數,插入就一定可以成功

原创 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 p

原创 1043 Is It a Binary Search Tree (25 分) 建立BST對比前序輸出後序

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree

原创 二叉樹的最近公共祖先 (BSF和普通)

1.若二叉樹是一個搜索二叉樹 看這個!https://blog.csdn.net/TheWise_lzy/article/details/99610262 從樹的根節點開始和兩個節點作比較,如果當前節點的值比兩個節點的值都大,則這兩個節點

原创 1099 Build A Binary Search Tree (30 分) BST 中序遍歷構造樹然後輸出層次遍歷

1099 Build A Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a binary tree which has the