文件名称:4
-
所属分类:
- 标签属性:
- 上传时间:2015-12-01
-
文件大小:2.41kb
-
已下载:1次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
通过扩展已实现的基本数据结构,模拟更为复杂的数据结构,是一种常见而实用的技巧。这里,我们将利用栈结构,来模拟一种功能增强的队列。
具体来说,你必须首先实现一个元素类型为int的栈,该栈能且只能支持以下操作接口:
bool empty() //判断是否栈空
void push(int) //向栈中压入一个整数
int pop() //弹出栈顶元素,并返回其数值
int top() //仅获取栈顶元素的值,但不弹出
接下来,你必须借助以上栈结构,模拟所谓的队堆(queap)结构,它至少支持以下操作接口:
void enqueue(int) //新元素作为尾元素入队
int dequeue() //队首元素出队,并返回其数值(调用时输入数据保证队列非空)
int min() //返回队列内的最小元素(调用时输入数据保证队列非空)
可见,这种结构之所以称作队堆,是因为它兼具一定的队列(queue)和堆(heap)的功能。
最后,你还需要通过一系列真实的查询和修改操作,对所实现的队堆结构进行测试。-Expansion has been achieved through a column of basic data structures, simulate more complex data structures, is a common and practical skills. Here, we will use the stack structure to simulate a feature enhanced queue.
Specifically, you must first implement an element of type int stack, the stack can and only supports the following user interface:
bool empty () // determine whether the stack empty
void push (int) // to stack pressed into an integer
int pop () // pop the top element, and returns its value
int top () // get only the value of the stack elements, but does not pop up
Next, you must use the above stack structure, simulate the so-called Team heap (queap) structure, which supports at least the following interfaces:
void enqueue (int) // a new element into the team as the last element
int dequeue () // element of the first team squad, and returns its value (input data to ensure that the queue is not empty when you call)
int min () // Returns the
具体来说,你必须首先实现一个元素类型为int的栈,该栈能且只能支持以下操作接口:
bool empty() //判断是否栈空
void push(int) //向栈中压入一个整数
int pop() //弹出栈顶元素,并返回其数值
int top() //仅获取栈顶元素的值,但不弹出
接下来,你必须借助以上栈结构,模拟所谓的队堆(queap)结构,它至少支持以下操作接口:
void enqueue(int) //新元素作为尾元素入队
int dequeue() //队首元素出队,并返回其数值(调用时输入数据保证队列非空)
int min() //返回队列内的最小元素(调用时输入数据保证队列非空)
可见,这种结构之所以称作队堆,是因为它兼具一定的队列(queue)和堆(heap)的功能。
最后,你还需要通过一系列真实的查询和修改操作,对所实现的队堆结构进行测试。-Expansion has been achieved through a column of basic data structures, simulate more complex data structures, is a common and practical skills. Here, we will use the stack structure to simulate a feature enhanced queue.
Specifically, you must first implement an element of type int stack, the stack can and only supports the following user interface:
bool empty () // determine whether the stack empty
void push (int) // to stack pressed into an integer
int pop () // pop the top element, and returns its value
int top () // get only the value of the stack elements, but does not pop up
Next, you must use the above stack structure, simulate the so-called Team heap (queap) structure, which supports at least the following interfaces:
void enqueue (int) // a new element into the team as the last element
int dequeue () // element of the first team squad, and returns its value (input data to ensure that the queue is not empty when you call)
int min () // Returns the
(系统自动生成,下载前可以参看下载内容)
下载文件列表
PA2.vcxproj
PA2.vcxproj.filters
4.cpp
PA2.vcxproj.filters
4.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.