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 ?
soodsandeepAsked:
Who is Participating?
 
Infinity08Connect With a Mentor 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)
0
 
deepu chandranCommented:
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


0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Infinity08Commented:
>> 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.
0
 
deepu chandranCommented:
Sorry, i confused with Sequential and NonSequential Data Structures.

0
 
meoconxCommented:
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.
0
 
Infinity08Commented:
>> 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.
0
 
roussoscCommented:
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.
0
 
soodsandeepAuthor Commented:
Thanks Infinity08 !
i m ur fan. get many excellent answers from u.
thanks.
0
 
Infinity08Commented:
I'm glad to be of assistance :)
0
All Courses

From novice to tech pro — start learning today.