Posts

Showing posts from April, 2019

What is Graph

Image
A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph can be defined as, A Graph consists of a finite set of vertices(or nodes) and set of Edges which connect a pair of nodes. In the above Graph, the set of vertices V = {0,1,2,3,4} and the set of edges E = {01, 12, 23, 34, 04, 14, 13}. Graphs are used to solve many real-life problems. Graphs are used to represent networks. The networks may include paths in a city or telephone network or circuit network. Graphs are also used in social networks like linkedIn, Facebook. For example, in Facebook, each person is represented with a vertex(or node). Each node is a structure and contains information like person id, name, gender, locale etc. Therefore in general,  A   graph   is collection of two sets V and E where V is a finite non-empty set of vertices a...

What are the Differences Between Linear and Non-linear Data Structure

BASIS FOR COMPARISON LINEAR DATA STRUCTURE NON-LINEAR DATA STRUCTURE Basic The data is organized in a linear order in which elements are linked one after the other the non-linear data structure the data elements are not stored in a sequential manner rather the elements are hierarchically related Traversing of the data Sequential - The data elements can be accessed in one time (single run). Traversing of data elements in one go is not possible. Ease of implementation Simpler Complex Levels involved Single level Multiple level Examples Array, queue, stack, linked list, etc. Tree and graph. Memory utilization Ineffective Effective