《c语言数据结构补充Clanguagedatastructuresupplement》由会员分享,可在线阅读,更多相关《c语言数据结构补充Clanguagedatastructuresupplement(32页珍藏版)》请在金锄头文库上搜索。
1、c语言数据结构补充(C language data structure supplement)For Many a little make a mickle. progress every day.I. Basic Concepts and terminologyData (Data): a symbolic representation of informationIn computer science, a general term for all symbols that can be entered into a computer and processed by a computer
2、 programData element (Data Element): the basic unit of dataIn computer programs, usually considered and handled as a wholeA data element can consist of several data itemsA data item is the smallest unit of data that cannot be dividedData object (Data Object): a collection of data elements of the sam
3、e natureIs a subset of the dataStructure (Data): a collection of data elements that exist in one or more specific relationships with each otherThe data structure is divided into logical structure and physical structureThe relation between data is called logical structureThey are usually divided into
4、 four categories:* data elements in a collection structure, except that they belong to one typeNothing else* there is a one to one relationship between the data elements in the linear structure* there is a one to many relationship between data elements in tree structured structures* there are many t
5、o many relationships between data elements in graphs, structures, or mesh structuresThe data structure is formally defined as: the data structure is a two tuple: Data-Structure= (DS)Where: D is a finite set of data elementsS is a finite set of relations on DThe data structure of the complex number i
6、s defined as follows: Complex= (CR)Where: C is the two sets of real numbers C1C2Representing the real and imaginary parts of the complex number, respectivelyR=PP is a relation defined on a collection C1C2.The representation of data structures in a computer is called the physical structure of dataAls
7、o known as storage structureData structures have two different representations in a computer: sequential and non sequential representationsTwo different storage structures are obtained: sequential storage structure and chain storage structure* sequential storage structure: the logical relation betwe
8、en data elements represented by the relative positions of data elements in memory* chained storage structure: adds a pointer to the address in each of the data elementsUse this pointer to represent logical relationships between data elementsData type (Data Type): in a programming languageThe type of
9、 data that a variable hasIn C language, data types: base types and construction typesBasic types: integer, floating point, and character typeStructural types: arrays, structures, unions, pointers, enumerations, and customizationsTwo, linear tableLinear table (Linear List): n (n = 0) data elements (n
10、odes) A1A2A finite sequence consisting of anThe number of data elements n is defined as the length of the tableWhen n=0 is called an empty tableThe non empty linear table (n0) is often denoted as: (A1A2An).An example of 1 or 26 letters of alphabet (ABC,., Z)Example 2. Changes in the amount of comput
11、er ownership of a school from 1978 to 1983(6SeventeenTwenty-eightFiftyNinety-two188)Example 3 student health registration form is as followsFull nameStudent numberSexAgeHealthWangSeven hundred and ninety thousand six hundred and thirty-onemaleEighteenHealthyChen HongSeven hundred and ninety thousand
12、 six hundred and thirty-twofemaleTwentycommonlyLiu jianping1Seven hundred and ninety thousand six hundred and thirty-threemaleTwenty-oneHealthyZhangliliSeven hundred and ninety thousand six hundred and thirty-fourmaleSeventeenNeurasthenia2.1 order tableThe nodes of the linear table are stored in log
13、ical order sequentially in a set of address contiguous storage unitsA linear table stored in this method; referred to as a list of tablesIt is assumed that each element of the linear table needs to occupy l storage cellsThe storage location of the first unit is used as the storage location of the da
14、ta elementThe linear table in the i+1 data elements storage location for the LOC (ai+1) and the storage location for the LOC I data elements (AI) between satisfying the following relation: LOC (ai+1) =LOC (AI) +l the I storage location data elements linear table AI: LOC (AI (A1) =LOC) + (i-1) *lSinc
15、e the one-dimensional array in the C language is also expressed in sequential storageYou can use array types to describe sequential tablesBecause besides storing elements of a linear table with arraysThe order table should also use a variable to represent the length attribute of a linear tableSo we define sequence table types with structure types# define ListSize 100Typedef int DataTy