Different data structures

one of a kind statistics systems

  • Linear data structures
  • Nonlinear data structures

In linear facts structures, objects are based in a linear or sequential manner. Array, list, stack, and queue are examples of linear structures. In nonlinear systems, records are not dependent in a sequential way. Graph and tree are the maximum not unusual examples of nonlinear records structures.

allow us to now discover the sector of information structures, with exclusive varieties of information systems and their purposes in a summarized way. afterward, we can explore every of the facts structures in details.

there are many distinctive kinds of information structures that exist within the programming international. Out of them, following are the most used ones:

  • Struct
  • Array
  • Linked list
  • Doubly linked list
  • Stack
  • Queue
  • Set
  • Map
  • Tree
  • Graph
  • Heap


commonly, a variable can shop a unmarried statistics type and a single scalar data type can only save a unmarried cost. there are many conditions where we’d need to institution a few records types together as a unmarried complicated statistics kind. for instance, we want to store a few scholar statistics together in a pupil facts kind. We need the scholar name, cope with, phone wide variety, e-mail, date of start, contemporary elegance, and so on. so as to store each scholar report to a completely unique scholar facts type, we are able to need a special shape if you want to allow us to do this. this will be without problems done via struct. In other words, a struct is a container of values that is normally accessed using names. although structs are very famous in c language, we will use a comparable concept in php as properly. we’re going to discover that in coming chapters.


although an array is taken into consideration to be a information type in php, an array is without a doubt a records structure which is commonly used in all programming structures. In personal home page, the array is simply an ordered map (we are going to know about maps after some greater sections). we are able to store more than one values in a single array as a unmarried variable. Matrix kind facts are smooth to shop in an array and as a result it’s far used broadly in all programming platforms. generally arrays are a set length collection which is accessed by using sequential numeric indexes. In php, arrays are implemented otherwise and you could outline dynamic arrays without defining any constant length of the array. we will discover more about Hypertext Preprocessor arrays within the subsequent chapter. Arrays may have unique dimensions. If an array has most effective one index to get right of entry to an detail, we name it a single size array. however if it calls for two or greater indexes to get entry to an detail, we call it two dimensional or multidimensional arrays respectively. here are two diagrams of array data structures:

Linked list

A connected listing is a linear facts structure which is a collection of data elements additionally known as nodes and can have various sizes. typically, indexed items are linked through a pointer that’s referred to as a link and for this reason it is known as a connected listing. In a linked list, one list element hyperlinks to the next detail via a pointer. From the following diagram, we are able to see that the related listing certainly continues an ordered series. linked lists are the most commonplace and handiest shape of facts structures used by programming languages. In a unmarried linked list, we will simplest go ahead. In bankruptcy three, using related Lists we’re going to dive deep within the related listing ideas and implementations:

Doubly linked list

A doubly connected list is a special type of related listing in which we not simplest keep what’s the next node, but we also keep the preceding node in the node shape. As a end result, it is able to flow ahead and backward inside the listing. It offers more flexibility than a single related list or connected list by means of having each the previous and subsequent recommendations. we’re going to explore greater approximately those in chapter three, the usage of linked Lists. the subsequent diagram depicts a doubly linked list:


As we pointed out the stack in preceding pages, we already recognize that stack is a linear information shape with the LIFO principle. As a result, stacks have simplest one end to feature a brand new item or do away with an object. it’s far one of the oldest and most used records systems in laptop technology. We always add or take away an object from a stack the use of the unmarried point named pinnacle. The term push is used to signify an item to be introduced on pinnacle of the stack and pop to remove an item from the top; this is proven inside the following diagram. we will talk greater approximately stacks in chapter 4, constructing Stacks and Queues.


A queue is every other linear records structure which follows the FIFO principle. A queue permits two basic operations on the gathering. the primary one is enqueue which lets in us to add an object to the returned of the queue. the second is dequeue which allows us to eliminate an item from the the front of the queue. A queue is another of the maximum used facts structures in laptop era. we can research information about queues in chapter 4, Consrtucting Stacks and Queues.


a hard and fast is an summary data kind that’s used to save positive values. those values are not saved in any unique order however there should now not be any repeated values within the set. Set isn’t always used like a group where we retrieve a particular cost from it; a set is used to check the lifestyles of a cost inside it. every now and then a fixed statistics structure may be looked after and we name it an ordered set.


A map is a set of key and value pairs wherein all of the keys are particular. we will recollect a map as an associative array in which all keys are particular. we are able to upload and remove using key and value pairs in conjunction with update and appearance up from a map using a key. In fact, Hypertext Preprocessor arrays are ordered map implementations. we’re going to explore that in the next bankruptcy.


A tree is the maximum extensively used nonlinear records shape within the computing international. it’s far incredibly used for hierarchical records structures. A tree consists of nodes and there is a special node which is called the basis of the tree which begins the tree shape. other nodes descend from the foundation node. Tree information shape is recursive which means that a tree can contain many subtrees. Nodes are related with every other through edges. we’re going to discuss exceptional sorts of bushes, their operations, and purposes in chapter 6, know-how and imposing bushes.


A graph facts structure is a unique kind of nonlinear information structure which consists of a finite variety of vertices or nodes, and edges or arcs. A graph may be each directed and undirected. A directed graph in reality indicates the path of the edges, even as an undirected graph mentions the edges, not the path. As a end result, in an undirected graph, each instructions of side are considered as a unmarried facet. In other phrases, we will say a graph is a pair of units (V, E), wherein V is the set of vertices and E is the set of edges:

V = {A, B, C, D, E, F}

E = {AB, BC, CE, ED, EF, DB}

In a directed graph, an area AB isn’t the same as an facet BA whilst in an undirected graph, each AB and BA are the equal. Graphs are handy to remedy lots of complex problems within the programming global. we are going to maintain our discussion of graph data structures in bankruptcy 9, putting Graphs into action. inside the following diagram, we’ve got:


A heap is a unique tree-based totally data structure which satisfies the heap homes. the largest secret is the basis and smaller keys are leaves, that is called max heap. Or, the smallest key’s the root and large keys are leaves, that’s called min heap. even though the root of a heap shape is either the biggest or smallest key of the tree, it isn’t necessarily a sorted shape. A heap is used for fixing graph algorithms with performance and additionally in sorting. we are going to explore heap records structures in bankruptcy 10, expertise and using heaps.

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x