目录
列表是一种常见的 ADT,用于保存有序数据,具有附加数据项、删除数据项、搜索数据项是否存在以及打印列表等操作。
List ADT 常见操作
相关操作 | 描述 |
---|---|
Append(list, x) | Inserts x at end of list |
Prepend(list, x) | Inserts x at start of list |
InsertAfter(list, w, x) | Inserts x after w |
Remove(list, x) | Removes x |
Search(list, x) | Returns item if found, else returns null |
Print(list) | Prints list’s items in order |
PrintReverse(list) | Prints list’s items in reverse order |
Sort(list) | Sorts the lists items in ascending order |
IsEmpty(list) | Returns true if list has no items |
GetLength(list) | Returns the number of items in the list |