什么是隐式数据结构?而堆是实现优先级队列的隐式数据结构吗?

发布于 2024-12-28 09:12:44 字数 87 浏览 5 评论 0原文

我的问题可能看起来很幼稚,但我真的不明白这个问题,因为我只是数据结构课程的新手。我确实知道最大和最小堆如何工作,但我不确定堆是否是实现优先级队列的隐式数据结构。

My question might seem childish but I really don't understand this question as I am just a newbie to data structures course. I do know how max and min heap work, but I am not sure that whether heap is implicit data structure to implement priority queue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2025-01-04 09:12:44

维基百科已备份:D

来自文章

在计算机科学中,隐式数据结构是一种除了实际数据元素之外使用很少内存的数据结构......

所以是的,堆符合要求,因为它可以实现为简单的数组。实现优先级队列的堆将是隐式数据结构,但不是因为它实现了优先级队列。这是因为堆不使用任何特殊的东西来跟踪其元素,仅使用数组位置。

另外,我完全不同意你朋友的解释。任何问题都没有“自然”的数据结构,只有在特定情况下恰好非常方便的数据结构。

计算和数据结构是抽象概念,可以通过多种不同方式实现。链表可以在堆上、在硬盘上、在互联网上、以一堆带有便签和下一个人的电话号码的人的形式实现。将它们的整个集合称为用于某些特定问题的“自然”数据结构是错误的。

Wikipedia is back up :D

From the article:

In computer science, an implicit data structure is a data structure that uses very little memory besides the actual data elements...

So yes, a heap would fit the bill because it can be implemented as a simple array. A heap that is implementing a priority queue would be an implicit data structure, but not because it's implementing a priority queue. It's because heaps don't use anything special to keep track of its elements, only the array location.

Also, I completely disagree with your friend's interpretation. There is no "natural" data structure for any problem, only ones that happen to be very convenient under the circumstances.

Computing and data structures are abstract ideas that can be implemented in many different ways. A linked list can be implemented on the heap, on the hard drive, over the internet, and in the form of a bunch of people with sticky notes and the next person's phone number. Calling the whole set of them a "natural" data structure to use for some particular problem is wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文