Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we ca…
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2→1→5→6. Input Specification:…
Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤) which is the total number of…
Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For exampl…
PTA数据结构与算法题目集(中文)  7-37 模拟EXCEL排序 (25 分) 7-37 模拟EXCEL排序 (25 分)   Excel可以对一组纪录按任意指定列排序.现请编写程序实现类似功能. 输入格式: 输入的第一行包含两个正整数N(≤) 和C,其中N是纪录的条数,C是指定排序的列号.之后有 N行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,保证没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩([0, 100]内的整数)组成,相邻属性用1个空格隔开. 输出格式: 在…
PTA数据结构与算法题目集(中文)  7-35 城市间紧急救援 (25 分) 作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图.在地图上显示有多个分散的城市和一些连接城市的快速道路.每个城市的救援队数量和每一条连接两个城市的快速道路长度都标在地图上.当其他城市有紧急求助电话给你的时候,你的任务是带领你的救援队尽快赶往事发地,同时,一路上召集尽可能多的救援队. 输入格式: 输入第一行给出4个正整数N.M.S.D,其中N(2)是城市的个数,顺便假设城市的编号为0 ~ (:M是快速道路的条数…
链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805070971912192 题目: 一棵二叉搜索树可被递归地定义为具有下列性质的二叉树:对于任一结点, 其左子树中所有结点的键值小于该结点的键值: 其右子树中所有结点的键值大于等于该结点的键值: 其左右子树都是二叉搜索树. 所谓二叉搜索树的“镜像”,即将所有结点的左右子树对换位置后所得到的树. 给定一个整数键值序列,现请你编写程序,判断这是否是对一棵二叉搜索树或其…
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1→6→5→4; if K = 4, you must output 4→3→2→1→5→6. Input Specificat…
01-复杂度2 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+1​​, ..., N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has…
大家好,我是Mac Jiang,非常高兴您能在百忙之中阅读我的博客!这个专题我主要讲的是Coursera-台湾大学-機器學習基石(Machine Learning Foundations)的课后习题解答.笔者是在学习了Ng的Machine Learning之后開始学习这门课程的.但还是感觉收获颇丰.Ng的课程主要站在计算机专业的角度.教你怎样使用机器学习.注重方法而不是数学推导,是一门非常好的新手教程.而林轩田老师的机器学习基石是站在统计分析角度,证明机器学习算法为什么要这么做,更加注重于理论的…