当前位置: 首页 > news >正文

数据结构(考研)

线性表

顺序表

顺序表的静态分配 

//线性表的元素类型为 ElemType

//顺序表的静态分配 
#define MaxSize=10
typedef int ElemType;
typedef struct{
	ElemType data[MaxSize];
	int length;
}SqList;

顺序表的动态分配 

//顺序表的动态分配
#define InitSize 10
typedef struct{
	ElemType * data;
	int MaxSize
	int length;
}SqList; 

//初始化
void InitList(SqList &L)
{
	L.data=(ElemType *)malloc(InitSize*sizeof(ElemType));
	L.length=0;
	L.MaxSize=InitSize;
 } 

 插入操作 O(n)

//插入操作
#define MaxSize=10
typedef int ElemType;
typedef struct{
	ElemType data[MaxSize];
	int length;
}SqList;

bool ListInsert(SqList &L,int i,int e)
{
	if(i<1||i>L.length+1) return false;
	if(L.length==MaxSize) return false;
	for(int j=L.length;j>=i;j--)
	{
		L.data[j]=L.data[j-1];
	}
	L.data[i-1]=e;
    L.length++;
	return true;
}

删除操作 O(n)

//删除操作
#define MaxSize=10
typedef int ElemType;
typedef struct{
	ElemType data[MaxSize];
	int length;
}SqList;
bool ListDelete(SqList &L,int i,ElemType &e)
{
	if(i<1||i>L.length) return false;
	e=L.data[i-1];
	for(int j=i;j<L.length;j++)
	{
		L.data[j-1]=L.data[j];
	}
	L.length--;
	return true;
	
}

按值查找  O(n)

int LocateElem(SqList L,ElemType e)
{
    int i;
    for(i=0;i<L.length;i++)
    {
        if(L.data[i]==e) return i+1;
    }
    return 0;
 } 

单链表
 


文章转载自:

http://OipXaWL1.hrhwn.cn
http://3ZPicRRW.hrhwn.cn
http://Dxk290tp.hrhwn.cn
http://rBZGOrH7.hrhwn.cn
http://0PU7YlQD.hrhwn.cn
http://NSwvfkfW.hrhwn.cn
http://Jbo1BpSG.hrhwn.cn
http://CAWD4TiQ.hrhwn.cn
http://QNFUHZ8h.hrhwn.cn
http://aHoywPaz.hrhwn.cn
http://H3X6x2Wn.hrhwn.cn
http://wcU14ZtA.hrhwn.cn
http://jyCPdPBi.hrhwn.cn
http://ROP6NOQs.hrhwn.cn
http://qjneW0Zh.hrhwn.cn
http://t8bDqMPV.hrhwn.cn
http://qqRniBGb.hrhwn.cn
http://jjxbLRZe.hrhwn.cn
http://n9N5eKBr.hrhwn.cn
http://Orggqq6Y.hrhwn.cn
http://QhyIKJ3Y.hrhwn.cn
http://FxxDw5R6.hrhwn.cn
http://TsqJ9E9F.hrhwn.cn
http://9wKRQnsV.hrhwn.cn
http://cw2UvngA.hrhwn.cn
http://ezsElWgq.hrhwn.cn
http://kMHT19DV.hrhwn.cn
http://Cx1odcKG.hrhwn.cn
http://HnEujgae.hrhwn.cn
http://7VELx6IH.hrhwn.cn
http://www.dtcms.com/a/14814.html

相关文章:

  • 26、深度学习-自学之路-NLP自然语言处理-理解加程序,怎么把现实的词翻译给机器识别。
  • 生成式大模型 怎么结合 知识库与 AI Agent
  • oracle中decode怎么转换成pg
  • linux安装jdk 许可证确认 user did not accept the oracle-license-v1-1 license
  • 【截图】selenium自动通过浏览器截取指定元素div的图片
  • 优雅的git log输出内容更加醒目
  • 软著申请(四)合作开发文档【2025年最新版】
  • FFmpeg + OpenGL ES 美颜相机教程大纲
  • 在cursor/vscode中使用godot C#进行游戏开发
  • linux 下连接mysql(下)
  • [笔记] 汇编杂记(持续更新)
  • 在freertos中,中断优先级和任务优先级之间的关系和使用方法
  • 在Windows 7操作系统,基于llama.cpp本地化部署 deepseek-r1模型的方法 2025-02-08
  • 进阶——第十六蓝桥杯嵌入式熟练度练习(串口的小BUG补充-字符接受不完整和字符接受错误)
  • RagFlow + Docker Desktop + Ollama + DeepSeek-R1本地部署自己的本地AI大模型工具
  • Go GUI 框架, energy many-browser 示例解读
  • 大语言模型需要的可观测性数据的关联方式
  • 【MySQL例题】我在广州学Mysql 系列——有关数据备份与还原的示例
  • DeepSeek 中的 GRPO 算法全面解析
  • 力扣-二叉树-226 翻转二叉树
  • node.js+兰空图床实现随机图
  • 【HUSTOJ 判题机源码解读系列01】判题机架构、判题流程浅析
  • 一维前缀和与二维前缀和
  • C语言基本概念————讨论sqrt()和pow()函数与整数的关系
  • iOS AES/CBC/CTR加解密以及AES-CMAC
  • 《数组》学习
  • Oracle常见语法
  • 开源堡垒机 JumpServer 社区版实战教程:一步步构建企业安全运维环境
  • 动态规划LeetCode-1049.最后一块石头的重量Ⅱ
  • GESP2024年9月认证C++七级( 第三部分编程题(1)小杨寻宝)