We help IT Professionals succeed at work.

Linear vs Non Linear Data Structure

soodsandeep
soodsandeep asked
on
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 ?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009
Commented:
>> 1. what is difference between Linear and Non Linear Data Structures ?

Linear means that they are represented by one (single) series of data ... ie. Each data member has at most one predecessor and at most one successor.

Non-linear means anything else.


>> 2. In which category does Heap Come ?

non-linear, since it's a kind of tree :

        http://en.wikipedia.org/wiki/Heap_(data_structure)
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


evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> 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.

Commented:
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.
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> 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.

Commented:
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.

Author

Commented:
Thanks Infinity08 !
i m ur fan. get many excellent answers from u.
thanks.
CERTIFIED EXPERT
Top Expert 2009

Commented:
I'm glad to be of assistance :)