【问题标题】:insertion, deletion retrieval recursively in sorted list在排序列表中递归地插入、删除检索
【发布时间】:2012-02-29 14:38:49
【问题描述】:

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

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

谢谢

【问题讨论】:

  • 不,它的额外工作,如果我想这样做,由我决定。

标签: java data-structures recursion linked-list


【解决方案1】:

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

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

插入和删除方法的find where x should appear in the sorted list 部分可以使用您的搜索实现来实现。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-14
    • 1970-01-01
    相关资源
    最近更新 更多