Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is doubly linked list a non linear data structure or linear data structure?

A linear data structure traverses the data elements sequentially, in which only one data element can directly be reached. Ex: Arrays, Linked Lists.

But in doubly linked list we can reach two data elements using previous pointer and next pointer.

So can we say that doubly linked list is a non linear data structure?

Correct me if I am wrong.

Thank you.

like image 605
Varun Teja Avatar asked May 27 '15 15:05

Varun Teja


People also ask

Is doubly linked list linear or nonlinear?

But, in doubly linked list, you have to move sequentially(linearly) only, to move forward(using forward pointer) or backward(using previous pointer). You can't jump from any element in the list to any distant element without traversing the intermediary elements. Hence, doubly-linked list is a linear data structure.

Are linked list considered linear or nonlinear?

A linked list is a linear data structure where elements are not stored at contiguous location. Instead the elements are linked using pointers.

Which data structure is used by doubly linked list?

In computer science, a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains three fields: two link fields (references to the previous and to the next node in the sequence of nodes) and one data field.

Is doubly linked list circular or linear?

Answer: The doubly linked list is a linear structure but a circular doubly linked list that has its tail pointed to head and head pointed to tail. Hence it's a circular list.


1 Answers

Non-linear data structures are those data-structure in which the elements appear in a non-linear fashion,which requires two or more than two-dimensional representation . The elements may OR mayn't(mostly) be stored in contiguous memory locations,rather in any order/non-linearly as if you have skipped the elements in between. Accessing the elements are also done in an out-of-order pattern.

Example :- A Tree, here one may iterate from root to right child,to its right child,... and so on---thereby skipping all the left nodes.

But, in doubly linked list, you have to move sequentially(linearly) only, to move forward(using forward pointer) or backward(using previous pointer). You can't jump from any element in the list to any distant element without traversing the intermediary elements.

Hence, doubly-linked list is a linear data structure. In a linear data structure, the elements are arranged in a linear fashion(that is,one-dimensional representation).

like image 59
Am_I_Helpful Avatar answered Sep 25 '22 17:09

Am_I_Helpful