Link to home
Start Free TrialLog in
Avatar of soodsandeep
soodsandeepFlag for India

asked on

Linear vs Non Linear Data Structure

Hello experts,
please tell me
1. what is difference between Linear and Non Linear Data Structures ?
Linear are - Array, Linked List, Stack, Queue
Non Linear are - Tree, Graph
2. In which category does Heap Come ?
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
>>Linear are - Array, Linked List, Stack, Queue

In the above category Linked List will not come as Liniear, also Stack and Queue we can implement as NonLinear. Array is the perfect example of Linear


>> In the above category Linked List will not come as Liniear, also Stack and Queue we can implement as NonLinear.

No, not true. See my explanation. And if you don't believe me, see the links evilrix posted.
Sorry, i confused with Sequential and NonSequential Data Structures.

Avatar of meoconx
meoconx

Linear or non-linear depend on how you search an element with a specified key.
In linear structure, when you find an key, you have to begin at the first element in the structure and go down to when you meet the key you want to find.
And non-linear is of course not linear  :) => when you do a search in a non-linear structure is generally faster than linear structure .
in Heap, we needn't care whether it's linear or not, because the main purpose of heap is make us easily to obtain max or min key of the data structure.
>> Linear or non-linear depend on how you search an element with a specified key.

That's not what defines linear versus non-linear (see my post for that ;) ). If a linear data structure, like an array for example, is sorted, you can often search as fast as with say a binary tree.

Or, look at it from a different perspective : linked lists and arrays are two linear data structures, yet the way search algorithms are implemented with them are quite different. Queues and stacks are other examples of linear data structures, but there's usually no need for searching in them, so again : search strategies are not a defining characteristic of linear versus non-linear data structures.
I am not sure that your question is well-defined enough to give an answer.
On the one hand if you would like a definition of linear vs. non-linear data structures one could certainly be manufactured.  Whether the definition would be useful for your purposes is another question.  

The referenced wikipedia page is basically trying to define the difference through examples.  On this page linear data structures are basically one dimensional and non-linear have more than one dimension.
This is consistent with what one finds In text books where typical examples of linear are lists and one-dimensional arrays and typical examples of non-linear are graphs (including trees) and arrays of 2 or more dimensions.  This is basically what the wikipedia page is saying but some unfortunate choice of terminology confuses the issue.  e.g., the page lists a matrix and a sparse matrix as being linear but from the context I think the author meant only to include one-dimensional matrices.  Including "Parallel Array" in the linear category may be debatable.

You can find consistent categorization of linear vs non-linear in many data strures books.
Avatar of soodsandeep

ASKER

Thanks Infinity08 !
i m ur fan. get many excellent answers from u.
thanks.
I'm glad to be of assistance :)