What is the time complexity of a removing middle element from a doubly linked list?

Delete a node in a Doubly Linked List

Pre-requisite: Doubly Link List Set 1| Introduction and Insertion

Write a function to delete a given node in a doubly-linked list.
Original Doubly Linked List

What is the time complexity of a removing middle element from a doubly linked list?

Delete middle of linked list

Given a singly linked list, delete the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the linked list should be modified to 1->2->4->5

If there are even nodes, then there would be two middle nodes, we need to delete the second middle element. For example, if given linked list is 1->2->3->4->5->6 then it should be modified to 1->2->3->5->6.
If the input linked list is NULL, then it should remain NULL.

If the input linked list has 1 node, then this node should be deleted and a new head should be returned.

Singly Linked List vs Doubly Linked List

Before looking at the differences between the singly linked list and doubly linked list, we first understand what is singly linked list and doubly linked list separately.

About Linked List

Linked List is a one of the DataStructure used for storing collection of data. A Linked List has the following properties:

  1. A Linked List is linear dynamic DataStructure.
  2. The number of nodes in Linked List is not fixed, it can grow and shrink on demand.
  3. Each node of the Linked List is made up of two items - the data and a reference to the next node.
  4. The Last node has reference to null.
  5. The entry point is called head
  6. If the list is empty then the head is null reference.

Basic Structure of Linked List-