What is Data Structure? Its Types in detail

A data structure is a method of storing data in a computer so that it can be used effectively. A data structure is a specialized format for organizing and storing information. 

  • Save
Data Struc­ture

A data struc­ture is a method of orga­niz­ing data so that any oper­a­tion on it can be per­formed efficiently.

Arrays, files, linked lists, stacks, queues, trees, and graphs are exam­ples of gen­er­al data struc­ture types.

Types of Data Structure

1. Primitive Data Structure 

A prim­i­tive data struc­ture is a pre­de­fined data struc­ture that stores a sin­gle val­ue. A prim­i­tive data struc­ture is a type of data struc­ture that stores only one type of data. The fun­da­men­tal data struc­tures are prim­i­tive data structures.

It can per­form direct oper­a­tions on data and machine instructions.

It is also referred to as a basic data structure.

Prim­i­tive data struc­tures are defined by pro­gram­ming lan­guages, or they are built-in.

Inte­ger, Boolean, char­ac­ter, float­ing-point num­ber, and String are exam­ples of prim­i­tive data types.

Essen­tial­ly, the terms ‘data-type and ‘data struc­ture’ are fre­quent­ly used interchangeably.

Inte­ger:- The numer­ic val­ues are stored in the inte­ger data type. It con­tains whole num­bers that can be pos­i­tive or negative.

Float:- The float data type can store dec­i­mal val­ues. which con­tains a for­mu­la­ic rep­re­sen­ta­tion of real numbers

Char­ac­ter:- It is a data type that can store a sin­gle upper­case and low­er­case char­ac­ter val­ue, such as ‘A’ or ‘a’.

String:-  String is a col­lec­tion of characters. 

Boolean:- A data type that can store either a True or False val­ue. It is pri­mar­i­ly used to check the condition.

2. Non-Primitive Data Structure

 A Non-prim­i­tive data struc­ture is a defined data struc­ture that stores mul­ti­ple val­ues. A non Prim­i­tive data struc­ture is a  type of data struc­ture that stores mul­ti­ple val­ue types of data.  Non-prim­i­tive data struc­tures are those that are cre­at­ed by using prim­i­tive data structures. 

As com­pared to prim­i­tive data struc­ture it is a lit­tle bit complicated.

linked lists, stacks, trees, and graphs are exam­ples of non-prim­i­tive data types.

A non-prim­i­tive data struc­ture is fur­ther divid­ed into two-part:-

  1. Lin­ear Data struc­ture in lin­ear data struc­ture ele­ments are organ­ised sequen­tial­ly so that  each ele­ment is attached to its pre­vi­ous and next adja­cent ele­ments. Exam­ple of lin­ear data Struc­ture Array,Stack , Queue and linked list 

Array:- An array is a col­lec­tion of items that are stored in con­tigu­ous mem­o­ry locations.

Stack:- A stack is a lin­ear data struc­ture in which oper­a­tions are per­formed in a spe­cif­ic order. It is based on the prin­ci­ple of LIFO (LAST IN FIRST OUT). 

Queue:- A queue is a lin­ear struc­ture in which oper­a­tions are per­formed in a spe­cif­ic order. It is based on the prin­ci­ple of FIFO (FIRST IN FIRST OUT).

Linked list:- A linked list is a type of lin­ear data struc­ture in which the ele­ments are not stored in con­sec­u­tive mem­o­ry loca­tions. A linked list is made up of nodes, each of which has a data field and a ref­er­ence (link) to the next node in the list.

  1. Non-lin­ear Data Struc­ture  Data ele­ments in a non-lin­ear data struc­ture are attached hier­ar­chi­cal­ly.  It is oppo­site of lin­ear data struc­ture that means ele­ments are not  organ­ised sequen­tial­ly . Exam­ple of non-lin­ear data struc­ture Graph and Tree 

Graph:- A graph is a non­lin­ear data struc­ture made up of nodes and edges. The nodes are also known as ver­tices, and edges are lines or arcs that con­nect any two nodes in the graph.

Tree:- A tree is a hier­ar­chi­cal data struc­ture con­sist­ing of nodes. Val­ue is rep­re­sent­ed by nodes, which are con­nect­ed by edges. Each node has a sin­gle par­ent but may have mul­ti­ple chil­dren. Each node has an edge that con­nects it to its children.

Leave a Comment

Share via
Copy link
Verified by MonsterInsights