数据结构 Data Structure
Overview
In this course, we mainly learned some basic data structures, like:
- Linear Data Structure: Linked List, Stack, Queue
- Non-Linear Data Structure: Binary Tree and Graph
一、Linear Data Structure
1. Linked List
The linked list uses a set of arbitrary storage units to store the data elements.
Each node of the linked list stores its own data and a pointer to the next node.
In C/C++ Language:
typedef struct Node{
int val;
struct Node *next;
}Node, *LinkedList;
There is also double linked list, which has two pointers:
2. Stack
In stack, data can only be inserted at the end of it.
It follows the Last In First Out principle:
Linked List implementation of Stack:
typedef struct Node{
int val;
struct Node *next;
}Node, *LinkedStack
3. Queue
In queue, data can only be inserted at the tail and taken out at the head.
It follows First In First Out principle:
Linked List implementation of Queue:
typedef struct Node{
int val;
struct Node *next;
}Node, *LinkedQueue
二、Non-Linear Data Structure
1. Binary Tree
Tree is a finite set of n nodes. Any non-empty tree has a root node.
The root of the node's sub-tree is the child of the node, and the node is the parent of the child.
In a binary tree, each node has at most two sub-trees.
Three are two special types of binary tree:
- Full Binary Tree
In full binary tree, each non-leaf node has two children.
- Complete Binary tree
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
An important characteristic of a complete binary tree is that the depth of a complete binary tree with n nodes is \(\log_2n + 1\)
C++ implementation of binary tree:
typedef struct Node
{
int data;
struct Node *lchild,*rchild;
}Node,*BinaryTree;
2. Graph
In the graph, the relationship between nodes is arbitrary, and every two nodes may be related.
There are mainly two types of graphs: directed graph and undirected graph.
In this course we learned about the adjacency list implementation of graph.
In the adjacency list, each vertex has a linked list, and the linked list stores the edges attached to the vertex.
Code:
typedef char VertexType;
typedef int ArcType;
typedef struct ArcNode{
int adjvex;//顶点下标(位置)
ArcType weight;//权值
struct ArcNode *nextarc;//指向下一个边结点
}ArcNode;//边结点
typedef struct VNode{
VertexType data;//顶点内容
ArcNode *firstArc;//指向第一个边结点
}VNode,AdjList[MVNUM];
typedef struct{
AdjList vertices;//顶点数组
int vexNum,arcNum;//顶点数和边数
}ALGraph;
Traversal of Graph:
三、Curriculum Design
I made a Huffman encoder/decoder.
Decoder reads the text file, then counts the frequency of each character and encodes the text according to the Huffman tree.
The decoder reads the encoded file and translates the encoded file into the original text file according to the Huffman code.
原文地址:https://www.cnblogs.com/danielwong2021/p/15271283.html
- Docker 远程连接 -- dockerd 命令详解
- 在开发环境使用 Docker
- Docker Cloud 简介
- 一封伪造邮件引发的“探索”(涉及钓鱼邮件、SPF和DKIM等)
- Docker 镜像多阶段构建
- 利用WCF改进文件流传输的三种方式
- 利用系统特性伪装成一个免密登陆后门
- Docker 桌面版支持 kubernetes
- OOB(out of band)分析系列之DNS渗漏
- VLC播放器加载恶意字幕文件导致执行任意代码漏洞分析与POC实现
- Wolf CMS 新旧两个版本中的文件上传漏洞分析
- C#向excel中写入数据的三种方式
- 一款短小精致的SSH后门分析
- 反击“猫眼电影”网站的反爬虫策略
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Kettle构建Hadoop ETL实践(二):安装与配置
- WKWebView加载沙盒HTML
- 【python-leetcode480-双堆】滑动窗口的中位数
- 虚拟机--python环境配置
- 利用装饰器计算函数运行的时间
- 【猫狗数据集】谷歌colab之使用pytorch读取自己数据集(猫狗数据集)
- python wraps的作用
- paddlepaddle中文词法分析LAC
- python *args,**kwargs参数
- (一)django创建
- PaddleHub提供的ERNIE进行文本分类
- (二)django--带APP的网站
- Spring Boot 自定義 HttpMessageConverter 解決 String 類型返回JSON對象問題
- spring之为级联集合属性进行赋值
- springmvc之HiddenHttpMethodFilter配置使用POST、GET、DELETE、PUT请求