【精品数据结构】preface.ppt

上传人:marr****208 文档编号:130051360 上传时间:2020-04-24 格式:PPT 页数:53 大小:282.50KB
返回 下载 相关 举报
【精品数据结构】preface.ppt_第1页
第1页 / 共53页
【精品数据结构】preface.ppt_第2页
第2页 / 共53页
【精品数据结构】preface.ppt_第3页
第3页 / 共53页
【精品数据结构】preface.ppt_第4页
第4页 / 共53页
【精品数据结构】preface.ppt_第5页
第5页 / 共53页
点击查看更多>>
资源描述

《【精品数据结构】preface.ppt》由会员分享,可在线阅读,更多相关《【精品数据结构】preface.ppt(53页珍藏版)》请在金锄头文库上搜索。

1、DataStructures Algorithms andApplicationsinC ChenPeipeiMarch13 2003 Chapter1 preface Thepurposeandcontentsofthecourse IntroducemostuseddatastructuresandalgorithmsPrerequisiteofothercoursesIntroducealgorithmanalysisReviewC Thepurposeandcontentsofthecourse 1 Introducemostuseddatastructuresandalgorithm

2、s Useproperdatastructurestosolvedifferentproblems Example GameproblemManagementoflibrarycataloguebycomputerManagementofthetrafficlightsinintersections Thepurposeandcontentsofthecourse Example1 Gameproblem Nextstep xhasfivechoices Thepurposeandcontentsofthecourse Example1usesatreestructure Thepurpose

3、andcontentsofthecourse Example2 Managementoflibrarycataloguebycomputer Itisalinearlist D S SartajSahni000001computer2000 1 Thepurposeandcontentsofthecourse Example3 Managementofthetrafficlightsinintersections C Eareone wayroad thereare13pathtogo Cangoatthesametime A BE CCannotgoatthesametime E BA D

4、Thisisagraph Thepurposeandcontentsofthecourse 2 Prerequisiteofothercourses Principlesofcompiling usestacktocomputeexpressionandimplementrecursiveprocedureOperatingSystem usequeuetoimplementjobschedulingDatabase useB treetoorganize storeandloadmassivedatainthehardmemory Thepurposeandcontentsofthecour

5、se 3 Basicmethodsofalgorithmanalysisstandardsoftheperformanceofanalgorithm timecomplexity spacecomplexity andaccuracy4 ReviewC WhatisDataStructure 1 Dataisthecarrierofinformation Dataisasetofnumbers characters andothersymbolsthatcanbeusedtodescribetheobjectivethings Thesesymbolscanbeinputintocompute

6、rs identifiedandprocessedbythecomputerprogram WhatisDataStructure Datacandividedintotwoclasses numericaldata int float complex non numericaldata character string graph voice WhatisDataStructure DatastructureAdatastructureisadataobjecttogetherwiththerelationshipsamongthedatamembersthatcomposetheobjec

7、tData Structure D R isadataobject RisalimitedsetofrelationshipsofallthedatamembersinD WhatisDataStructure LinearstructureDatastructureNon linearstucture ADTandOO 1 DatatypeDefinition isasetofvaluestogetherwithaoperationsetthatoperateonthesevalues Example inttypevalueset 2 1 0 1 2 operationset ADTand

8、OO Mostoftheprogramminglanguagesprovideagroupofpredefineddatatype Atomdatatype int float double Structuredatatype array struct ADTandOO 2 ADTs AbstractDataTypesAbstract isamethodusedtohidetheinformation Example intx floatx y x 735 x x y 3 0 abstractofintdatatypeabstractoffloatdatatypeassignmentopera

9、tion ADTandOO Abstractdatatype isanewprogrammingmethodthatparttheusageandimplementation inordertoencapsulateandhidetheinformation ADTNaturalNunberisobjects 一个整数的有序子集合 它开始于0 结束于机器能表示的最大整数 MAXINT Function Zero NaturalNumberIsZero x BooleanAdd x y NaturalNumberEqual x y BooleanSuccessor x NaturalNumber

10、Subtract x y NaturalNumberendNaturalNumber ADTandOO 3 OO object oriented object class inherit communicateobject attributevalues operatesclass objectsofsameattributesandoperates aninstanceisanobjectoftheclass differentobjecthasdeferentattributevalue ADTandOO Inherit baseclass integratethesamepart inc

11、ludingattributesandoperations inallthederivedclassesderivedclass addthespecificattributesandoperationstothebaseclassExample baseclass polygonderivedclass quadrilateral triangular ADTandOO Communication eachclassobjectcommunicatewithothersusingmessages Message instructionsthatoneclassobjectusedinorde

12、rtorequireanotherclassobjecttoperformsomeoperation Algorithmdefinition Algorithm anoperationsequenceofsolutingaproblemCharacteristic 1 finite2 deterministic3 initialaction4 sequenceends Algorithmdefinition Program 1 Programiswrittenbylanguagesthatcanbeperformedbymachine Algorithmhasmultipledescripti

13、vemethods suchaslanguage graph table 2 programcan tsatisfythefiniteness Forexample OS TemplatesinC Problem program1 1 intAbc inta intb intc returna b b c a b c a b 4 program1 2 floatAbc floata floatb floatc returna b b c a b c a b 4 TemplatesinC program1 1and1 2differonlyinthedatatypeoftheformalpara

14、metersandofthevaluereturned Wecanwriteagenericcodeinwhichthedatatypeisavariablewhosevalueisdeterminedbythecompiler Thisgenericcodeiswrittenusingthetemplatestatementinprogram1 3 TemplatesinC Program1 3templateTAbc Ta Tb Tc returna b b c a b c a b 4 Fromthisgenericcodethecompilercanconstruct1 1bysubst

15、itutingintforTand1 2bysubstitutingfloatforT Parameterpassing 1 ValueParameters Program1 1 templateTAbc Ta Tb Tc returna b b c a b c a b 4 z Abc 2 x y Parameterpassing 2 ReferenceParameterstemplateTAbc T RecursiveFunction 1 directrecursive2 indirectrecursiveExample1factorialfunctionf n n 1n1 recursiv

16、ecomponent f 5 5f 4 5 4f 3 5 4 3f 2 5 4 3 2f 1 120 f n RecursiveFunction intfactorial intn if n 1 return1 elsereturnn Factorial n 1 RecursiveFunction Example2 computesthesumoftheelementsa 0 througha n 1 Program1 9 a 0 a 1 a n 2 a n 1 RecursiveFunction TemplateTRsum Ta intn if n 0 returnRsum a n 1 a n 1 return0 RecursiveFunction Example3 Permutation Program1 10 a b c abc acb bac bca cab cbapermutationofnelementshasn RecursiveFunction Templatevoidperm Tlist intk intm inti if k m for i 0 i m i cout

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号