0%

本题要求实现二分查找算法。

函数接口定义:

1
Position BinarySearch( List L, ElementType X );

其中List结构定义如下:

阅读全文 »

本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列

函数接口定义:

1
List Merge( List L1, List L2 );

其中List结构定义如下:

阅读全文 »

​ Given a sequence of K integers { N1, N2, …, N**K }. A continuous subsequence is defined to be { N**i, N**i+1, …, N**j } where 1≤ijK. 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.

阅读全文 »

​ 给定K个整数组成的序列{ N1, N2, …, N**K },“连续子列”被定义为{ N**i, N**i+1, …, N**j },其中 1≤ijK。“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。

​ 本题旨在测试各种不同的算法在各种数据情况下的表现。各组测试数据特点如下:

阅读全文 »

​ 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.
阅读全文 »

​ “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图所示。

阅读全文 »

​ 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 dealers. He was sent to a small piece of land at the center of a lake filled with crocodiles. There he performed the most daring action to escape – he jumped onto the head of the nearest crocodile! Before the animal realized what was happening, James jumped again onto the next big head… Finally he reached the bank before the last crocodile could bite him (actually the stunt man was caught by the big mouth and barely escaped with his extra thick boot).

阅读全文 »

​ 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.

阅读全文 »

树结构 - 大顶堆结构及其操作

结构 HeapStruct - MaxHeap
  1. 存放结点数据的数组Elements,从1位置开始存,0位置放哨兵
  2. 数组元素个数Size
  3. 数组最大容量Capacity
阅读全文 »

树结构 - 平衡二叉树结构及其操作

结构 AVLNode - Position - AVLTree
  1. 结点的数据Data
  2. 结点的左子树
  3. 结点的右子树
  4. 以当前结点为根的树高
阅读全文 »