自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

NJU_ChopinXBP的博客

https://github.com/ChopinXBP

  • 博客(272)
  • 资源 (22)
  • 收藏
  • 关注

原创 基于共享内存的异步无锁IPC类库 Traffic-SHM 源码阅读

全文目录Trafic-SHM特点:一、内存映射二、内存对齐三、字节顺序四、数据结构五、并发控制六、关键代码内存映射类MappedFile数据结构类Queue元数据类Metadata数据块类Block块标识类ACK七、互斥原理github项目地址:https://github.com/peptos/traffic-shmTrafic-...

2019-11-25 13:24:55 618

原创 LeetCode 从零单刷个人笔记整理(持续更新)

更新至2019.4.19本人博客用于个人对知识点的记录和巩固。之前刷了《剑指Offer》,基本每道题都用两种语言过了一遍,比较用心地进行原理和方法的剖析,并且用几乎所有可行的方法进行了实现和调优,大多数题目都附上了测试用例,少数题目进行了一些升级和扩充。感兴趣的话可以看这里:#程序员面试必备#《剑指Offer》从零单刷个人笔记整理(66题全)刷完剑指Offer后下一步就是LeetCode了。下...

2019-04-19 15:28:29 3462 1

原创 《剑指Offer》从零单刷个人笔记整理(66题全)

github:https://github.com/ChopinXBP/JZOffer_Babel/《剑指Offer》以面试题为主,代码大都不长。比较适合两种人,第一种是新手入门,第二种是面前备战。我就是以新手的姿态来刷这本书的,每一道题先按自己的思路写一遍,然后尽可能尝试所有的方法实现并调优,然后再把感想和总结以博客的形式进行记录和分享。由于本人学习语言主Java,辅C++,所以每题...

2019-03-11 20:57:08 1531 1

原创 树莓派3B+ QT5 串口收发配置与用户程序开机自启方法图文教程

2018.9.6由于实验室项目需要处理数据并用串口进行发送,最后还要开机自启,专门鼓捣了一番。由于网上的方案随着树莓派本身版本变化而不适应,因此调试过程中也实在耗费了不少功夫。最有价值的调试方案还是官方的英文教程:Raspberry Pi 3 UART Boot Overlay Part Two,本文也是主要参照英文教程的方法进行调试,顺便附加了网上的一些其他经验。本文分为两部分:1.树莓...

2018-09-06 15:49:31 5564 2

原创 LeetCode(459):重复的子字符串 Repeated Substring Pattern(Java)

2021.1.22 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel如果s中包含重复的子字符串,那么说明s中至少包含两个子字符串,s+s至少包含4个字串,前后各去掉一位,查找s是否在新构建的字符串中。传送门:重复的子字符串Given a non-empty string check if it can be constructed by taking a substring of it and

2021-01-22 12:40:52 288 1

原创 LeetCode(402):移掉K位数字 Remove K Digits(Java)

2021.1.21 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel最小递增栈,每次替换栈顶比当前元素大的元素,直至k次。若替换完成之后k>0,从尾部移除。传送门:移掉K位数字Given a non-negative integer num represented as a string, remove k digits from the number so that the new nu

2021-01-21 10:32:49 313 3

原创 LeetCode(453):最小移动次数使数组元素相等 Minimum Moves to Equal Array Elements(Java)

2021.1.18 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel1.先对数组排序2.排序后,第1次更新除最大值nums[len-1]外的其余值,更新nums[i]-nums[0]次,使得nums[0]=nums[len-1]同为最小值3.而nums[len-2]为新的最大值,第二次更新nums[len-2]-nums[0]次,使得nums[0]=nums[len-1]=nums[len-2]同

2021-01-18 13:46:12 257 1

原创 LeetCode(1361):验证二叉树 Validate Binary Tree Nodes(Java)

2021.1.17 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel直接的思路是借助哈希表+DFS验证二叉树的正确性。1.同一结点不能有两个父节点2.有且仅有一个根节点3.结点中不存在环高级的一点的方法可以借助图论:叶子结点个数 = 非叶子结点个数 + 1将所有-1看成叶子结点,也即:num(-1) = n + 1传送门:验证二叉树You have n binary tree

2021-01-17 11:27:03 188

原创 LeetCode(1360):日期之间隔几天 Number of Days Between Two Dates(Java)

2021.1.16 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel如果能依靠库函数Date和SimpleDateFormat可以很快解决问题。在不能依赖库函数的情况下,直接让两个日期做差需要考虑的因素太多。需要换个思路,分别求出两个日期距离1970年1月1日的天数,再将两个天数做差即可。传送门:日期之间隔几天Write a program to count the number of day

2021-01-16 13:01:58 225

原创 LeetCode(401):二进制手表 Binary Watch(Java)

2021.1.11 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel可以有两种思路:1.遍历所有符合要求的时间,统计二进制中1的个数,把个数等于num的时间筛选出来。2.回溯法遍历所有LED,记录符合条件的时间。传送门:二进制手表A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 L

2021-01-11 08:39:11 148

原创 LeetCode(1319):连通网络的操作次数 Number of Operations to Make Network Connected(Java)

2021.1.8 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel这是一道经典的并查集问题。关键点在于:每一个多余的连通集都需要一次操作进行消除,每一次操作需要一条多余的边。因此,可以先建立一个并查集,初始连通集个数为n。根据给定的connection来合并连通集,每一次失败的合并意味着有一条多余的边。计算多余的连通集个数result。如果result=0,说明已经全连通,直接返回0;如果l

2021-01-08 09:42:37 151 1

原创 LeetCode(342):4的幂 Power of Four(Java)

2021.1.6 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel不能用循环或者递归,意味着就得依靠奇技淫巧了。位运算方法11.该数是2的幂(仅有一位为1),用n&(n-1)可以验证(去掉最右边的1)2.这个1出现在奇数位上,用0x[5] = 0b[0101]可以验证位运算方法21.该数是2的幂(仅有一位为1),用n&(n-1)可以验证(去掉最右边的1)2.保证上一条的前提

2021-01-06 16:54:18 103

原创 LeetCode(1297):子串的最大出现次数 Maximum Number of Occurrences of a Substring(Java)

2021.1.4 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel利用滑动窗口的思路可以做,但是本题有一个思维技巧在于:只需要创建minSize的滑动窗口即可,如果长度为maxSize的子串出现了N次,那么长度为minSize的子串也会出现N次。而题目只要求最大数量的子串即可,没有长度要求。传送门:子串的最大出现次数Given a string s, return the maximum num

2021-01-04 11:13:26 248

原创 LeetCode(1296):划分数组为连续数字的集合 Divide Array in Sets of K Consecutive Numbers(Java)

2021.1.2 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel可以用TreeMap对数组中的元素进行排序并对个数进行记录,再依次检查。传送门:划分数组为连续数字的集合Given an array of integers nums and a positive integer k, find whether it’s possible to divide this array into set

2021-01-02 15:24:36 202

原创 LeetCode(601):体育馆的人流量 Human Traffic of Stadium(SQL)

2021.1.1 第一天,元旦快乐LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel括号题一般可以考虑用递归/回溯、栈等等,子串问题一般可以考虑用动态规划、滑动窗口等等。这道题结果要求输出多种组合,一般也就考虑用递归/回溯或者动态规划了。这道题的回溯思想如下:1.先计算不匹配的左右括号数leftError、rightError。2.开始递归回溯,返回条件是判断当前递归位置idx是否到达尾部,如果此时

2021-01-01 16:43:27 1152 1

原创 LeetCode(263 & 264):丑数 I II Ugly Number I II(Java)

2020.12.30 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel丑数I只需要验证是否为丑数即可,直接将其除净即可。丑数II要求返回指定顺位的丑数,可以采用归并的思想。用三指针指向下一个需要乘n(n=2/3/5)进行拓展的数字,相当于做一个三路归并。找出三个指针的最小元素,将指针后移。如果有多组指针的当前值都是min,指针都需要后移,保证 ugly 数组中不会加入重复元素。传送门:丑数W

2020-12-30 17:48:35 118

原创 LeetCode(262):行程和用户 Trips and Users(SQL)

2020.12.29 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:行程和用户Trips 表中存所有出租车的行程信息。每段行程有唯一键 Id,Client_Id 和 Driver_Id 是 Users 表中 Users_Id 的外键。Status 是枚举类型,枚举成员为 (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’)。

2020-12-29 17:41:31 164

原创 LeetCode(258):各位相加 Add Digits(Java)

2020.12.27 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel智力题规律很简单:数字为0时,结果为0;数字为9的倍数时,结果为9;其他情况下为除以9的余数。假设输入的数字是一个5位数字num,则num的各位分别为a、b、c、d、e。有如下关系:num = a * 10000 + b * 1000 + c * 100 + d * 10 + e即:num = (a + b + c + d

2020-12-27 20:49:53 112

原创 LeetCode(1292):元素和小于等于阈值的正方形的最大边长 Maximum Side Length of a Square(Java)

2020.12.24 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel原地动态规划 + 前缀和。遍历每一个位置ij时,将该位的数值置为从该位起左边的1的总个数,例如对于矩阵 [1,1,3,2], [1,1,4,3], [1,2,4,2]遍历结束后效果为: [1,2,5,7], [1,2,6,9], [1,3,7,9]为了统计正方形矩阵的面积,可以假定当前位置ij为正方

2020-12-24 16:12:52 161 1

原创 LeetCode(185):部门工资前三高的所有员工 Department Top Three Salaries(SQL)

2020.12.23 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:部门工资前三高的所有员工Employee 表包含所有员工信息,每个员工有其对应的工号 Id,姓名 Name,工资 Salary 和部门编号 DepartmentId 。+----+-------+--------+--------------+| Id | Name | Salary | DepartmentId |

2020-12-23 19:32:37 205

原创 LeetCode(168):Excel表列名称 Excel Sheet Column Title(Java)

2020.12.21 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel这题实质上是移位进制转换问题。xi*26^(i-1) + … + x3*26^2 + x2*26^1 + x1*26^0 = n每次num=n%26可以取出最低位的xi=num,n/=26可以去掉最低位的xi.但题目每个位的范围是1-26,而不是0-25。因此当num==26时需要进行修正,将n-1是使n不满足26的倍数,再

2020-12-21 16:17:20 135

原创 LeetCode(626):换座位 Exchange Seats(SQL)

2020.12.20 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:换座位小美是一所中学的信息科技老师,她有一张 seat 座位表,平时用来储存学生名字和与他们相对应的座位 id。其中纵列的 id 是连续递增的小美想改变相邻俩学生的座位。你能不能帮她写一个 SQL query 来输出小美想要的结果呢?示例:+---------+---------+| id | stu

2020-12-20 19:40:56 152

原创 LeetCode(1226):哲学家进餐 The Dining Philosophers(JUC)

2020.12.19 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:哲学家进餐Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed between each pair of adjacent philosophers.Each philosopher must alt

2020-12-19 20:35:46 372 1

原创 LeetCode(184):部门工资最高的员工 Reformat Department Table(SQL)

2020.7.8 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:部门工资最高的员工Employee 表包含所有员工信息,每个员工有其对应的 Id, salary 和 department Id。+----+-------+--------+--------------+| Id | Name | Salary | DepartmentId |+----+-------+------

2020-07-08 20:34:47 190

原创 LeetCode(1195):交替打印字符串 Fizz Buzz Multithreaded(JUC)

2020.7.7 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:交替打印字符串Write a program that outputs the string representation of numbers from 1 to n, however:If the number is divisible by 3, output “fizz”.If the number is divi

2020-07-07 14:10:25 331 1

原创 LeetCode(180):连续出现的数字 Consecutive Numbers(SQL)

2020.4.9 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:连续出现的数字编写一个 SQL 查询,查找所有至少连续出现三次的数字。+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | ...

2020-04-09 16:13:44 221

原创 LeetCode(178):分数排名 Rank Scores(SQL)

2020.2.23 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:分数排名编写一个 SQL 查询来实现分数排名。如果两个分数相同,则两个分数排名(Rank)相同。请注意,平分后的下一个名次应该是下一个连续的整数值。换句话说,名次之间不应该有“间隔”。+----+-------+...

2020-02-23 15:24:49 320

原创 LeetCode(432):全 O(1) 的数据结构 All O`one Data Structure(Java)

2020.2.22 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel这道题要求在常数的复杂度内对这个数据结构进行查找、增删、获取最值操作。而且相同count值还可能会同时存在多个key,因此需要结合多种数据结构进行。依靠一个HashMap、一个排序双向链表DoubleLinkedList,...

2020-02-22 15:42:12 392

原创 LeetCode(1117):H2O 生成 Building H2O(JUC)

2020.1.30 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:H2O 生成There are two kinds of threads, oxygen and hydrogen. Your goal is to group these threads to form wate...

2020-01-30 17:50:25 383

原创 LeetCode(177):第N高的薪水 Reformat Department Table(SQL)

2020.1.12 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:重新格式化部门表编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。+----+--------+| Id | Salary |+----+--------+| 1 | ...

2020-01-12 13:36:02 1385

原创 LeetCode(354):俄罗斯套娃信封问题 Russian Doll Envelopes(Java)

2020.1.10 . LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel这道题是之前 LeetCode(300):最长上升子序列 Longest Increasing Subsequence(Java) 的拓展问题。对所有信封排序之后,原题相当于是二维的最长上升子序列。思路主要有动态规划和动...

2020-01-10 22:07:46 421

原创 LeetCode(1277):统计全为 1 的正方形子矩阵 Count Square Submatrices with All Ones(Java)

2019.12.29 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel原地动态规划。遍历每一个位置ij时,将该位的数值置为从该位起左边的1的总个数,例如对于矩阵 [0,1,1,1], [1,1,1,1], [0,1,1,1]遍历结束后效果为: [0,1,2,3], ...

2019-12-29 12:34:41 635

原创 LeetCode(1179):重新格式化部门表 Reformat Department Table(SQL)

2019.12.27 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:重新格式化部门表部门表 Department:+---------------+---------+| Column Name | Type |+---------------+---------...

2019-12-27 21:51:15 562

原创 LeetCode(120):三角形最小路径和 Triangle(Java)

2019.12.22 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel自底向上的动态规划。建立dp数组,dp[j]代表当前层j位置的最小路径和,对于每一层i,自底向上有动态转移方程:dp[j] = triangle.get(i - 1).get(j) + Math.min(dp[j], d...

2019-12-22 15:16:11 234

原创 LeetCode(627):交换工资 Swap Salary(SQL)

2019.12.21 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:交换工资给定一个 salary 表,如下所示,有 m = 男性 和 f = 女性 的值。交换所有的 f 和 m 值(例如,将所有 f 值更改为 m,反之亦然)。要求只使用一个更新(Update)语句,并且没有中间...

2019-12-21 18:05:01 179

原创 LeetCode(60):第k个排列 Permutation Sequence(Java)

2019.12.19 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel之前有做过两道排列相关的题目:LeetCode(46):全排列 Permutations(Java)LeetCode(31):下一个排列 Next Permutation(Java)但是,单纯依靠之前的全排列方法做出...

2019-12-19 09:47:00 240

原创 LeetCode(1114):按序打印 Print in Order(JUC)

2019.12.17 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:按序打印Suppose we have a class:public class Foo { public void first() { print("first"); } public void se...

2019-12-17 19:55:44 250

原创 LeetCode(197):上升的温度 Rising Temperature(SQL)

2019.12.15 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:上升的温度给定一个 Weather 表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。+---------+------------------+--------------...

2019-12-15 12:32:21 394

原创 LeetCode(196):删除重复的电子邮箱 Delete Duplicate Emails(SQL)

2019.12.11 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:删除重复的电子邮箱编写一个 SQL 查询,来删除 Person 表中所有重复的电子邮箱,重复的邮箱里只保留 Id 最小 的那个。+----+------------------+| Id | Email ...

2019-12-11 13:54:01 248

原创 LeetCode(183):从不订购的客户 Customers Who Never Order(SQL)

2019.12.10 LeetCode 从零单刷个人笔记整理(持续更新)github:https://github.com/ChopinXBP/LeetCode-Babel传送门:从不订购的客户某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。Customers 表:+----+-------+| Id | Name...

2019-12-10 14:15:18 137

阿里技术年度精选合集

阿里技术年度精选合集,分上下两册《阿里技术年度精选(上)》、《阿里技术年度精选(下)》。

2018-07-31

2019程序员互联网公司最新面经(包含腾讯、百度、阿里等)

2019程序员互联网公司最新面经(包含腾讯、百度、阿里等)

2018-07-31

陈越、何钦铭-数据结构作业17:Huffman Codes哈夫曼编码

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 professor who gives the final exam problem on Huffman codes, I am encountering a big problem: the Huffman codes are NOT unique. For example, given a string "aaaxuaxz", we can observe that the frequencies of the characters 'a', 'x', 'u' and 'z' are 4, 2, 1 and 1, respectively. We may either encode the symbols as {'a'=0, 'x'=10, 'u'=110, 'z'=111}, or in another way as {'a'=1, 'x'=01, 'u'=001, 'z'=000}, both compress the string into 14 bits. Another set of code can be given as {'a'=0, 'x'=11, 'u'=100, 'z'=101}, but {'a'=0, 'x'=01, 'u'=011, 'z'=001} is NOT correct since "aaaxuaxz" and "aazuaxax" can both be decoded from the code 00001011001001. The students are submitting all kinds of codes, and I need a computer program to help me determine which ones are correct and which ones are not.

2018-05-17

陈越、何钦铭-数据结构作业16:Complete Binary Search Tree完全二叉搜索树

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 less than the node's key. The right subtree of a node contains only nodes with keys greater than or equal to the node's key. Both the left and right subtrees must also be binary search trees. A Complete Binary Tree (CBT) is a tree that is completely filled, with the possible exception of the bottom level, which is filled from left to right. Now given a sequence of distinct non-negative integer keys, a unique BST can be constructed if it is required that the tree must also be a CBT. You are supposed to output the level order traversal sequence of this BST.

2018-05-16

陈越、何钦铭-数据结构作业15:File Transfer并查集

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 to send a file from any computer on the network to any other?

2018-05-16

陈越、何钦铭-数据结构作业14:堆中的路径

将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。

2018-05-03

陈越、何钦铭-数据结构作业13:Root of AVL Tree平衡二叉树的根节点

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 more than one, rebalancing is done to restore this property. Figures 1-4 illustrate the rotation rules.Now given a sequence of insertions, you are supposed to tell the root of the resulting AVL tree.

2018-05-03

陈越、何钦铭-数据结构作业12:是否同一棵二叉搜索树

给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。

2018-04-20

陈越、何钦铭-数据结构作业11:Tree Traversals Again二叉树非递归遍历/栈遍历

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stack operations are: push(1); push(2); push(3); pop(); pop(); push(4); pop(); pop(); push(5); push(6); pop(); pop(). Then a unique binary tree (shown in Figure 1) can be generated from this sequence of operations. Your task is to give the postorder traversal sequence of this tree.

2018-04-18

陈越、何钦铭-数据结构作业10:List Leaves层次遍历叶节点

Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.

2018-04-09

陈越、何钦铭-数据结构作业9:树的同构

给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。现给定两棵树,请你判断它们是否是同构的。

2018-04-04

陈越、何钦铭-数据结构作业8:二叉搜索树的操作集

函数Insert将X插入二叉搜索树BST并返回结果树的根结点指针; 函数Delete将X从二叉搜索树BST中删除,并返回结果树的根结点指针;如果X不在树中,则打印一行Not Found并返回原树的根结点指针; 函数Find在二叉搜索树BST中找到X,返回该结点的指针;如果找不到则返回空指针; 函数FindMin返回二叉搜索树BST中最小元结点的指针; 函数FindMax返回二叉搜索树BST中最大元结点的指针。

2018-03-28

陈越、何钦铭-数据结构作业7:Pop Sequence出栈序列检验

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 can obtain 1, 2, 3, 4, 5, 6, 7 from the stack, but not 3, 2, 1, 7, 5, 6, 4.

2018-03-27

陈越、何钦铭-数据结构作业6:Reversing Linked List链表翻转

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.

2018-03-26

陈越、何钦铭-数据结构作业5:一元多项式的乘法与加法运算

设计函数分别求两个一元多项式的乘积与和。输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。

2018-03-20

陈越、何钦铭-数据结构作业4:在线查找算法求最大子列和,并返回最大子列和头尾元素

The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20. Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum subsequence.

2018-03-18

陈越、何钦铭-数据结构作业3:分治算法求最大子列和

“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。

2018-03-18

陈越、何钦铭-数据结构作业3:在线查找算法求最大子列和

“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。

2018-03-17

陈越、何钦铭-数据结构作业2:顺序链表合并

本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。L1和L2是给定的带头结点的单链表,其结点存储的数据是递增有序的;函数Merge要将L1和L2合并为一个非递减的整数序列。应直接使用原序列中的结点,返回归并后的带头结点的链表头指针。

2018-03-15

陈越、何钦铭-数据结构作业1:二分查找算法

L是用户传入的一个线性表,其中ElementType元素可以通过>、==、<进行比较,并且题目保证传入的数据是递增有序的。函数BinarySearch要查找X在Data中的位置,即数组下标(注意:元素从下标1开始存储)。找到则返回下标,否则返回一个特殊的失败标记NotFound。

2018-03-15

《C程序设计语言(第二版)》(中文)

《C程序设计语言(第二版)》(中文) (美)Brain W.Kernighan,Dennis M.Ritchie著 徐宝文 等翻译 机械工业出版社

2015-07-19

20套大学计算机C语言期末考试复习试题及答案

2010年20套大学计算机C语言期末考试复习试题及答案

2015-07-19

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除