数据结构 C 代码 2.1: 顺序表

顺序表是最常用的数据结构.

1. 代码 (2022 版)

先上代码, 再说废话.

#include <stdio.h>
#include <malloc.h>

#define LIST_MAX_LENGTH 10

/**
 * Linear list of integers. The key is data.
 */
typedef struct SequentialList {
    int actualLength;

    int data[LIST_MAX_LENGTH]; //The maximum length is fixed.
} *SequentialListPtr;

/**
 * Output the list.
 */
void outputList(SequentialListPtr paraList) {
    for(int i = 0; i < paraList->actualLength; i ++) {
        printf("%d ", paraList->data[i]);
    }// Of for i
    printf("\r\n");
}// Of outputList

/**
 * Output the memeory for the list.
 */
void outputMemory(SequentialListPtr paraListPtr) {
    printf("The address of the structure: %ld\r\n", paraListPtr);
    printf("The address of actualLength: %ld\r\n", &paraListPtr->actualLength);
    printf("The address of data: %ld\r\n", &paraListPtr->data);
    printf("The address of actual data: %ld\r\n", &paraListPtr->data[0]);
    printf("The address of second data: %ld\r\n", &paraListPtr->data[1]);
}// Of outputMemory

/**
 * Initialize a sequential list. No error checking for this function.
 * @param paraListPtr The pointer to the list. It must be a pointer to change the list.
 * @param paraValues An int array storing all elements.
 */
SequentialListPtr sequentialListInit(int paraData[], int paraLength) {
	SequentialListPtr resultPtr = (SequentialListPtr)malloc(sizeof(struct SequentialList));
	for (int i = 0; i < paraLength; i ++) {
		resultPtr->data[i] = paraData[i];
	}// Of for i
	resultPtr->actualLength = paraLength;
	
	return resultPtr;
}//Of sequentialListInit

/**
 * Insert an element into a sequential linear list.
 * @param paraListPtr The pointer to the list. It must be a pointer to change the list.
 * @param paraPosition The position, e.g., 0 stands for inserting at the first position.
 * @param paraValue The value to be inserted.
 */
void sequentialListInsert(SequentialListPtr paraListPtr, int paraPosition, int paraValue) {
    // Step 1. Space check.
    if (paraListPtr->actualLength >= LIST_MAX_LENGTH) {
        printf("Cannot insert element: list full.\r\n");
        return;
    }//Of if

    // Step 2. Position check.
    if (paraPosition < 0) {
        printf("Cannot insert element: negative position unsupported.");
        return;
    }//Of if
    if (paraPosition > paraListPtr->actualLength) {
        printf("Cannot insert element: the position %d is bigger than the list length %d.\r\n", paraPosition, paraListPtr->actualLength);
        return;
    }//Of if

    // Step 3. Move the remaining part.
    for (int i = paraListPtr->actualLength; i > paraPosition; i --) {
        paraListPtr->data[i] = paraListPtr->data[i - 1];
    }//Of for i

    // Step 4. Insert.
    paraListPtr->data[paraPosition] = paraValue;

    // Step 5. Update the length.
    paraListPtr->actualLength ++;
}// Of sequentialListInsert

/**
 * Test the insert function.
 */
void sequentialInsertTest() {
	int i;
	int tempArray[5] = {3, 5, 2, 7, 4};

    printf("---- sequentialInsertTest begins. ----\r\n");

	// Initialize.
    SequentialListPtr tempList = sequentialListInit(tempArray, 5);
    printf("After initialization, the list is: ");
	outputList(tempList);

	// Insert to the first.
    printf("Now insert to the first, the list is: ");
	sequentialListInsert(tempList, 0, 8);
	outputList(tempList);

	// Insert to the last.
    printf("Now insert to the last, the list is: ");
	sequentialListInsert(tempList, 6, 9);
	outputList(tempList);

	// Insert beyond the tail.
    printf("Now insert beyond the tail. \r\n");
	sequentialListInsert(tempList, 8, 9);
    printf("The list is:");
	outputList(tempList);

	// Insert to position 3.
	for (i = 0; i < 5; i ++) {
		printf("Inserting %d.\r\n", (i + 10));
		sequentialListInsert(tempList, 0, (i + 10));
		outputList(tempList);
	}//Of for i

    printf("---- sequentialInsertTest ends. ----\r\n");
}// Of sequentialInsertTest

/**
 * Delete an element from a sequential linear list.
 * @param paraListPtr The pointer to the list. It must be a pointer to change the list.
 * @param paraPosition The position, e.g., 0 stands for inserting at the first position.
 * @return The deleted value.
 */
int sequentialListDelete(SequentialListPtr paraListPtr, int paraPosition) {
    // Step 1. Position check.
    if (paraPosition < 0) {
        printf("Invalid position: %d.\r\n", paraPosition);
        return -1;
    }//Of if

    if (paraPosition >= paraListPtr->actualLength) {
        printf("Cannot delete element: the position %d is beyond the list length %d.\r\n", paraPosition, paraListPtr->actualLength);
        return -1;
    }//Of if

    // Step 2. Move the remaining part.
	int resultValue = paraListPtr->data[paraPosition];
    for (int i = paraPosition; i < paraListPtr->actualLength; i ++) {
        paraListPtr->data[i] = paraListPtr->data[i + 1];
    }//Of for i

    // Step 3. Update the length.
    paraListPtr->actualLength --;

	// Step 4. Return the value.
	return resultValue;
}// Of sequentialListDelete

/**
 * Test the delete function.
 */
void sequentialDeleteTest() {
	int tempArray[5] = {3, 5, 2, 7, 4};

    printf("---- sequentialDeleteTest begins. ----\r\n");

	// Initialize.
    SequentialListPtr tempList = sequentialListInit(tempArray, 5);
    printf("After initialization, the list is: ");
	outputList(tempList);

	// Delete the first.
    printf("Now delete the first, the list is: ");
	sequentialListDelete(tempList, 0);
	outputList(tempList);

	// Delete to the last.
    printf("Now delete the last, the list is: ");
	sequentialListDelete(tempList, 3);
	outputList(tempList);

	// Delete the second.
    printf("Now delete the second, the list is: ");
	sequentialListDelete(tempList, 1);
	outputList(tempList);

	// Delete the second.
    printf("Now delete the 5th, the list is: ");
	sequentialListDelete(tempList, 5);
	outputList(tempList);

	// Delete the second.
    printf("Now delete the (-6)th, the list is: ");
	sequentialListDelete(tempList, -6);
	outputList(tempList);

    printf("---- sequentialDeleteTest ends. ----\r\n");

	outputMemory(tempList);
}// Of sequentialDeleteTest

/**
 * Locate an element in the list.
 * @param paraListPtr The pointer to the list.
 * @param paraValue the indicated value.
 * @return The position of the value, or  -1 indicating not exists
 */
int locateElement(SequentialListPtr paraListPtr, int paraValue) {
	for (int i = 0; i < paraListPtr->actualLength; i ++) {
		if (paraListPtr->data[i] == paraValue) {
			return i;
		}// Of if
	}//Of for i

	return -1;
}// Of locateElement

/**
 * Get an element in the list.
 * @param paraListPtr The pointer to the list.
 * @param paraPosition The given position.
 * @return The position of the value, or  -1 indicating not exists
 */
int getElement(SequentialListPtr paraListPtr, int paraPosition) {
    // Step 1. Position check.
    if (paraPosition < 0) {
        printf("Invalid position: %d.\r\n", paraPosition);
        return -1;
    }//Of if

    if (paraPosition >= paraListPtr->actualLength) {
        printf("Cannot get element: the position %d is beyond the list length %d.\r\n", paraPosition, paraListPtr->actualLength);
        return -1;
    }//Of if

	return paraListPtr->data[paraPosition];
}// Of locateElement

/**
 * Clear elements in the list.
 * @param paraListPtr The pointer to the list.
 * @return The position of the value, or  -1 indicating not exists
 */
void clearList(SequentialListPtr paraListPtr) {
	paraListPtr->actualLength = 0;
}// Of clearList

/**
 The entrance.
 */
void main() {
	sequentialInsertTest();
	sequentialDeleteTest();
}// Of main

2. 运行结果

---- sequentialInsertTest begins. ----
After initialization, the list is: 3 5 2 7 4
Now insert to the first, the list is: 8 3 5 2 7 4
Now insert to the last, the list is: 8 3 5 2 7 4 9
Now insert beyond the tail.
Cannot insert element: the position 8 is bigger than the list length 7.
The list is:8 3 5 2 7 4 9
Inserting 10.
10 8 3 5 2 7 4 9
Inserting 11.
11 10 8 3 5 2 7 4 9
Inserting 12.
12 11 10 8 3 5 2 7 4 9
Inserting 13.
Cannot insert element: list full.
12 11 10 8 3 5 2 7 4 9
Inserting 14.
Cannot insert element: list full.
12 11 10 8 3 5 2 7 4 9
---- sequentialInsertTest ends. ----
---- sequentialDeleteTest begins. ----
After initialization, the list is: 3 5 2 7 4
Now delete the first, the list is: 5 2 7 4
Now delete the last, the list is: 5 2 7
Now delete the second, the list is: 5 7
Now delete the 5th, the list is: Cannot delete element: the position 5 is beyond the list length 2.
5 7
Now delete the (-6)th, the list is: Invalid position: -6.
5 7
---- sequentialDeleteTest ends. ----
The address of the structure: 10163840
The address of actualLength: 10163840
The address of data: 10163844
The address of actual data: 10163844
The address of second data: 10163848
Press any key to continue

3. 代码说明

  1. 用 typedef struct SequentialList 定义一个新的结构体, 即数据结构的数据部分. 这里使用了指向结构体的指针. 用 C 语言描述, 没办法避开指针, 还不如面对它! 简化起见, 这里的结构体具有固定的空间.
  2. outputList 用于打印该顺序表, 方便结果观察.
  3. outputMemory 可以观察数据在内存中的具体位置. 有了地址, 就知道了系统内部运行的机制. 这也是 C 语言的一个具大优点. 因此, C 语言被称为高级语言与汇编语言之间的“中级语言”. 要想成为高手, 就应该玩转内存. 要想成为东方不败, 就必须搞懂指针.
  4. sequentialListInit 用于初始化顺序表, 它具有很高的复用性.
  5. sequentialListInsert 是第一个重要的功能. 其中需要进行越界检查等.
  6. sequentialInsertTest 是 sequentialListInsert 的单元测试函数. 一个合格的程序员必须做完美的单元测试, 千万不要嫌麻烦. 这里多花 1 小时, 找 bug 的时间就会节约 10 小时.
  7. sequentialListDelete 是第二个重要的功能.
  8. sequentialDeleteTest 与 sequentialListDelete 配套.
  9. main() 里面的代码量越少越好.

4. 作业

  1. 抄代码并运行. 不包括 locateElement, getElement, clearList.
  2. 自己实现 locateElement, getElement, clearList 三个函数并与我的代码比较.
  3. 实现并测试书上其它相关函数如 PriorElement.
  4. 找出我代码的问题, 并在本贴下方留言.
  5. 将自己的工作写成贴子发布到 CSDN.

附 1: 2021 版代码

#include <stdio.h>
#include <malloc.h>

#define LIST_MAX_LENGTH 100

/**
 * The list contains only int values to keep it as simple as possible.
 */
struct SequentialList
{
    int maxLength;

    int actualLength;

    int data[LIST_MAX_LENGTH];
} SequentialList;

/**
 * Insert an element into the linear list. The new list should be sorted in ascendant order.
 */
void SequentialListInsert(struct SequentialList* paraListPtr, int paraValue)
{
    int i = 0;
    int tempPosition = paraListPtr->actualLength;

    //Space check.
    if(paraListPtr->actualLength == paraListPtr->maxLength)
    {
        printf("List full, cannot SequentialListInsert element.");
        return;
    }//Of if

    //Find the position.
    for(i = 0; i < paraListPtr->actualLength; i ++)
    {
        if (paraListPtr->data[i] > paraValue)
        {
            tempPosition = i;
            break;
        }//Of if
    }//Of for i

    //Move the remaining part.
    for(i = paraListPtr->actualLength; i > tempPosition; i --)
    {
        paraListPtr->data[i] = paraListPtr->data[i - 1];
    }//Of for i

    //Now SequentialListInsert.
    paraListPtr->data[tempPosition] = paraValue;

    //Update the length.
    paraListPtr->actualLength ++;
}//Of SequentialListInsert

/**
 * Output the list.
 */
void outputList(struct SequentialList *paraList)
{
    for(int i = 0; i < paraList->actualLength; i ++)
    {
        printf("%d ", paraList->data[i]);
    }//Of for i
    printf("\r\n");
}//Of outputList

/**
 * Output the memeory for the list.
 */
void outputMemory(struct SequentialList* paraListPtr)
{
    printf("The address of the structure: %ld\r\n", paraListPtr);
    printf("The address of maxLength: %ld\r\n", &paraListPtr->maxLength);
    printf("The address of actualLength: %ld\r\n", &paraListPtr->actualLength);
    printf("The address of data: %ld\r\n", &paraListPtr->data);
    printf("The address of actual data: %ld\r\n", &paraListPtr->data[0]);
}//Of output

/**
* Test functions.
*/
void main()
{
	int tempArray[5] = {3, 5, 2, 7, 4};
    printf("Hello, world!\r\n");

    struct SequentialList tempList1;
    struct SequentialList tempList2;
    struct SequentialList tempList3;

    tempList1.maxLength = 100;
    tempList1.actualLength = 0;

	for(int i = 0; i < 5; i ++)
	{
		printf("Inserting %d.\r\n", tempArray[i]);
		SequentialListInsert(&tempList1, tempArray[i]);
		outputList(&tempList1);
	}//Of for i

    outputMemory(&tempList1);

    printf("Now for other two lists.\r\n");
    outputMemory(&tempList2);
    outputMemory(&tempList3);
}//Of main

附 2. 2021 年学生的程序

完整的抽象数据类型, 完整的函数.
选用迪达尔的程序, 未作修改.

#include "stdio.h"
#include "windows.h"
#include "stdlib.h"

#define MAXSIZE 25     //顺序表最大长度

/*定义顺序表*/
typedef struct
{
    int data[MAXSIZE];
    int length;
} SeqList;

/*初始化顺序表*/
void InitList(SeqList *l)
{
    l->length = 0;
}

/*建立顺序表*/
int CreatList(SeqList *l, int a[], int n)
{
    if (n > MAXSIZE)
    {
        printf("空间不够,无法建立顺序表。\n");
        return 0;
    }
    for (int d = 0; d < n; d++)
    {
        l->data[d] = a[d];
    }
    l->length = n;
    return 1;
}

/*判空操作*/
int Empty(SeqList *l)
{
    if (l->length == 0)
        return 1;
    else
        return 0;
}

/*求顺序表长度*/
int Length(SeqList *l)
{
    return l->length;
}

/*遍历操作*/
void PrintList(SeqList *l)
{
    for (int i = 0; i < l->length; i++)
        printf("%d ", (l->data[i]));
}

/*按值查找*/
int Locate(SeqList *l,int x)
{
    for (int i = 0; i < l->length; i++)
    {
        if (l->data[i] == x)
        {
            return i + 1;
        }
        return 0;

    }
    return 1;
}

/*按位查找*/
int Get(SeqList *l, int x,int *ptr)
{
    //若查找成功,则通过指针参数ptr返回值
    if ( x <1 || x>l->length)
    {
        printf("查找位置非法,查找错误\n");
        return 0;
    }
    else
    {
        *ptr = l->data[x];
        return 1;
    }
}

/*插入操作*/
int Insert(SeqList *l, int i, int x)
{
    if (l->length > MAXSIZE)
    {
        printf("上溢错误!");
        return 0;
    }
    if (i<1 || i>l->length)
    {
        printf("插入位置错误!");
        return 0;
    }
    for (int k = l->length; k > i; k--)
    {
        l->data[k] = l->data[k - 1];
    }
    l->data[i] = x;
    l->length++;
    return 1;
}

/*删除操作*/
int Delete(SeqList *l, int i, int *ptr)
{
    if (l->length == 0)
    {
        printf("发生下溢错误,即将要访问顺序表之前的地址.\n");
        return 0;
    }
    if (i > l->length || i < 1)
    {
        printf("删除位置错误!\n");
        return 0;
    }
    *ptr = l->data[i - 1];//把要删除的数据返回
    for (int j = i; j < l->length; j++)
    {
        l->data[j - 1] = l->data[j];
    }
    l->length--;
    return 1;
}

/*修改操作*/
int Modify(SeqList *l, int i, int x)
{
    if (i > l->length || i < 1)
    {
        printf("位置错误!\n");
        return 0;
    }
    l->data[i] = x;
    return 1;
}

int main()
{
    int a[5] = {5,15,25,35,45 };
    int  i, x;
    SeqList list1;
    InitList(&list1);     //初始化顺序表
    if (Empty(&list1))
    {
        printf("初始化顺序表成功!\n");
    }
    printf("给顺序表赋值:5 15 25 35 45\n遍历并输出顺序表:\n");
    CreatList(&list1,a,5 );    //建立一个长度为5的线性表
    PrintList(&list1);        //遍历输出此顺序表
    printf("\n在第五位后插入一个500:\n");
    Insert(&list1, 5, 500);
    PrintList(&list1);
    if (Modify(&list1, 3, 250) == 1)
    {
        printf("\n把第三位改成250\n");
        PrintList(&list1);
    }
    if (Delete(&list1, 6, &x) == 1)
    {
        printf("\n把倒数第一位删除,删除的值是%d\n",x);
        PrintList(&list1);
    }
    system("pause");
    return 0;
}

欢迎留言!

  • 17
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 22
    评论
数据结构》(c语言版)是为“数据结构”课程编写的教材,也可作为学习数据结构及其算法的C程序设计的参数教材。学了数据结构后,许多以前写起来很繁杂的代码现在写起来很清晰明了. 本书的前半部分从抽象数据类型的角度讨论各种基本类型的数据结构及其应用;后半部分主要讨论查找和排序的各种实现方法及其综合分析比较。 全书采用类C语言作为数据结构和算法的描述语言。 本书概念述严谨,逻辑推理严密,语言精炼,用词达意,并有配套出版的《数据结构题集》(C语言版),便于教学,又便于自学。 本书后附有光盘。光盘内容可在DOS环境下运行的以类C语言描述的“数据结构算法动态模拟辅助教学软件,以及在Windows环境下运行的以类PASCAL或类C两种语言描述的“数据结构算法动态模拟辅助教学软件”。 目录: 第1章 绪论 1.1 什么是数据结构 1.2 基本概念和术语 1.3 抽象数据类型的现与实现 1.4 算法和算法分析 第2章 线性 2.1 线性的类型定义 2.2 线性顺序表示和实现 2.3 线性的链式示和实现 2.4 一元多项式的示及相加 第3章 栈和队列 3.1 栈 3.2 栈的应有和举例 3.3 栈与递归的实现 3.4 队列 3.5 离散事件模拟 第4章 串 4.1 串类型的定义 4.2 串的示和实现 4.3 串的模式匹配算法 4.4 串操作应用举例 第5章 数组和广义 5.1 数组的定义 5.2 数组的顺序表现和实现 5.3 矩阵的压缩存储 5.4 广义的定义 5.5 广义的储存结构 5.6 m元多项式的示 5.7 广义的递归算法第6章 树和二叉树 6.1 树的定义和基本术语 6.2 二叉树 6.2.1 二叉树的定义 6.2.2 二叉树的性质 6.2.3 二叉树的存储结构 6.3 遍历二叉树和线索二叉树 6.3.1 遍历二叉树 6.3.2 线索二叉树 6.4 树和森林 6.4.1 树的存储结构 6.4.2 森林与二叉树的转换 6.4.3 树和森林的遍历 6.5 树与等价问题 6.6 赫夫曼树及其应用 6.6.1 最优二叉树(赫夫曼树) 6.6.2 赫夫曼编码 6.7 回溯法与树的遍历 6.8 树的计数 第7章 图 7.1 图的定义和术语 7.2 图的存储结构 7.2.1 数组示法 7.2.2 邻接 7.2.3 十字链 7.2.4 邻接多重 7.3 图的遍历 7.3.1 深度优先搜索 7.3.2 广度优先搜索 7.4 图的连通性问题 7.4.1 无向图的连通分量和生成树 7.4.2 有向图的强连通分量 7.4.3 最小生成树 7.4.4 关节点和重连通分量 7.5 有向无环图及其应用 7.5.1 拓扑排序 7.5.2 关键路径 7.6 最短路径 7.6.1 从某个源点到其余各顶点的最短路径 7.6.2 每一对顶点之间的最短路径 第8章 动态存储管理 8.1 概述 8.2 可利用空间及分配方法 8.3 边界标识法 8.3.1 可利用空间的结构 8.3.2 分配算法 8.3.3 回收算法 8.4 伙伴系统 8.4.1 可利用空间的结构 8.4.2 分配算法 8.4.3 回收算法 8.5 无用单元收集 8.6 存储紧缩 第9章 查找 9.1 静态查找 9.1.1 顺序表的查找 9.1.2 有序的查找 9.1.3 静态树的查找 9.1.4 索引顺序表的查找 9.2 动态查找 9.2.1 二叉排序树和平衡二叉树 9.2.2 B树和B+树 9.2.3 键树 9.3 哈希 9.3.1 什么是哈希 9.3.2 哈希函数的构造方法 9.3.3 处理冲突的方法 9.3.4 哈希的查找及其分析 第10章 内部排序 10.1 概述 10.2 插入排序 10.2.1 直接插入排序 10.2.2 其他插入排序 10.2.3 希尔排序 10.3 快速排序 10.4 选择排序 10.4.1 简单选择排序 10.4.2 树形选择排序 10.4.3 堆排序 10.5 归并排序 10.6 基数排序 10.6.1 多关键字的排序 10.6.2 链式基数排序 10.7 各种内部排序方法的比较讨论 第11章 外部排序 11.1 外存信息的存取 11.2 外部排序的方法 11.3 多路平衡归并的实现 11.4 置换一选择排序 11.5 最佳归并树 第12章 文件 12.1 有关文件的基本概念 12.2 顺序文件 12.3 索引文件 12.4 ISAM文件和VSAM文件 12.4.1 ISAM文件 12.4.2 VSAM文件 12.5 直接存取文件(散列文件) 12.6 多关键字文件 12.6.1 多重文件 12.6.2 倒排文件 附录A 名词索引 附录B 函数索引 参考书目
作 者:严蔚敏 李冬梅 吴伟民 出版时间:2011-2-1 0:00:00 [1] 字 数:398千字 责任编辑:蒋亮 页 数:236页 开 本:16 ISBN书号:978-7-115-23490-2 所属分类:本科 >> 计算机类 >> 数据结构与算法 所属丛书:21世纪高等学校计算机规划教材——名家系列 定 价:¥28.00元 第1章 绪论 1 1.1 数据结构的研究内容 1 1.2 基本概念和术语 3 1.2.1 数据、数据元素、数据项和数据对象 3 1.2.2 数据结构 4 1.2.3 数据类型和抽象数据类型 6 1.3 抽象数据类型的示与实现 7 1.4 算法和算法分析 11 1.4.1 算法的定义及特性 11 1.4.2 评价算法优劣的基本标准 11 1.4.3 算法的时间复杂度 12 1.4.4 算法的空间复杂度 14 1.5 小结 15 习题 16 第2章 线性 18 2.1 线性的类型定义 18 2.1.1 线性的定义和特点 18 2.1.2 线性的抽象数据类型定义 18 2.2 线性顺序表示和实现 19 2.2.1 线性的顺序存储示 19 2.2.2 顺序表中基本操作的实现 20 2.3 线性的链式示和实现 24 2.3.1 单链的定义和示 24 2.3.2 单链基本操作的实现 26 2.3.3 循环链 31 2.3.4 双向链 32 2.4 线性的应用 34 2.4.1 一般线性的合并 34 2.4.2 有序的合并 35 2.4.3 一元多项式的示及相加 37 2.5 小结 40 习题 41 第3章 栈和队列 44 3.1 栈 44 3.1.1 栈的类型定义 44 3.1.2 顺序栈的示和实现 45 3.1.3 链栈的示和实现 47 3.2 栈的应用 48 3.2.1 数制转换 49 3.2.2 括号匹配的检验 49 3.2.3 达式求值 51 3.3 栈与递归 54 3.3.1 采用递归算法解决的问题 54 3.3.2 递归过程与递归工作栈 57 3.3.3 递归算法的效率分析 59 3.3.4 将递归转换为非递归的方法 60 3.4 队列 61 3.4.1 队列的类型定义 61 3.4.2 循环队列——队列的顺序表示和实现 62 3.4.3 链队——队列的链式示和实现 65 3.5 队列的应用 67 3.6 小结 69 习题 69 第4章 串、数组和广义 73 4.1 串 73 4.1.1 串的类型定义 73 4.1.2 串的存储结构 75 4.1.3 串的模式匹配算法 76 4.2 数组 83 4.2.1 数组的类型定义 83 4.2.2 数组的顺序存储 84 4.2.3 特殊矩阵的压缩存储 85 4.3 广义 87 4.3.1 广义的定义 87 4.3.2 广义的存储结构 88 4.4 小结 90 习题 91 第5章 树和二叉树 94 5.1 树的定义和基本术语 94 5.1.1 树的定义 94 5.1.2 树的基本术语 96 5.2 二叉树 97 5.2.1 二叉树的定义 97 5.2.2 二叉树的性质 100 5.2.3 二叉树的存储结构 102 5.3 遍历二叉树和线索二叉树 103 5.3.1 遍历二叉树 103 5.3.2 线索二叉树 109 5.4 树和森林 114 5.4.1 树的存储结构 114 5.4.2 森林与二叉树的转换 116 5.4.3 树和森林的遍历 116 5.5 赫夫曼树及其应用 117 5.5.1 赫夫曼树的基本概念 117 5.5.2 赫夫曼树的构造算法 118 5.5.3 赫夫曼编码 121 5.6 小结 123 习题 123 第6章 图 126 6.1 图的定义和基本术语 126 6.1.1 图的定义 126 6.1.2 图的基本术语 128 6.2 图的存储结构 129 6.2.1 邻接矩阵 130 6.2.2 邻接 132 6.3 图的遍历 135 6.3.1 深度优先搜索 135 6.3.2 广度优先搜索 138 6.4 图的应用 139 6.4.1 最小生成树 139 6.4.2 最短路径 144 6.4.3 拓扑排序 150 6.4.4 关键路径 153 6.5 小结 158 习题 160 第7章 查找 164 7.1 查找的基本概念 164 7.2 线性的查找 165 7.2.1 顺序查找 165 7.2.2 折半查找 166 7.3 树的查找 169 7.3.1 二叉排序树 170 7.3.2 平衡二叉树 176 7.3.3 B-树 182 7.3.4 B+树 190 7.4 散列的查找 192 7.4.1 散列的基本概念 192 7.4.2 散列函数的构造方法 1
16进制10进制.txt 32.txt asm.txt Crctable.txt C标志符命名源程序.txt erre.txt erre2.txt ff.txt for循环的.txt list.log N皇后问题回溯算法.txt ping.txt re.txt source.txt winsock2.txt ww.txt 万年历.txt 万年历的算法 .txt 乘方函数桃子猴.txt 乘法矩阵.txt 二分查找1.txt 二分查找2.txt 二叉排序树.txt 二叉树.txt 二叉树实例.txt 二进制数.txt 二进制数2.txt 余弦曲线.txt 余弦直线.txt 傻瓜递归.txt 冒泡排序.txt 冒泡法改进.txt 动态计算网络最长最短路线.txt 十五人排序.txt 单循环链.txt 单词倒转.txt 单链.txt 单链1.txt 单链2.txt 单链倒序.txt 单链的处理全集.txt 双链正排序.txt 反出字符.txt 叠代整除.txt 各种排序法.txt 哈夫曼算法.txt 哈慢树.txt 四分砝码.txt 四塔1.txt 四塔2.txt 回文.txt 图.txt 圆周率.txt 多位阶乘.txt 多位阶乘2.txt 大加数.txt 大小倍约.txt 大整数.txt 字符串查找.txt 字符编辑.txt 字符编辑技术(插入和删除) .txt 完数.txt 定长串.txt 实例1.txt 实例2.txt 实例3.txt 小写数字转换成大写数字1.txt 小写数字转换成大写数字2.txt 小写数字转换成大写数字3.txt 小字库DIY-.txt 小字库DIY.txt 小孩分糖果.txt 小明买书.txt 小白鼠钻迷宫.txt 带头结点双链循环线性.txt 平方根.txt 建树和遍历.txt 建立链1.txt 扫描码.txt 挽救软盘.txt 换位递归.txt 排序法.txt 推箱子.txt 数字移动.txt 数据结构.txt 数据结构2.txt 数据结构3.txt 数组完全单元.txt 数组操作.txt 数组递归退出.txt 数组递归退出2.txt 文件加密.txt 文件复制.txt 文件连接.txt 无向图.txt 时间陷阱.txt 杨辉三角形.txt 栈单元加.txt 栈操作.txt 桃子猴.txt 桶排序.txt 检出错误.txt 检测鼠标.txt 汉字字模.txt 汉诺塔.txt 汉诺塔2.txt 灯塔问题.txt 猴子和桃.txt 百鸡百钱.txt 矩阵乘法动态规划.txt 矩阵转换.txt 硬币分法.txt 神经元模型.txt 穷举搜索法.txt 符号图形.txt 简单数据库.txt 简单计算器.txt 简单逆阵.txt 线性顺序存储结构.txt 线索化二叉树.txt 绘制圆.txt 编随机数.txt 网络最短路径Dijkstra算法.txt 自我复制.txt 节点.txt 苹果分法.txt 螺旋数组1.txt 螺旋数组2.txt 试题.txt 诺汉塔画图版.txt 读写文本文件.txt 货郎担分枝限界图形演示.txt 货郎担限界算法.txt 质因子.txt 输出自已.txt 迷宫.txt 迷宫问题.txt 逆波兰计算器.txt 逆矩阵.txt 逆阵.txt 递堆法.txt 递归桃猴.txt 递归车厢.txt 递推.txt 逻辑移动.txt 链串.txt 链栈.txt 链十五人排序.txt 链(递归).txt 链队列.txt 队列.txt 阶乘递归.txt 阿姆斯特朗数.txt 非递归.txt 顺序栈.txt 顺序表.txt 顺序队列.txt 骑士遍历1.txt 骑士遍历2.txt 骑士遍历回逆.txt 黑白.txt
16进制10进制.txt 32.txt asm.txt Crctable.txt C标志符命名源程序.txt erre.txt erre2.txt ff.txt for循环的.txt list.log N皇后问题回溯算法.txt ping.txt re.txt source.txt winsock2.txt ww.txt 万年历.txt 万年历的算法 .txt 乘方函数桃子猴.txt 乘法矩阵.txt 二分查找1.txt 二分查找2.txt 二叉排序树.txt 二叉树.txt 二叉树实例.txt 二进制数.txt 二进制数2.txt 余弦曲线.txt 余弦直线.txt 傻瓜递归.txt 冒泡排序.txt 冒泡法改进.txt 动态计算网络最长最短路线.txt 十五人排序.txt 单循环链.txt 单词倒转.txt 单链.txt 单链1.txt 单链2.txt 单链倒序.txt 单链的处理全集.txt 双链正排序.txt 反出字符.txt 叠代整除.txt 各种排序法.txt 哈夫曼算法.txt 哈慢树.txt 四分砝码.txt 四塔1.txt 四塔2.txt 回文.txt 图.txt 圆周率.txt 多位阶乘.txt 多位阶乘2.txt 大加数.txt 大小倍约.txt 大整数.txt 字符串查找.txt 字符编辑.txt 字符编辑技术(插入和删除) .txt 完数.txt 定长串.txt 实例1.txt 实例2.txt 实例3.txt 小写数字转换成大写数字1.txt 小写数字转换成大写数字2.txt 小写数字转换成大写数字3.txt 小字库DIY-.txt 小字库DIY.txt 小孩分糖果.txt 小明买书.txt 小白鼠钻迷宫.txt 带头结点双链循环线性.txt 平方根.txt 建树和遍历.txt 建立链1.txt 扫描码.txt 挽救软盘.txt 换位递归.txt 排序法.txt 推箱子.txt 数字移动.txt 数据结构.txt 数据结构2.txt 数据结构3.txt 数组完全单元.txt 数组操作.txt 数组递归退出.txt 数组递归退出2.txt 文件加密.txt 文件复制.txt 文件连接.txt 无向图.txt 时间陷阱.txt 杨辉三角形.txt 栈单元加.txt 栈操作.txt 桃子猴.txt 桶排序.txt 检出错误.txt 检测鼠标.txt 汉字字模.txt 汉诺塔.txt 汉诺塔2.txt 灯塔问题.txt 猴子和桃.txt 百鸡百钱.txt 矩阵乘法动态规划.txt 矩阵转换.txt 硬币分法.txt 神经元模型.txt 穷举搜索法.txt 符号图形.txt 简单数据库.txt 简单计算器.txt 简单逆阵.txt 线性顺序存储结构.txt 线索化二叉树.txt 绘制圆.txt 编随机数.txt 网络最短路径Dijkstra算法.txt 自我复制.txt 节点.txt 苹果分法.txt 螺旋数组1.txt 螺旋数组2.txt 试题.txt 诺汉塔画图版.txt 读写文本文件.txt 货郎担分枝限界图形演示.txt 货郎担限界算法.txt 质因子.txt 输出自已.txt 迷宫.txt 迷宫问题.txt 逆波兰计算器.txt 逆矩阵.txt 逆阵.txt 递堆法.txt 递归桃猴.txt 递归车厢.txt 递推.txt 逻辑移动.txt 链串.txt 链栈.txt 链十五人排序.txt 链(递归).txt 链队列.txt 队列.txt 阶乘递归.txt 阿姆斯特朗数.txt 非递归.txt 顺序栈.txt 顺序表.txt 顺序队列.txt 骑士遍历1.txt 骑士遍历2.txt 骑士遍历回逆.txt 黑白.txt

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值