摘要: Saving James Bond - Hard Version This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous 阅读全文
posted @ 2021-04-13 19:14 onlyblues 阅读(175) 评论(0) 推荐(1) 编辑
摘要: Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous 阅读全文
posted @ 2021-04-10 19:05 onlyblues 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 前言 我们知道,要构造Huffman Tree,每次都要从堆中弹出最小的两个权重的节点,然后把这两个权重的值相加存放到新的节点中,同时让这两个节点分别成为新节点的左右儿子,再把新节点插入到堆中。假设节点个数为n,则重复n-1次后,最后堆中的那个节点就是Huffman Tree的根。 用堆实现当然可以 阅读全文
posted @ 2021-04-08 09:41 onlyblues 阅读(442) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2021-04-08 07:51 onlyblues 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 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 compu 阅读全文
posted @ 2021-04-05 13:07 onlyblues 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 问题引入 在做题的时候需要在堆区申请一个二维数组。所以当时很自然用这种方式来申请: int *a = new int[row][col]; ,编译器会报错。 首先,有个错误是我把二维数组名理解成一个一级指针。这是因为之前打印输出二维数组名的地址时,二维数组名就是一个指向二维数组第一个元素地址的指针, 阅读全文
posted @ 2021-04-01 22:20 onlyblues 阅读(1952) 评论(1) 推荐(1) 编辑
摘要: 是否同一棵二叉搜索树 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入 阅读全文
posted @ 2021-03-30 12:32 onlyblues 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2021-03-28 09:45 onlyblues 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2021-03-26 14:12 onlyblues 阅读(149) 评论(0) 推荐(0) 编辑
摘要: List Leaves 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 co 阅读全文
posted @ 2021-03-26 08:18 onlyblues 阅读(97) 评论(0) 推荐(0) 编辑
Web Analytics