1. Data Structure Concepts
Data structure (Data structure) is present between each other a group of one or more specific relationship between the data organized in the data mode and they are within a computer storage , and is defined on the set of data is a set of operations .
The main data structure:
1) data (a computer object to be processed) of the logical structure
2) Basic operations implement algorithms
Step into the computer to solve the problem:
- Mathematical model
- Design Algorithm
- Programming algorithm
It refers to a logical structure data of the organization of data and the data
1976 Swiss computer Nicklaus put forward " algorithm + Data Structures = Programs "
Data structure is divided into: the basic operation of the logical structure data, data storage structure of the data
Basic concepts and terminology 1.2
: Data The data set of symbols that can be processed by a computer all
DataElement data elements : a set of individual data, i.e., the basic unit of data
Item data items DATE : data element is often further divided into a number of data items, the data item is the meaningful minimum unit
As shown, the relationship between the three is contained in the database, also known as a data item field or fields . It is the smallest indivisible unit of data representation.
The actual data in question is referred to the original data
Logical Structure: refers to the structural relationship between the data elements
Physical structure (storage structure): means the clerk then oh represented in the old machine, logic structure of data in the computer implemented.
Type logical structure: a set of linear structure, a tree structure, like the structure of FIG.
The data storage structure
Storing a data structure comprising a memory which stores logic and data element
存储结构可分为:顺序存储结构、链式存储结构、索引存储方式和散列存储方式等
顺序存储结构:借助数据元素的相对存储位置来表示数据的逻辑结构;线性表的顺序存储方法:将表中的结点一次存放在计算机内存中一组连续的存储单元中。
特点:1)预先分配好长度,需要预估存储数据需要的存储量
2)插入和删除需要移动其他元素
3)存取快捷,是随机存取结构
链式存储方式:数据元素地址的指针表示数据的逻辑结构
数据项|指针项
特点:
1)动态分配,不需要预先确定内存分配
2)插入和删除不需要移动其他元素
3)非随即存取结构
索引存储方式:借助索引表中的索引指示存储节点的存储位置
散列存储方式:用散列函数知识各节点的存储位置
运算
运算就是指在某种逻辑结构上施加的操作,即对逻辑结构的加工
加工型运算:其操作改变原逻辑结构的值
引用型运算:其操作不改变原洛基结构的值
建立——查找——读取——插入——删除
算法规定了求解给定类所需的所有“处理步骤”以及执行顺序,
使给定类型问题能在有限时间内被机械的求解
算法必须使用某种语言描述:
1.程序
2.介于自然语言和程序设计语言的伪代码
3.非形式算法(自然语言)
4.框图(N-S图)
1.3算法描述
一个算法是对特定问题求解步骤的一种描述,它是指令有穷序列
算法具有以下特性:
1)有穷性 2) 确定性 3)可行性 4)输入 5)输出
1.4算法分析
算法的设计应满足:
1)正确性:对于合法的输入产生符合要求的输出
2)易读性:算法应该易读、便于交流,这也是保证算法正确性的前提;
添加注释也是一种增加可读的办法;
3)健壮性:当输入非法时,算法还能做出适当的反应而不会崩溃,如输出错误信息;
算法中应该考虑适当的错误处理;
4)时空性; 一个算法的时空性是指算法的世家复杂度和空间复杂度,算法分析主要分析算法的时间
复杂度和空间复杂度,目的是提高算法的效率。解决同一问题的算法可以有多种。 我们希望从中选出最优的算法,效率高或者存储空间小。为此,需要对算法进行评估,分析 。
通常考虑两个度量:
❖ 时间复杂度: 算法运行时需要的总步数,通
常是问题规模的函数。
❖ 空间复杂度: 算法执行时所占用的存储空间,
通常是问题规模的函数。