摘要: 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 阅读(307) 评论(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 阅读(400) 评论(0) 推荐(0)
摘要: 问题引入 在做题的时候需要在堆区申请一个二维数组。所以当时很自然用这种方式来申请: int *a = new int[row][col]; ,编译器会报错。 首先,有个错误是我把二维数组名理解成一个一级指针。这是因为之前打印输出二维数组名的地址时,二维数组名就是一个指向二维数组第一个元素地址的指针, 阅读全文
posted @ 2021-04-01 22:20 onlyblues 阅读(2415) 评论(1) 推荐(1)
摘要: 是否同一棵二叉搜索树 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入 阅读全文
posted @ 2021-03-30 12:32 onlyblues 阅读(542) 评论(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 阅读(300) 评论(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 阅读(225) 评论(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 阅读(165) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2021-03-25 19:00 onlyblues 阅读(227) 评论(0) 推荐(0)
摘要: 遍历二叉树可以用递归的方法去实现,也可以用非递归的方法去实现。递归代码的好处是简洁,直观,最主要的还是递归的代码少,很快就可以写完。但我们知道,递归的调用会用到一个专门的栈,这个栈的深度是有限的,如果递归函数调用的次数很多,超过栈限制的深度,那么程序就会崩溃。这个时候就需要把递归的代码改为非递归了。 阅读全文
posted @ 2021-03-18 09:17 onlyblues 阅读(2111) 评论(0) 推荐(4)
摘要: 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, give 阅读全文
posted @ 2021-03-17 14:23 onlyblues 阅读(383) 评论(0) 推荐(0)
Web Analytics