MIPS 中的链表 - 例子?
我正在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论