西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_链式栈与队列 Chapter 4 Linked Stacks and Queues(英文)

Chapter 4 Linked Stacks and Queues I1 Pointers and Linked Structures I 2. Linked Stacks 3. Linked Stacks with Safeguards 4. Linked Queues 5. Application: Polynomial Arithmetic 6. Abstract Data Types and Implementations 7. Pointers and Pitfalls
Chapter 4 Linked Stacks and Queues 1. Pointers and Linked Structures 2. Linked Stacks 3. Linked Stacks with Safeguards 4. Linked Queues 5. Application: Polynomial Arithmetic 6. Abstract Data Types and Implementations 7. Pointers and Pitfalls

4.1 Pointers and a Linked List A Linked list is a Lynn sequence of zero o Jack more elements called nodes each containing Q Dave two kinds of Marsha information: some data and one or more FRed Jackie links called pointers to 367-2205 2950603 Jan 28 Feb 18 other nodes of the Carol Rene linked list 628-5100 3425153 Feb23 Mar. 15
A Linked List is a sequence of zero or more elements called nodes each containing two kinds of information: some data and one or more links called pointers to other nodes of the linked list. 4.1 Pointers and a Linked List

Head 日-[a[a→…→a囚 Head Head an Head

Key Terms ◆ Overflow Running out of space ◆ Pointer: An object, often a variable, that stores the location(that is the machine address) of some other object, typically of a structure containing data that we wish to manipulate. Also sometimes called a link or a reference) ◆ Linked list: A list in which each entry contains a pointer giving the location of the next entry
Key Terms Overflow: Running out of space. Pointer: An object, often a variable, that stores the location (that is the machine address) of some other object, typically of a structure containing data that we wish to manipulate. (Also sometimes called a link or a reference) Linked list: A list in which each entry contains a pointer giving the location of the next entry

◆ Contiguous Next to each other, touching, adjoining; used in contrast to linked ◆ Automatic object: An object that exists as long as the block of program declaring it is active; referenced by giving it a name when writing the program ◆ Dynamic object An object that is created (and perhaps destroyed) while the program is running accessed indirectly via pointers
Contiguous: Next to each other, touching, adjoining; used in contrast to linked. Automatic object: An object that exists as long as the block of program declaring it is active; referenced by giving it a name when writing the program. Dynamic object: An object that is created (and perhaps destroyed) while the program is running; accessed indirectly via pointers

Pointers in c++ ◆ Notation: C++ uses an asterisk to denote a pointer. If Item is a type, then a pointer to such an Item object has the type Item For example, Item item ptr; declares item ptr as a pointer variable to an Item object Creating dynamic objects item ptr= new Item; creates a new dynamic object of type Item and assigns its location to the pointer variable item_ptr
Pointers in C++ Notation: C++ uses an asterisk * to denote a pointer. If Item is a type, then a pointer to such an Item object has the type Item *. For example, Item *item ptr; declares item ptr as a pointer variable to an Item object. Creating dynamic objects: item_ptr = new Item; creates a new dynamic object of type Item and assigns its location to the pointer variable item_ptr

The dynamic objects that we create are kept in an area of computer memory called the free store for the heap). Deleting dynamic objects delete item_ptr; disposes of the dynamic object to which item_ ptr points and returns the space it occupies to the free store so it can be used again. After this delete statement is executed. the pointer variable item_ptr is undefined and so should not be used until it is assigned a new value
The dynamic objects that we create are kept in an area of computer memory called the free store (or the heap). Deleting dynamic objects: delete item_ptr; disposes of the dynamic object to which item_ptr points and returns the space it occupies to the free store so it can be used again. After this delete statement is executed, the pointer variable item_ptr is undefined and so should not be used until it is assigned a new value

◆ Following pointers item _ptr denotes the object to which item_ptr points. The action of taking item ptr is called referencing the pointer *item_ptr. ◆ NULL pointers If a pointer variable item_ ptr has no dynamic object to which it currently refers then it should be given the special value item_ptr= NULL
Following pointers: *item_ptr denotes the object to which item_ptr points. The action of taking “ *item_ptr is called *referencing the pointer *item_ptr.” NULL pointers : If a pointer variable item_ptr has no dynamic object to which it currently refers, then it should be given the special value item_ptr = NULL;

In diagrams we reserve the electrical ground symbol for NULL pointers. The value null is used as a constant for all pointer types and is generic in that the same value can be assigned to a variable of any pointer type
In diagrams we reserve the electrical ground symbol for NULL pointers. The value NULL is used as a constant for all pointer types and is generic in that the same value can be assigned to a variable of any pointer type

Undefined pointers versus NULL pointers item_ptr=NULL means that item_ _ptr currently points to no dynamic object. If the value of item_ptr is undefined, then item_ ptr might point to any random location in memory. important data Random pointer p=new Item 19 884 0 important data 1375 p=1375 p=0 Random pointer 0 G→ ??? p= NULL Random pointer =0 delete p Please modify Pgll8 Figure 4.3 code is c, not c++
Undefined pointers versus NULL pointers : item_ptr = NULL means that item_ptr currently points to no dynamic object. If the value of item_ptr is undefined, then item_ptr might point to any random location in memory. Please modify Pg118 Figure4.3 code is c,not c++
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_队列 Chapter 3 QUEUES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_栈 Chapter 2 INTRODUCTION TO STACKS(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_大规模程序开发 Chapter 1 PROGRAMMING PRINCIPLES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_数据结构导言(中文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_C++回顾(C++编程简介,中文).ppt
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)用Dijkstra方法求最短路径.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)中缀表达式转后缀表达式.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)查找最短路径.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)四则运算计算器.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)图书馆系统.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)十进制数转化为其他进制的数.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)查找性能比较.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)列车车票查询.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)平衡二叉树.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)录像带商店.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)前缀算术表达式转换成中缀算术表达式.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)文本行编辑系统.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)农夫过河问题.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)哈夫曼编码.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)数学排列.doc
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_递归 Chapter 5 RECURSION(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第三部分 线性表_线性表 Chapter 6 LISTS AND STRINGS(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_查找 Chapter 7 SEARCHING(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_排列 Chapter 8 SORTING(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_检索 Chapter 9 Tables And Information Retrieval(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第五部分 树结构_二叉树 Chapter 10 BINARY TREES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第五部分 树结构_多叉树 Chapter 11 MULTIWAY TREES(英文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第一部分 绪论(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第二部分 线性表(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第三部分 栈、队列、递归方法(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第四部分 树与二叉树(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第五部分 图(中文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第六部分 图结构_图 Chapter 12 GRAPHS(英文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第六部分 排序(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第七部分 查找(中文).ppt
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第一部分 绪论_大规模程序开发 PROGRAMMING PRINCIPLES(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_栈 INTRODUCTION TO STACKS(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_队列 Queues(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_递归 RECURSION(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_链式栈与队列 LINKED STACKS AND QUEUES(英文).doc