PAT-2019年春季考试-甲级7-3 Telefraud Detection (25分) 7-3 Telefraud Detection (25分)Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are su...
PAT-2019年冬季考试-甲级7-4 Cartesian Tree (30分) A Cartesian tree is a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8...
[PAT甲] 2019年冬季考试7-1 Good in C (20分) 这个题目有点搞人Input Specification:Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .'s. Then a sentence is gi...
PAT(甲级)2019年秋季考试 7-4 Dijkstra Sequence (30分) 7-4 Dijkstra Sequence (30分)状态:ACedDijkstra’s algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from...
PAT(甲级) 2019秋季考试 7-3 Postifix Expression (25分) 7-3 Postfix Expression (25分)状态:ACedGiven a syntax tree (binary), you are supposed to output the corresponding postfix expression, with parentheses reflecting the precedences of the operators.Input ...
PAT(甲级)2019年秋季考试 7-2 Merging Linked Lists (25分) 7-2 Merging Linked Lists (25分)状态:ACedGiven two singly linked lists L1=a1→a2 →⋯→an−1→an and L2=b1→b2→⋯→bm−1→bm . If n≥2m, you are supposed to reverse and merge the shorter one into the longer ...
PAT(甲级)2019年秋季考试 7-1 Forever (20分) 7-1 Forever (20分)“Forever number” is a positive integer A with K digits, satisfying the following constrains:the sum of all the digits of A is m;the sum of all the digits of A+1 is n; andthe great...
FSM(有限状态机) 有限状态机的实现#include <stdio.h>#include <ctype.h>#include <string.h>#define START 0#define STOP 2#define BUILD_ID 3#define BUILD_NUM 4#define IDENTIFER 5#define NUMBER 6#define...
[LeetCode - tree] 662. Maximum Width of Binary Tree 662. Maximum Width of Binary TreeGiven a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the sam
[LeetCode - tree]687. Longest Univalue Path 687. Longest Univalue PathGiven a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of pat
Graph Practise 这里记录一下最近写的关于图的东西,图还是比较难的,这里有些可能不能用,但分开来都是对的#pragma once//带权//此文件不能直接使用#define MAXV 100#define INF 0x3fffffff#include <cstdio>#include <cstring>#include <vector>#include <queue>#include <utili
06-图3 六度空间(30 分) 06-图3 六度空间(30 分)“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。\ “六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标
06-图2 Saving James Bond - Easy Version(25 分) 06-图2 Saving James Bond - Easy Version(25 分)This time let us consider the situation in the movie “Live and Let Die” in which James Bond, the world’s most famous spy, was captured by a group of drug dea
05-树9 Huffman Codes(30 分) 05-树9 Huffman Codes(30 分)In 1953, David A. Huffman published his paper “A Method for the Construction of Minimum-Redundancy Codes”, and hence printed his name in the history of computer science. As a p
05-树8 File Transfer(25 分) 05-树8 File Transfer(25 分)We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible
04-树6 Complete Binary Search Tree(30 分) 04-树6 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
04-树5 Root of AVL Tree(25 分) 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 differ by at most one; if at any time they dif
04-树4 是否同一棵二叉搜索树(25 分) 04-树4 是否同一棵二叉搜索树(25 分)给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两