随笔分类 - DFS
深搜实例
摘要:PAT(甲级)2019年秋季考试 7-3 Postfix Expression (25 分) 题目描述: Given a syntax tree (binary), you are supposed to output the corresponding postfix expression, wi
阅读全文
摘要:PAT(甲级)2019年秋季考试 7-1 Forever (20 分) 题目描述: "Forever number" is a positive integer A with K digits, satisfying the following constrains: the sum of all
阅读全文
摘要:PAT (Advanced Level) Practice 1119 Pre- and Post-order Traversals (30 分) 凌宸1642 题目描述: Suppose that all the keys in a binary tree are distinct positive
阅读全文
摘要:PAT (Advanced Level) Practice 1147 Heaps (30 分) 凌宸1642 题目描述: In computer science, a heap is a specialized tree-based data structure that satisfies the
阅读全文
摘要:PAT (Advanced Level) Practice 1143 Lowest Common Ancestor (30 分) 凌宸1642 题目描述: The lowest common ancestor (LCA) of two nodes U and V in a tree is the d
阅读全文
摘要:PAT (Advanced Level) Practice 1138 Postorder Traversal (25 分) 凌宸1642 题目描述: Suppose that all the keys in a binary tree are distinct positive integers.
阅读全文
摘要:PAT (Advanced Level) Practice 1130 Infix Expression (25 分) 凌宸1642 题目描述: Given a syntax tree (binary), you are supposed to output the corresponding inf
阅读全文
摘要:PAT (Advanced Level) Practice 1086 Tree Traversals Again (25 分) 凌宸1642 题目描述: An inorder binary tree traversal can be implemented in a non-recursive wa
阅读全文
摘要:PAT (Advanced Level) Practice 1102 Invert a Binary Tree (25 分) 凌宸1642 题目描述: The following is from Max Howell @twitter: Google: 90% of our engineers us
阅读全文
摘要:PAT (Advanced Level) Practice 1003 Emergency (25 分) 凌宸1642 题目描述: As an emergency rescue team leader of a city, you are given a special map of your cou
阅读全文
摘要:PAT (Advanced Level) Practice 1030 Travel Plan (30 分) 凌宸1642 题目描述: A traveler's map gives the distances between cities along the highways, together wi
阅读全文
摘要:codeup 习题--图的遍历-- 凌宸1642 问题A : 第一题 题目描述 : 该题的目的是要你统计图的连通分支数。 输入描述: 每个输入文件包含若干行,每行两个整数 i , j ,表示节点 i 和 j 之间存在一条边。 输出描述 输出每个图的联通分支数。 样例输入: 1 4 4 3
阅读全文
摘要:PAT (Advanced Level) Practice 1053 Path of Equal Weight (30 分) 凌宸1642 题目描述: Given a non-empty tree with root R, and with weight Wi assigned to each tr
阅读全文
摘要:BFS 广度搜索 入门典例 -- 凌宸1642 广度优先搜索 是以 广度 为 第一关键词 ,当碰到岔路口时,总是先依次访问从该岔道口能 直接到达 的 所有结点 ,然后再按这些结点被访问的顺序去依次访问它们能直接到达的所有结点,以此类推。广度优先搜索一般由 队列 实现,且总是按照 层次 的顺序进行遍历
阅读全文
摘要:DFS 深搜专题 入门典例 -- 凌宸1642 深度优先搜索 是一种 枚举所有完整路径以遍历所有情况的搜索方法 ,使用 递归 可以很好的实现 深度优先搜索。 1 最大价值 题目描述 有 n 件物品,每件物品的重量为 w[i] , 价值为 c[i] 。现在需要选出若干件物品放入一个容器为 V 的背
阅读全文

浙公网安备 33010602011771号