Is Heap considered an Abstract Data Type?
I would try to clarify about this confusion other way round. Quoting wikipedia from here:
While priority queues are often implemented with heaps, they are conceptually distinct from heaps. A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods such as an unordered array.
So heap is just an implementation of Priority Queue abstract data type(ADT) which can be implemented in many other listed below but might no be limited to:
- Unordered Array
- Unordered List
- Ordered Array
- Ordered List
- Binary Search Tree (BST)
- Balanced Binary Search Tree (AVL-tree)
- Binary heap (asked by OP)
Comparing the time efficiency of heap implementation for main operations in Priority Queue ADT with other possible implementations:
----------------------------------------------------------------------------
| Implementation | Insertion | Deletion(DeleteMax/DeleteMin)|Find Max/Min
----------------------------------------------------------------------------
| Unordered Array| 1 | n | n
----------------------------------------------------------------------------
| Unordered List | 1 | n | n
----------------------------------------------------------------------------
| Ordered Array | n | 1 | 1
----------------------------------------------------------------------------
| Ordered List | n | 1 | 1
----------------------------------------------------------------------------
| BST | logn (avg.) | logn (avg.) | logn (avg.)
----------------------------------------------------------------------------
| Balanced BST | log n | log n | log n
----------------------------------------------------------------------------
| Binary Heaps | log n | log n | 1
Heap is not an ADT. It is a Data Structure.
The obligatory Wikipedia quote:
In computer science, an abstract data type (ADT) is a mathematical model for data types where a data type is defined by its behavior (semantics) from the point of view of a user of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. This contrasts with data structures, which are concrete representations of data, and are the point of view of an implementer, not a user.
Bonus content inspired from Code Complete - 2 by Steve McConnell.
Data Structures are low-level implementation domain items, in contrast with ADTs which work in the problem domain. ADTs let you manipulate real-world entities rather than low-level, implementation entities. Instead of inserting a node into a linked-list or adding an item to a heap, you can add a cell to a spreadsheet, a new type of window to window types, or another passenger to a train simulation.
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.
However, if you simulate a game of Tetris where adding a new block will simply go and sit on top of wherever it falls, this Tetris game's UI will actually be an ADT.