• DLL_Vs_CLL


    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.

     SinglyDoublyCircular
    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
  • 相关阅读:
    Windows PE变形练手3-把通用模板机器码直接覆盖目标PE
    Windows PE变形练手2-开发一套自己的PE嵌入模板
    R3抹掉加载的DLL
    R3获取kernel32地址
    Windows PE变形练手1-用PE自己的机器码修改自己的逻辑
    Windows PE 第十三章 PE补丁技术
    Windows PE 第十二章 PE变形技术
    16.PHP_Ajax模拟服务器登录验证
    15.PHP_PHP与Ajax
    14.PHP_PHP与XML技术
  • 原文地址:https://www.cnblogs.com/szzshi/p/7093418.html
Copyright © 2020-2023  润新知