# Merge Sort for Doubly Linked List

JAVA Programming-Merge Sort for Doubly Linked List – Searching and Sorting – Merge sort for singly linked list is already discussed. The important change here is to modify the previous pointers also when merging two lists.

Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort.

For example, the following doubly linked list should be changed to 2<->4<->8<->10

The important change here is to modify the previous pointers also when merging two lists.

Doubly Linked List (DLL) is a list of elements and it varies from Linked List. It allows navigation, either forward or backward when compared to Single Linked List. It has two pointers: previous pointer and next pointer. Every element points to next of the list and previous element in list.

Terms used in doubly linked list:

• Next
• Prev

### Output:

```Linked List after sorting
Forward Traversal using next pointer
3 4 5 10 20 30
Backward Traversal using prev pointer
30 20 10 5 4 3```

Time Complexity: Time complexity of the above implementation is same as time complexity of MergeSort for arrays. It takes Θ(nLogn) time.

## [ Solution 1 Answers ] Class Is Public, Should Be Declared In A File Named .Java

PROBLEM: When the class name and the filename of a given Java program doesn’t match then we will get this error. Considering an example where the file is named as…

## Top 10 Grey Hat Hackers 2018

Grey hat hackers that do hacking bit the ethical and non-ethical. These are the persons who knows extraordinary hacking traps

## C++ Programming – Program to add two polynomials

C++ Programming – Program to add two polynomials – Mathematical Algorithms – Addition is simpler than multiplication of polynomials. We initialize result

## C++ Algorithm – Write a function to reverse a linked list

Cpp Algorithm – Write a function to reverse a linked list – Linked List – Given pointer to the head node of a linked list, the task is to reverse

## C Programming – Backtracking | Set 6 (Hamiltonian Cycle)

C Programming – Backtracking – Hamiltonian Cycle – Create an empty path array and add vertex 0 to it. Add other vertices, starting from the vertex 1

## Get current URL in web browser – JAVA

URL: JavaScript provides many methods to retrieve and change the current URL which is displayed in browser’s address bar. All these methods uses the Location object, which is a property…