- 1、本文档共55页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter12amp;ndash;DataStructures.ppt
Chapter 12 – Data Structures Objectives In this chapter, you will learn: To be able to allocate and free memory dynamically for data objects. To be able to form linked data structures using pointers, self-referential structures and recursion. To be able to create and manipulate linked lists, queues, stacks and binary trees. To understand various important applications of linked data structures. 12.1 Introduction Dynamic data structures Data structures that grow and shrink during execution Linked lists Allow insertions and removals anywhere Stacks Allow insertions and removals only at top of stack Queues Allow insertions at the back and removals from the front Binary trees High-speed searching and sorting of data and efficient elimination of duplicate data items 12.2 Self-Referential Structures Self-referential structures Structure that contains a pointer to a structure of the same type Can be linked together to form useful data structures such as lists, queues, stacks and trees Terminated with a NULL pointer (0) struct node { int data; struct node *nextPtr;} nextPtr Points to an object of type node Referred to as a link Ties one node to another node 12.3 Dynamic Memory Allocation 12.3 Dynamic Memory Allocation Dynamic memory allocation Obtain and release memory during execution malloc Takes number of bytes to allocate Use sizeof to determine the size of an object Returns pointer of type void * A void * pointer may be assigned to any pointer If no memory available, returns NULL Example newPtr = malloc( sizeof( struct node ) ); free Deallocates memory allocated by malloc Takes a pointer as an argument free ( newPtr ); 12.4 Linked Lists Linked list Linear collection of self-referential class objects, called nodes Connected by pointer links Accessed via a pointer to the first node of the list Subsequent nodes are accessed via the link-pointer member of the current node Link pointer in the last node is set to NULL to mark the list’s end Use a link
您可能关注的文档
最近下载
- 内江师范学院2021-2022学年第2学期《高等数学(下)》期末试卷(A卷)附标准答案.pdf
- 高思奥数一年级下册含答案第16讲 有趣的拆数.docx VIP
- 叉车安全考试题库及答案.doc VIP
- 新疆2024年高中学业水平考试化学试卷试题真题(含答案详解).docx VIP
- 卓长仁劫机案.doc VIP
- 国家建筑标准设计图集 23S519小型排水构筑物图集.pdf VIP
- 四年级语文下册期末试卷(人教版).doc VIP
- 金属塑性成形原理知到智慧树期末考试答案题库2024年秋山东建筑大学.docx VIP
- 《高效工作计划与目标管理培训课件》.ppt VIP
- 常见肿瘤标志物及临床意义.pptx VIP
文档评论(0)