在排序列表中递归插入、删除检索

发布于 2025-01-03 16:31:42 字数 161 浏览 0 评论 0原文

大家好,我不太明白以下教程问题: 编写一个ADT排序列表,插入、删除和检索操作必须递归实现。 [注意:递归要求可以通过实现插入/删除或检索方法中使用的递归搜索函数来实现。

如何实现一种方法可以完成三件事? 我知道教授要求实现一个搜索方法,但是插入删除检索需要不同的操作。

谢谢

Hi Guys I don't quite understand the following tutorial question:
write a ADT sorted list, The insertion, deletion and retrieval operations must be implemented recursively. [Note: The recursive requirement could be achieved by implementing a recursive search function that is used within the insertion/deletion or retrieval methods.

How can you implement one method that does 3 things?
I know that the professor is asking to implement a search method, but inserting deleting retrieving requires different operations.

thanks

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

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

发布评论

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

评论(1

2025-01-10 16:31:42

您的教授说您可以使用搜索方法作为实现插入或删除的方式的一部分。抽象地说,您有三个任务:

search(x):  find where x should appear in the sorted list, then return it
insert(x):  find where x should appear in the sorted list, then put it there
delete(x):  find where x should appear in the sorted list, then remove it

插入和删除方法的查找 x 应出现在排序列表中的位置 部分可以使用您的搜索实现来实现。

您的教授并不期望您编写一种可以完成所有三件事的方法,而是提示您可以在插入和删除方法中使用您的搜索方法。

Your professor is saying that you can use the search method as part of the way you achieve insert or delete. Abstractly, you have three tasks:

search(x):  find where x should appear in the sorted list, then return it
insert(x):  find where x should appear in the sorted list, then put it there
delete(x):  find where x should appear in the sorted list, then remove it

The find where x should appear in the sorted list part of both the insert and delete methods could be achieved using your implementation of search.

You professor isn't expecting you to write one method that does all three things, but instead is giving you the hint that your search method can be used inside your insert and delete methods.

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