MIPS 中的链表 - 例子?

发布于 2025-01-15 23:07:55 字数 298 浏览 2 评论 0原文

我正在 MIPS 中使用链接列表,并且有一个我不确定的示例。它说: 编写函数rotate(head, a, b),将链表的元素从位置a旋转到位置b,这样如果元素位于位置i(属于段a,b),则它的新位置是b+ai。选择数字a、b使得a<b。现在,我不明白这个例子的意思,因为在我们更改每个位置 i 的元素后,由于公式的原因,列表将保持不变(也认为列表中元素的位置从 1 开始,长度为列表)。

另外,对于列表中的每个节点,我认为仅替换相应索引的值字段就足够了(下一个字段不是必需的)。仅当我有列表元素真正发生变化的示例时(如果我上面的假设是正确的),我才会考虑最后一句话。

I am working with linked lists in MIPS, and have one example that I am not sure about. It says:
write function rotate(head, a, b) that rotates elements of linked lists from position a to position b, such that if element was on position i(that belongs segment a,b) its new position is b+a-i. Numbers a,b are choosen such that a<b. Now, I don't get point of this example, because after we change elements for every position i, list will stay the same because of the formula(also it is considered that position of elements in list starts with 1 and goes to length of list).

Also, for every node in list, I think it is enough to replace only value field for corresponding indexes right(next field is not neccessary). Last sentence I am considering only if I had example where elements of list would really change(if my assumption above is correct).

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文