自调整表的数组实现

本文详细介绍了如何使用C语言来实现一种自调整表的数据结构,内容涵盖数据结构设计与算法分析,主要讨论了如何通过数组来高效地管理这种动态变化的表格。
摘要由CSDN通过智能技术生成

数据结构与算法分析——c语言描述 练习3.15 答案

list.h

typedef int ElementType;
#define SpaceSize 100
#ifndef _Cursor_H
#define _Cursor_H

struct SelfAdjustRecord;
typedef struct SelfAdjustRecord* SelfAdjust;
typedef int PtrToNode;
typedef PtrToNode Position;



SelfAdjust creatList(int space);
Position Find(ElementType X, SelfAdjust L);
void Insert(ElementType X, SelfAdjust L);
#endif

list.c

#include"list.h"
#include<stdlib.h>
#include"fatal.h"

struct SelfAdjustRecord {
	ElementType *arr;
	int capacity;
	int rearCur;
};


SelfAdjust creatList(int space) {
	SelfAdjust s = malloc(sizeof(struct SelfAdjustRecord));
	if (s == NULL)
		Error("out of memory");
	s->arr = malloc(sizeof(ElementType)*space);
	if (s->arr == NULL)
		Error("out of memory");
	s->capacity = space;
	s->rearCur = -1;
	return 
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值