KNOW: List, Stack, Queue

本文概要介绍了信息技术领域的关键数据结构如链表、栈、队列、堆等,以及常用算法如排序、搜索、动态规划等,强调了它们在实际应用中的重要性和实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CH 3 in DS and AA

List

Implementation Ways

1. Simple Array Implementation of List

- Insert and Delete are expensive O(N)

2. Linked List

Linked List consists of a series of structures, which are not necessarily adjacent in memory. Each structure contains the element and a pointer to a structure containing its successor. The last cell's Next pointer points to NULL.

PrintList(L) or Find(L,Key)will just traverse the list by following the Next pointers.O(N)

FindKth(L,i) takes O(i) and works by traversing down the list.

Insert and Delete takes constant time O(1)

Linked List Implementation

http://blog.youkuaiyun.com/b_end_an/article/details/9395813


Stack

A stack is a list with the restriction that insertions and deletions can be performed in only one position, namely, the end of the list, called the top.

The fundamental operations on a stack are Push(insert),Pop(delete) and Top.

Stacks are sometimes known as LIFO(last in, first out) list.

Implementation Ways

1. Linked List implementation

+ All operations take constant time

- calls to malloc and free are expensive

2. Simple Array implementation

- We need to declare an array size ahead of time.

Linked List Implementation

http://blog.youkuaiyun.com/b_end_an/article/details/9867565


Queue

For queue, insertion is done at one end, whereas deletion is performed at the other end.

Basic operations for queue:Enqueue (insert an element at the end of the list), Dequeue(deletes/return the element at the start of the list)

Any list implementation is legal for queues, and every operation takes O(1) running time.

Circular Array Implementation

http://blog.youkuaiyun.com/b_end_an/article/details/9938179





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值