arrays - 关于使用数组的双向链表的问题
问题描述
嗨,我们开始谈论数据结构,我无法为这个问题想出一个代码这基本上是一个双向链表的 3 个数组实现,P(上一个指针)/N(下一个指针)/D(数据)但我无法理解如何在函数之外使用新数组?我的意思是根据我的理解,我们得到了一个数组,我们正在操纵它,但这只是让我困惑新数组是如何发挥作用的。
同样在后续问题中,它们是指复杂性还是我们需要执行的每个操作?顺便说一句,这是我第一次编写psedueocode,看起来还好吗?
InsertFirst(k)
if (Free ≠ -1) then
q = free
else //Create new arrays
newArray ➜ newD(2n)
newArray ➜ newP(2n)
newArray ➜ newN(2n)
for i=0 ➜ n
newD[i] = D[i]
newP[i] = D[i]
newN[i] = D[i]
newD[q] = k //Insert first if list is full
Free = newN[Free]
newN[q] = L
newP[L] = q
L = q
return
D[q] = k //Insert first if list is not full
Free = N[Free]
N[q] = L
P[L] = q
L = q
return
解决方案
推荐阅读
- python - 如何在 graphql 响应中发送授权标头?
- asp.net - 通过 FTP 发布 .NET Core 3.1 应用程序时出现错误代码 550
- c - 设置主题窗口的标题
- flutter - Flutter Stack 未对齐浮动操作按钮
- asp.net-mvc - SqlException:列名“LCityCityID”无效
- wordpress - wordpress 解析错误:语法错误,文件意外结束
- java - 弹簧设置和安装
- python - 在目录中运行 OS 命令
- lua - 如何导入 luarocks 本地模块
- javascript - 如何在 Firestore 中获取上一个文档