The difference between linear and nonlinear data structure is that in linear data structure data is arrange no specific order and data is arranged adjacently whereas in nonlinear data structure data is arranged in a specific order and there is a relation between data.
Data structures are one of the most important concepts in computer programming. There is two type of data structures that are linear data structure and nonlinear data structure. The difference between the linear data structure and the nonlinear data structure is on the basis of the relationship between elements of data. Linear data structure and nonlinear data structure comes under nonprimitive data structure. In linear data structure data is to arrange no specific order and data is arranged adjacently whereas in nonlinear data structure data is arranged in a specific order and there is a relation between data.
Linear data structure forms a linear list. There is a specific order in which elements are attached to each other in the linear data structure. Elements in linear data structure consume linear memory space and data elements are store in sequential manner. In linear data structures memory of the data elements should be define at the start of the code. Array, stack, queue, linked list are examples of linear data structure. Nonlinear data structure arrange data in a sorted order. There is a hierarchical relationship in nonlinear data structure. There are roots, child, and nodes in nonlinear data structure, there are levels that are not available in linear data structure. Tree and graph are one of the most common examples of nonlinear data structures.
Comparison Chart
Basis  Linear data structure  Nonlinear data structure 
Meaning  In linear data structure data is arrange no specific order and data is arranged adjacently 
In nonlinear data, structure data is arranged in a specific order, and there is a relation between data.

Run  In single run, data can be extracted in the linear data structure.  In a single run, data cannot be extracted in the nonlinear data structure 
Implementation  Implementation of the linear data structure is easy  Implementation of the nonlinear data structure is not easy 
Effective  The linear data structure is memory ineffective  The nonlinear data structure is memory effective. 
Linear data structure
Linear data structure forms a linear list. There is a specific order in which elements are attached to each other in the linear data structure. Elements in linear data structure consume linear memory space, and data elements are store in a sequential manner. In linear data structures, the memory of the data elements should be defined at the start of the code. Array, stack, queue, linked list are examples of the linear data structure. The stack is a nonprimitive data structure that uses first in last out method whereas queue is a liner nonprimitive data structure that uses first in first out method.
top of the stack is known as TOS that is (top of the stack). Not only deletion but insertion also take place from the top of the stack. Stack follow last in first out method. Stack makes an ordered list, in this ordered list new item is added, and then existing elements are deleted. The element is deleted or removed from the top of the stack,
A queue is also a nonprimitive data structure, but the queue is different from the stack. The queue is a liner nonprimitive data structure that uses first in first out method. New elements are added form the bottom of the queue. That is the reason queue follow first in first out method.
NonLinear Data Structure
Nonlinear data structure arranges data in sorted order. There is a hierarchical relationship in the nonlinear data structure. There are roots, child, and nodes in the nonlinear data structure; there are levels that are not available in the linear data structure. Tree and graph are one of the most common examples of nonlinear data structures. There are finite data items that are known as nodes. In a tree, data is arranged in a sorted order that’s why it is called a nonlinear data structure. There is a hierarchical data structure in a tree.
There are many kinds of data elements that are organized into branches. Loops are formed in the addition of a new edge in a tree. There are many types of tree that are a binary tree, binary search tree, and AVL tree, threaded binary tree, Btree and many more. There are many applications of the tree such as data compression, file storage, manipulation of the arithmetic expression and game tree. There is only one node at the top of the tree that is known as the root of the tree. All the remaining data nodes are divided into subtree. There is a height of any tree that is calculated. There must be a path between all the roots of the tree that make it connected. The tree does not have a loop. Terminal node, edge node, level node, degree node, depth, forest are some important terminologies in the tree.
A graph is a nonlinear data structure. There are a group of vertices that are also known as a node in the graph. F(v,w) represent vertices. There are many types of graphs such as directed, nondirected, connected, nonconnected, simple and multigraph. If we talk about the application of graphs than a computer network, transportation system, social network graph, electrical circuits and project planning are some wellknown examples of graph data structure. Using edge vertex in the graph can be connected. Edge in the graph can also be bidirected or directed. Where the height of the tree is calculated, in graph edge can be weighted. Adjacent vertices, path, cycle, degree, connected graph, weighted graph are some important terms in the graph.
Key Differences
 In linear data structure data is to arrange no specific order and data is arranged adjacently whereas In nonlinear data structure data is arranged in a specific order and there is a relation between data.
 In a single run, data can be extracted in linear data structure whereas in single run data cannot be extracted in the nonlinear data structure.
 Implementation of the linear data structure is easy whereas Implementation of the nonlinear data structure is not easy.
 The linear data structure is memory ineffective whereas Nonlinear data structure is memory effective.
Conclusion
In this article above we see the clear difference between linear and nonlinear data structures with proper examples of code.