原创 PAT - 1076 Forwards on Weibo (30 分) 圖的BFS遍歷

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other

原创 PAT甲級 - 1094 The Largest Generation (25 分) 樹+DFS

A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same ge

原创 PAT - 1034 Head of a Gang (30 分) 圖的DFS

One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A 

原创 PAT甲級 1007 Maximum Subsequence Sum (25 分)

  Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+

原创 PAT甲級 - 1079 Total Sales of Supply Chain (25 分) 樹+BFS

A supply chain is a network of retailers(零售商), distributors(經銷商), and suppliers(供應商)-- everyone involved in moving a p

原创 PAT甲級 - 1102 Invert a Binary Tree (25 分) 反轉二叉樹

  The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but

原创 PAT- 並查集-好朋友

並查集的重點是維護一個father數組,來表明各結點間的關係 【好朋友】 1. 問題描述: 有一個叫做“數碼世界”奇異空間,在數碼世界裏生活着許許多多的數碼寶貝,其中有些數碼寶貝之間可能是好朋友,並且數碼寶貝世界有兩條不成文的規定: 第

原创 1053 Path of Equal Weight (30 分)

Given a non-empty tree with root R, and with weight W​i​​ assigned to each tree node T​i​​. The weight of a path from 

原创 PAT - A1043 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 subtre

原创 PAT甲級1105 Spiral Matrix (25 分) 模擬

  This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spir

原创 PAT甲級 - 1003 Emergency (25 分) Dijstra和BF算法

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scatt

原创 PAT甲級 - 1090 Highest Price in Supply Chain (25 分) 樹+DFS

A supply chain is a network of retailers(零售商), distributors(經銷商), and suppliers(供應商)-- everyone involved in moving a p

原创 PAT甲級 - 1030 Travel Plan (30 分)

A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now yo

原创 PAT - 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 subtre

原创 PAT甲級 - 1098 Insertion or Heap Sort (25 分) 堆排序,找規律

According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted out