(5.1.1)--chapter5-1数组的定义与顺序存储.pdf
《(5.1.1)--chapter5-1数组的定义与顺序存储.pdf》由会员分享,可在线阅读,更多相关《(5.1.1)--chapter5-1数组的定义与顺序存储.pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、 数据结构与算法Data Structures and Algorithms 数组的定义与顺序存储Definition of Array and Sequential StorageArray A is a finite sequence of n(n0)elements,denoted by A=(a1,an)l ai(1in)are all either atomic items ei (i.e.,specific value)with the same data type,or sub-arrays Bi with the same definition.lThe dimension o
2、f array A=(a1,an)is defined as:l n is the length of dimension 1 of array A;the length of ai equals to the length of dimension 2 of array A.l While defining an array,we need to give the length or range of each dimension of the array.Dim(A)=1 ai(1in)are all atomic itemsDim(ai)+1 ai(1in)are all sub-arr
3、ays Bi1Data StructuresData Structures1.Definition of arrayChapter 5 Arrays and generalized tablesl Defining an n-dimension array(n0)in C Lang.Let Li (1 i n)be any positive integern Syntax:ElemType arrayNameL1Ln;n Semantics:the length of dimension 1 is L1,and each element is a sub-array of L2*.*Ln.l
4、For example:a major has 50 courses in its program,and there are 100 students in each grade of the majorn Save the math scores of 100 students(100 atomic items)1-dimension array:int mathScore100 Length of the array:100 Element of the array:atomic item1.Definition of arrayin C LanguageChapter 5 Arrays
5、 and generalized tables2Data Structuresn Keep the 50 courses scores of all the students of a grade(50*100 atomic items)2-dimension array:int gradeScore50100 The length of array:The 1st dimension:50;The 2nd dimension:100.Element of the array:sub-array of length 100n Store all the students scores of 1
6、0 grades(10*50*100 atomic elements)3-dimension array:int allGradeScore1050100 Length of the array:The 1st dimension:10;The 2nd dimension:50;The 3nd dimension:100.Element of the array:2-dimension sub-array of the size 50*100.3l Defining an n-dimension array in Fortran.Let Li(1 i n)be any positive int
7、eger.n Syntax:ElemType array(L1,Ln);n Semantics:the length of dimension 1 is Ln,an each element is sub-array of L2*.*Ln;Data Structuresl For example:a major has 50 courses and each grade of the major has 100 students.To keep the 50 courses scores of all the 100 students of a grade:n 2-dimension arra
8、y:integer gradeScore(50,100)The length of the arrays:the lengths of dimension 1 and 2 are 100 and 50 respectively Element of the array:sub-array of length 50.n 2-dimension array:integer gradeScore(100,50)The length of the array:the lengths of dimension 1 and 2 are 50 and 100 respectively Element of
9、the array:sub-array of length 1001.Definition of arrayin Fortran LanguageChapter 5 Arrays and generalized tables4lKey problem:mapping the multi-dimension data space to linear memory space.lFor any array A=(a1,an)(n0),the sequential storage scheme can be inductively defined as follows:n Recursion bas
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 5.1 chapter5 数组 定义 顺序 存储
限制150内