O r c h e s t r a _ 数 据 结 构 与 算 法
- 格式:pdf
- 大小:105.85 KB
- 文档页数:4
第1章绪论教材中练习题及参考答案1. 简述数据与数据元素的关系与区别。
答:凡是能被计算机存储、加工的对象统称为数据,数据是一个集合。
数据元素是数据的基本单位,是数据的个体。
数据元素与数据之间的关系是元素与集合之间的关系。
2. 采用二元组表示的数据逻辑结构S=<D,R>,其中D={a,b,…,i},R={r},r={<a,b>,<a,c>,<c,d>,<c,f>,<f,h>,<d,e>,<f,g>,<h,i>},问关系r是什么类型的逻辑结构?哪些结点是开始结点,哪些结点是终端结点?答:该逻辑结构为树形结构,其中a结点没有前驱结点,它是开始结点,b、e、i和g、结点没有后继结点,它们都是终端结点。
3. 简述数据逻辑结构与存储结构的关系。
答:在数据结构中,逻辑结构与计算机无关,存储结构是数据元素之间的逻辑关系在计算机中的表示。
存储结构不仅将逻辑结构中所有数据元素存储到计算机内存中,而且还要在内存中存储各数据元素间的逻辑关系。
通常情况下,一种逻辑结构可以有多种存储结构,例如,线性结构可以采用顺序存储结构或链式存储结构表示。
4. 简述数据结构中运算描述和运算实现的异同。
答:运算描述是指逻辑结构施加的操作,而运算实现是指一个完成该运算功能的算法。
它们的相同点是,运算描述和运算实现都能完成对数据的“处理”或某种特定的操作。
不同点是,运算描述只是描述处理功能,不包括处理步骤和方法,而运算实现的核心则是设计处理步骤。
5. 数据结构和数据类型有什么区别?答:数据结构是相互之间存在一种或多种特定关系的数据元素的集合,一般包括三个方面的内容,即数据的逻辑结构、存储结构和数据的运算。
而数据类型是一个值的集合和定义在这个值集上的一组运算的总称,如C语言中的short int数据类型是由-32768~32767(16位机)的整数和+、-、*、/、%等运算符构成。
解忧书店 JieYouBookshop第二章单元测试1、(1分)以下哪种结构是逻辑结构,而与存储和运算无关:Which of the following structure is a logical structure regardless of the storage or algorithm:(There is only one correct answer)A、队列(queue)B、双链表(doubly linked list)C、数组(array)D、顺序表(Sequential list)答案: A2、(1分)计算运行下列程序段后m的值:Calculate the value of m after running the following program segmentn = 9; m = 0;for (i=1;i<=n;i++)for (j = 2*i; j<=n; j++)m=m+1;求m的值答案: 203、(1分)下列说法正确的是:Which options may be correct?(there are more than one correct answers)A、如果函数f(n)是O(g(n)),g(n)是O(h(n)),那么f(n)是O(h(n))【 if f(n) is O(g(n)),g(n) is O(h(n)),then f(n) is O(h(n))】B、如果函数f(n)是O(g(n)),g(n)是O(h(n)),那么f(n)+g(n)是O(h(n))【if f(n) is O(g(n)),g(n) is O(h(n)),so f(n)+g(n) is O(h(n))】C、如果a>b>1,logan是O(logbn),但logbn不一定是O(logan)【if a>b>1,logan is O(logbn),logbn may not be O(logan)】D、函数f(n)是O(g(n)),当常数a足够大时,一定有函数g(n)是O(af(n))【if f(n)是O(g(n)),When constant a is big enough ,there must be g(n) is O(af(n))】答案: A,B4、(1分)由大到小写出以下时间复杂度的序列:答案直接写标号,如:(1)(2)(3)(4)(5) (提示:系统基于字符匹配来判定答案,所以您的答案中不要出现空格)Write the following time complexity in descending sequence:Write down the answer labels such as (1)(2)(3)(4)(5). (Hint:This problem is judged by string matching, Please make sure your answer don't contain any blanks. )RUX4%GXZNDD{IAQWTCSEEJG.png答案: (5)(1)(2)(4)(3)5、(1分)已知一个数组a的长度为n,求问下面这段代码的时间复杂度:An array of a, its length is known as n. Please answer the time complexity of the following code.(There are more than one answers.)for (i=0,length=1;i<n-1;i++){for (j = i+1;j<n && a[j-1]<=a[j];j++)if(length<j-i+1)length=j-i+1;}Screen Shot 2017-09-05 at 23.31.19.pngA、如图,A选项B、如图,B选项C、如图,C选项D、如图,D选项答案: A,B第三章单元测试1、(1分)下面关于线性表的叙述中,正确的是哪些?Which of the followings about linear list are correct?(There are more than one answers.)Select the answer that matchesA、线性表采用顺序存储,必须占用一片连续的存储单元。
2022年广东白云学院计算机科学与技术专业《数据结构与算法》科目期末试卷A(有答案)一、选择题1、将两个各有N个元素的有序表归并成一个有序表,其最少的比较次数是()。
A.NB.2N-1C.2ND.N-12、n个结点的完全有向图含有边的数目()。
A.n*nB.n(n+1)C.n/2D.n*(n-1)3、链表不具有的特点是()。
A.插入、删除不需要移动元素B.可随机访问任一元素C.不必事先估计存储空间D.所需空间与线性长度成正比4、用不带头结点的单链表存储队列,其队头指针指向队头结点,队尾指针指向队尾结点,则在进行出队操作时()。
A.仅修改队头指针B.仅修改队尾指针C.队头、队尾指针都可能要修改D.队头、队尾指针都要修改5、循环队列A[0..m-1]存放其元素值,用front和rear分别表示队头和队尾,则当前队列中的元素数是()。
A.(rear-front+m)%mB.rear-front+1C.rear-front-1D.rear-front6、下列关于无向连通图特性的叙述中,正确的是()。
Ⅰ.所有的顶点的度之和为偶数Ⅱ.边数大于顶点个数减1 Ⅲ.至少有一个顶点的度为1 A.只有Ⅰ B.只有Ⅱ C.Ⅰ和Ⅱ D.Ⅰ和Ⅲ7、排序过程中,对尚未确定最终位置的所有元素进行一遍处理称为一趟排序。
下列排序方法中,每一趟排序结束时都至少能够确定一个元素最终位置的方法是()。
Ⅰ.简单选择排序Ⅱ.希尔排序Ⅲ.快速排序Ⅳ.堆排Ⅴ.二路归并排序A.仅Ⅰ、Ⅲ、Ⅳ B.仅Ⅰ、Ⅱ、Ⅲ C.仅Ⅱ、Ⅲ、Ⅳ D.仅Ⅲ、Ⅳ、Ⅴ8、有n(n>0)个分支结点的满二叉树的深度是()。
A.n2-1B.log2(n+1)+1C.log2(n+1)D.log2(n-l)9、有关二叉树下列说法正确的是()。
A.二叉树的度为2B.一棵二叉树的度可以小于2C.二叉树中至少有一个结点的度为2D.二叉树中任何一个结点的度都为210、数据序列(8,9,10,4,5,6,20,1,2)只能是下列排序算法中的()的两趟排序后的结果。
第1章绪论2 、(1)×(2)×(3) √3 、(1)A(2)C(3)C5、f or计(算i=下1n程;序中 1 得语句频度for(j=1;j<=i; j++)for(k=1;k<=j;k ++)x=x+1;【解答】 x=x+1 得语句频度为:T(n)=1+(1+2)+(1+2+3)+. …+(1+2+……+n)=n(n+1)(n+2)/66 、编写算法,求一元多项式p。
(x)=a。
+a,x+a₂X2+……、+a Xn得值p(x) 并确定算法中每一语句得执行次数与整个算法得时间复杂度,要求时间复杂度尽可能小,规定算法中不能使用求幂函数.注意:本题中得输入为a,(i=01,…n)、x 与n,输出为P。
(x)。
算法得输入与输出采用下列方法(1)通过参数表中得参数显式传递(2)通过全局变量隐式传递。
讨论两种方法得优缺点,并在算法中以您认为较好得一种实现输入输出.【解答】(1)通过参数表中得参数显式传递优点:当没有调用函数时,不占用内存,调用结束后形参被释放,实参维持,函数通用性强,移置性强。
缺点:形参须与实参对应,且返回值数量有限。
(2)通过全局变量隐式传递优点:减少实参预形参得个数,从而减少内存空间以及传递数据时得时间消耗缺点:函数通用性降低,移植性差算法如下:通过全局变量隐式传递参数PolyValue({ int,in;floatx,a[]p;pri n tf(hn=”);s c anf(“%f,”&n);printf(“x=”;)sca nf(“%f&x);f or(i=0;i<n; i++)s c anf(%f ,&a[i]; /*执行次数:n 次 */p=a[0];for (i=1;i<=n;i++){ p=p+a [i]*x; /*执行次数:n次*/x= x*x;}prin t f(%f” p);}算法得时间复杂度:T(n)=0(n)通过参数表中得参数显式传递f loat PolyVa lue(float a[ ], float x, i nt n)f 1 oat p, s;int;is p a X0];for(=1;i<= n;i++)/执行次数:n 次*/{s=s+a [i]* p;p=p*x;}re turn(p);算法得时间复杂度:T(n)=O(n)第2章线性表习题1、填空:(1)在顺序表中插入或者删除一个元素,需要平均挪移一半元素,具体挪移得元素个数与插入或者删除得位置有关。
英语中a s …a s结构变化多端,功能丰富,是英语考试中的热点。
笔者下面就该结构的用法进行一下归纳与总结。
一、a s +形容词原级+a s这个结构是用来表示相同或不同性质之间的比较关系,第一个 a s 为副词,第二个a s 为从属连词,引导状语从句。
1 .表示两个人或物相同性质的比较:和……一样;与……在……方面毫无二致S h e i s a s c l e v e r a s h e r s i s t e r .她和她妹妹一样聪明。
2 .表示两个人或物不同性质的比较:……而……;……却……Th e p r i s o ns ar e a s o v e r - c r o wd e d a s t he f a r ml a n d s a r e e mp t y 。
监牢里人满为患,而地里却无人耕种。
3 .表示同一人或物不同性质的比较:既……又……He i s a s k i n d a s h e i s h o n e s t .他既诚实,又和蔼可亲。
二、a s +形容词原级+名词+a s这个结构用来表示数量和其他方面的意思,第一个 a s 为副词,第二个a s 为从属连词,引导定语从句。
S h e i s a s f i n e a wo ma n a s e v e r wa l k e d .她可以与任何卓越的女性比美。
Co r n d o e s n’t n e e d a s mu c h wa t e r a s r i c e .玉米需要的水没有水稻需要的那样多。
三、a s +副词原级+a s这个结构中第一个 a s 是副词,第二个是从属连词,引导程度状语从句。
He wo k e u p a s s u d d e n l y a s h e h a d f a l l e n a s l e e p .他醒来和入睡一样突然。
四、a s …a s 结构的否定形式not as…as;not so…asHe i s n ot a s( s o)n au gh t y a s I t h ou ght he wa s .他不像我过去认为的那样淘气。
FLAC格式解析This is a detailed description of the FLAC format. There is also a companion document that describesFLAC-to-Ogg mapping.For a user-oriented overview, seeAbout the FLAC Format.Table of ContentsAcknowledgmentsScopeArchitectureDefinitionsBlockingInterchan nel DecorrelationPredictionResidual CodingFormatFLAC SubsetSpecificationMETADATA_BLOCKMETADATA_BLOCK_HEADERMETADATA_BLOCK_DATAMETADATA_BLOCK_STREAMINFOMETADATA_BLOCK_PADDINGMETADATA_BLOC K_APPLICATIONMETADATA_BLOCK_SEEKTABLESEEKPOINTMETADATA_BLOCK_VORBIS_COMMENTMETADATA_BLOCK_CUESHEE TCUESHEET_TRACKCUESHEET_TRACK_INDEXMETADATA_BLOCK_PICTUREFRAME_HEADERFRAME_FOOTERSUBFRAMESUBFRAME_HEADERSUBFRAME_CONSTANTSUBFRAME_FIXEDSUBFRAME_LPCSU BFRAME_VERBATIMRESIDUALRESIDUAL_CODING_METHOD_PARTITIONED_RICERICE_PARTITIONRESIDUAL_CODING_METHOD_PARTITIONED_RICE2RICE2_PARTITIONAcknowledgmentsFLAC owes much to the many people who have advanced the audio compression field so freely. For instance:A. J. Robinson for his work onShorten; his paper is a goodstarting point on some of the basic methods used by FLAC. FLAC trivially extends and improves the fixed predictors, LPC coefficient quantization, and Rice coding used in Shorten.S. W. Golomb and Robert F. Rice; their universal codes are used by FLAC's entropy coder.N. Levinson and J. Durbin; the reference encoder uses an algorithm developed and refined by them for determining the LPC coefficients from the autocorrelation coefficients.And of course, Claude ShannonScopeIt is a known fact that no algorithm can losslessly compress all possible input, so most compressors restrict themselves to a useful domain and try to work as well as possible within that domain. FLAC's domain is audio data. Though it can losslesslycodeany input, only certain kinds of input will get smaller. FLAC exploits the fact that audio data typically has a high degree of sample-to-sample correlation.Within the audio domain, there are many possible subdomains. For example: low bitrate speech, high-bitrate multi-channel music, etc.FLAC itself does not target a specific subdomain but many of the default parameters of the reference encoder are tuned to CD-quality music data (i.e. 44.1kHz, 2 channel, 16 bits per sample). The effect of the encoding parameters on different kinds of audio data will be examined later.ArchitectureSimilar to many audio coders, a FLAC encoder has the following stages:Blocking. The input is broken up into many contiguous blocks. With FLAC, the blocks may vary in size. The optimal size of the block is usually affected by many factors,including the sample rate, spectral characteristics over time, etc. Though FLAC allows the block size to vary within a stream, the reference encoder uses a fixed block size.Interchannel Decorrelation. In the case of stereo streams, the encoder will create mid and side signals based on the average and difference (respectively) of theleft and right channels. The encoder will then pass the best form of the signal to the next stage.Prediction. The block is passed through a prediction stage where the encoder tries to find a mathematical description (usually an approximate one) of the signal. Thisdescription is typically much smaller than the raw signal itself.Since the methods of prediction are known to both the encoder and decoder, only the parameters of the predictor need be included in the compressed stream. FLAC currently uses four different classes of predictors (described in theprediction section), but the format has reserved space for additional methods. FLAC allows the class of predictor to change from block to block, or even within the channels of a block.Residual coding. If the predictor does not describe the signal exactly, the difference between the original signal and the predicted signal (called the error orresidual signal) must be coded losslessy. If the predictor is effective, the residual signal will require fewer bits per sample than the original signal. FLAC currently uses only one method for encoding the residual (see theResidualcoding section), but the format has reserved space for additional methods. FLAC allows the residual coding method to change from block to block, or even within the channels of a block.In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.DefinitionsMany terms like "block" and "frame" are used to mean different things in differenct encoding schemes. For example, a fra。