Data structure study notes 1.1-the concept of linear tables

Data structure study notes 1.1-the concept of linear tables

Write in front

This is a study note and a process of gradual understanding.
Hope it will continue forever.

table of Contents

Let's first understand the concept and definition of linear tables, and of course the abstract base classes of C++. The specific implementation is left in the next section.

concept

  1. The linear table is a finite sequence , that is, the linear table has the only first entry and the last entry, and other entries have and only one direct predecessor (the first entry has no predecessor); except for the last Except for an entry, other entries have one and only one immediate successor i (the last entry has no successor).
  2. L = (a1, a2, …,an), L is the name of the table, and n is the length of the table.
  3. The first entry is called the header , and the last entry is called the tail .
  4. The adjacency relationship is one-to-one , and all nodes form a linear structure based on the one-to-one adjacency relationship.
  5. It is conceptually allowed that each element in the linear table can have different data types, but the current learning process only considers the same data type.

A few examples

A few examples of linear tables:
COLOR = ('Red', Orange','Yellow','Green','Blue','Black')
DEPT = (communication, computer, automation, microelectronics, architecture and urban planning, Life sciences, precision instruments)
SCORE = (667, 664, 659, 659, 657, 654, 653, 652, 651, 650, 650)

There may or may not be a relationship between the value in the linear table and its position. The elements in an ordered linear table are arranged in ascending order of value, while an unordered linear table has no such relationship.

Abstract data type of linear table

// 线性表的抽象数据类型
ADT LinearList is
Objects: n(0)个原子表项的一个有限序列。
Function:
	create()					创建一个空线性表
	int Length()				计算表长度
	int search(T& x)			找x在表中的位置,返回表项位置
	int Locate(int i)			返回第i个表项在表中的位置
	bool getData(int i,T& x)  	取第i个表项的值
	bool setData(int i,T& x)	用x修改第i个表项的值
	bool Insert(int i,T& x)		在第i个表项后插入x
	bool Remove(int i,T&x )		删除表中第i个表项,通过x返回删除表项的值
	bool IsEmpty()				判断表是否为空
	bool IsFull()				判断表是否已满
	void Sort()					对当前表排序
end LinearList

The above calculations are only definitions at the logical level , and only " what to do " are given . Only after the storage structure is determined , details such as " how to do " can be realized .

Bibliography: "Data Structure" (Described in Object-Oriented Method and C++ Language) (2nd Edition). Tsinghua University Press. Yin Renkun

Guess you like

Origin blog.csdn.net/qq_45830912/article/details/109633708