- 博客(16)
- 收藏
- 关注
原创 洛谷 P3379 【模板】最近公共祖先(LCA)
题目描述如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先。输入输出格式输入格式:第一行包含三个正整数N、M、S,分别表示树的结点个数、询问的个数和树根结点的序号。接下来N-1行每行包含两个正整数x、y,表示x结点和y结点之间有一条直接连接的边(数据保证可以构成树)。接下来M行每行包含两个正整数a、b,表示询问a结点和b结点的最近公共祖先。输出格式:输出包...
2018-12-08 18:04:36 185
原创 归并排序非递归
#include<cstdio>#include<algorithm>#include<iostream>#include<cstring>#include<queue>#include<cmath>#include<set>#include<vector>using
2018-12-07 23:55:20 138
原创 快速排序
#include<cstdio>#include<algorithm>#include<iostream>#include<cstring>#include<queue>#include<cmath>#include<map>#include<set>#include&
2018-12-07 23:18:15 149
原创 1147 Heaps (30 分)
1147 Heaps (30 分)In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater ...
2018-12-07 21:00:31 151
原创 1098 Insertion or Heap Sort (25 分)(插入排序,堆排序)
1098 Insertion or Heap Sort (25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remo...
2018-12-07 20:45:18 658
原创 1145 Hashing - Average Search Time (25 分)
1145 Hashing - Average Search Time (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer key...
2018-12-07 17:45:44 101
原创 1078 Hashing (25 分)
1078 Hashing (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined ...
2018-12-07 17:32:14 186
转载 哈希之线性探测法
数据结构实验之查找七:线性之哈希表Time Limit: 1000MS Memory Limit: 65536KBProblem Description根据给定的一系列整数关键字和素数p,用除留余数法定义hash函数H(Key)=Key%p,将关键字映射到长度为p的哈希表中,用线性探测法解决冲突。重复关键字放在hash表中的同一位置。Input连续输入多组数据,每组输入数据第一行...
2018-12-07 17:25:00 478
原创 1066 Root of AVL Tree (25 分)
1066 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 differ by at most one; if at any time they differ by...
2018-12-07 16:38:05 175
原创 1123 Is It a Complete AVL Tree (30 分)
1123 Is It a Complete AVL Tree (30 分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they ...
2018-12-06 00:06:46 100
原创 1099 Build A Binary Search Tree (30 分)
1099 Build A Binary Search Tree (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys...
2018-12-05 23:36:24 191
原创 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 one test case. For each case, the first line gives a positive integer N (≤20) wh...
2018-12-05 23:28:03 391
原创 1064 Complete Binary Search Tree (30 分)(完全二叉搜索树)
1064 Complete Binary Search Tree (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with key...
2018-12-05 23:22:22 212
原创 1043 Is It a Binary Search Tree (25 分)(判断是不是二叉搜索树)
1043 Is It a Binary Search Tree (25 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys...
2018-12-05 23:14:51 316
原创 PAT甲级1119 Pre- and Post-order Traversals (30 分)
1119Pre- and Post-order Traversals(30 分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder t...
2018-12-05 21:23:11 213
原创 PAT甲级1120Tree Traversals(后序中序建树)
1020 Tree Traversals (25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order ...
2018-12-05 21:16:11 159
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人