我在一些地方正在阅读与此主题相关的东西,例如在这里
答案是:
优先级队列和堆都是数据类型(更准确;抽象数据类型或ADT)
但在这里
堆不是ADT。它是一个数据结构。
例如,在书中:
Java软件结构,国际版[John Lewis,Joseph Chase]
它具有作为ADT的堆和具有以下代码的DS:
public interface HeapADT<T> extends BinaryTreeADT<T>
{
/**
* Adds the specified object to this heap.
*
* @param obj the element to be added to this heap
*/
public void addElement (T obj);
/**
* Removes element with the lowest value from this heap.
*
* @return the element with the lowest value from this heap
*/
public T removeMin();
/**
* Returns a reference to the element with the lowest value in
* this heap.
*
* @return a reference to the element with the lowest value in this heap
*/
public T findMin();
}
主要问题是,例如,我们是否说DS的所有行为定义都是ADT,
因此,抽象数据类型是您将使用具有自己的ADT的另一个数据结构实现的行为。
这样对吗?
谢谢
正如您所说的,抽象数据类型描述了实体的行为(或“语义”)(通常从使用该实体的人的角度来看)。因此,在您的示例中,堆栈,队列,列表等...
数据结构只是组织数据的一种特殊方式。因此,这只是表示数据类型的一种方式。
主要问题是,如果我们说DS的所有行为定义都是ADT
我不会那样说。如果我定义一个表示经典示例的Car
数据结构(同样,将数据结构视为组织数据的一种方式),则该数据结构的行为不一定表示ADT。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句