博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DLL_Vs_CLL
阅读量:4542 次
发布时间:2019-06-08

本文共 2887 字,大约阅读时间需要 9 分钟。

What is Circular Linked List ? What are Advantages and Disadvantages of Circular Linked List

 

 

 
 

 

In it the last node does not contain NULL pointer. Instead the last node contains a pointer that has the address of first node and thus points back to the first node. 

It is shown below: 
Circular Linked List
Advantages: 
1. If we are at a node, then we can go to any node. But in linear linked list it is not possible to go to previous node.
2. It saves time when we have to go to the first node from the last node. It can be done in single step because there is no need to traverse the in between nodes. But in double linked list, we will have to go through in between nodes. 
Disadvantages: 
1. It is not easy to reverse the linked list.
2. If proper care is not taken, then the problem of infinite loop can occur.
3. If we at a node and go back to the previous node, then we can not do it in single step. Instead we have to complete the entire circle by going through the in between nodes and then we will reach the required node. 

Advantages of Doubly linked list over singly linked list

1) A doubly linked list can be travel across in both forward and backward direction.
2) For delete operation a pointer to previous node is needed that is difficult in singly linked list so we need to traverse the list but in doubly linked list the previous node can be found easily using previous pointer.

Disadvantages of Doubly linked list over singly linked list
1) In doubly linked list extra space is required for previous pointer.

2) In all operations like insertion and deletion, an extra pointer (previous pointer) has to be maintained.

 

Circular Linked List

In Circular linked list all nodes are connected in such way that they form a circle and no NULL at the end of the list like a circle.

Advantages of Circular Linked Lists:

1) In this linked list any node can be a starting point. And to traverse list, we can start at any point and stop when the first node is visited again.

2) Unlike doubly linked list, in this linked list we don’t need to focus on two pointers for next and previous. So it is useful implementing a queue.

3) It is also useful for repeating list. For example operating system, so that when it reaches the end of the list of all application it can go to the front of the list

4) Circular DLL are used to implement advanced data structures like Fibonacci Heap.

 

Singly, Doubly & Circular Linked List

 
This is a basic type of Linked List.
  Singly Doubly Circular
Concept One way direction Two way direction One way direction in a circle
Has head Yes Yes No-because tail will refer to first node
Has tail Yes Yes Yes
No of Node 1-next node 2-next node & previous node 1-next node
insert() O(n) O(1) O(n)
delete() O(n) O(1) O(1)
Benefit require small space for each element allow to traverse the list in both directions execute to the end can be quickly

转载于:https://www.cnblogs.com/szzshi/p/7093418.html

你可能感兴趣的文章
JavaScript表单验证
查看>>
MySql表结构修改详解
查看>>
errno多线程安全(转载)
查看>>
使用maven和svn进行版本控制
查看>>
【bzoj2959】长跑【LCT+并查集】
查看>>
.NET 框架 Microsoft .NET Framework (更新至.NET Framework4.8)
查看>>
医院院长修电脑
查看>>
Android工程方法数超过65535的解决办法
查看>>
深度学习面试
查看>>
asp.net之DataList的使用方法,及分页(存储过程创建),编辑,更新,删除
查看>>
JQuery弹出层,点击按钮后弹出遮罩层,有关闭按钮【转】
查看>>
Codeforces 138D World of Darkraft
查看>>
CentOS 6.4 64位 搭建MySQL-Cluster 7.3.8 集群
查看>>
操作headers
查看>>
[zz] linux kill 进程
查看>>
普林斯顿大学算法课 Algorithm Part I Week 3 比较器 Comparators
查看>>
MySQL之增删改查
查看>>
zeromq示例代码
查看>>
数据库知识点积累
查看>>
好看的背景
查看>>