堆是否被视为抽象数据类型? [英] Is Heap considered an Abstract Data Type?

查看:89
本文介绍了堆是否被视为抽象数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上数据结构课程,对什么是ADT(抽象数据类型)和什么不是(如果不是ADT则必须是实现)感到有些困惑。 )。

I'm taking Data-Structure course and got a little confused about what is considered to be an ADT (Abstract Data Type) and what isn't (and if it isn't an ADT then it must be the implementation?).

具体地说,我在说堆。

我在Wikipedia中读过堆基于树的专用数据结构是否意味着它是ADT?如果是这样,那么我也无法理解维基百科的以下内容:堆是一种称为优先级队列的抽象数据类型的最大有效实现。

I've read in Wikipedia that " heap is a specialized tree-based data structure" does that mean it is an ADT? if so, then I can't understand the following line, also from Wikipedia "The heap is one maximally efficient implementation of an abstract data type called a priority queue".

我的意思是,Heap既可以是ADT,也可以是其他一些ADT的实现(在这种情况下,是优先级队列的实现?我了解ADT的概念,并且在Binary Heap的上下文中,我了解可以使用数组来实现,其中 arr [i] arr [2i] arr [2i + 1 ]
我只是对一个堆是否可以一方面是使用数组实现的ADT,另一方面是可以实现其他ADT的数据结构感到困惑。

I mean, can Heap be an ADT and also be an implementation of some other ADT (in this case an implementation of priority queue? I understand the concept of ADT and in the context of Binary Heap I understand that it can be implemented using array where arr[i] is the parent of arr[2i] and arr[2i + 1] I'm just confused about whether a Heap can be in one hand an ADT which implemented using array and on the other hand a data-structure that implements other ADT.

想对此进行一些澄清。

推荐答案

堆是

维基百科的强制性报价:

The obligatory Wikipedia quote:


在计算机科学中,抽象数据类型(ADT)是用于数据类型的数学
模型,其中数据类型由其行为
(语义)从数据用户的角度来定义,特别是
就可能的值,对此类数据的可能操作,
以及这些操作的行为而言。这与数据
结构相反,后者是数据的具体表示形式,是实现者而不是用户的
观点。

奖金内容受Steve McConnell的Code Complete -2启发。

数据结构是低级实现领域的项目,与在问题领域中工作的ADT相反。通过ADT,您可以操纵真实世界的实体,而不是底层的实现实体。您可以将单元格添加到电子表格,将新类型的窗口添加到窗口类型,或将另一名乘客添加到火车模拟中,而不是将节点插入到链表中或将项目添加到堆中。


  • 您可以清楚地看到堆已经定义了语义,例如insert(),heapify(),peek(),getTop( )等-在此处详细列出。因此,它是一个数据结构。

  • You can clearly see that heap has defined semantics like insert(), heapify(), peek(), getTop() etc. - listed here in detail. Hence it is a data structure.

但是,如果您模拟一个俄罗斯方块游戏,只需添加一个新块就可以了,坐在跌落的顶部,该俄罗斯方块游戏的用户界面实际上将是ADT。

这篇关于堆是否被视为抽象数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆