#### Data Structure

A Data Structure may be a special format for organizing, processing, retrieving and storing data. There are may basic and advanced sorts of organisations these data structure are designed to rearrange data to suit a particular purpose. Data structures make it easy for users to access and work with the information they have in appropriate ways. Most significantly, data structures frame the organization of data in order that machines and humans can better comprehend it.The logical or mathematical model of a particular organization of data is called a data structure. Data Structure are generally classified into primitive and non primitive data structures . based on structure and arrangement of data non primitive data structures are further classified into linear and nonlinear.

For instance, in an object-oriented programing language, the information structure and its associated methods are bound together as a part of a category definition. In non-object-oriented languages, there could also be functions defined to figure with the information structure, but they’re not technically a part of the information structure.

**Why are data structures important?**

The basic data type, such as floating-point values or integers, that are used in most computer programming languages but they are generally insufficient to capture the logical intent for data processing and use of data. Data structures combine together the data elements in a logical way and facilitate the effective use of data, persistence and sharing of data. Data structures provide a formal model that describes the way the data elements are organized. Data structures are created by composing data elements into a logical unit that represent an abstract data type that has relevance to the algorithm or application. Here is an example of an abstract data type is a “student name” which is composed of the character strings for “first name,” “middle name” and “last name.”It is not only use data structures, but it is also very important to choose the proper data structure for each task. Choosing a not proper data structure could result in slow runtime or unresponsive code. There are 5 major factors to consider when picking a data structure include the following:

- What kind of information will be stored?
- How will that information be used?
- Where should data persist, or be kept, after it is created?
- What is the best way to organize the data?
- What aspects of memory and storage reservation management should be considered?

### Types of data structure

- Primitive Data Structure
- Non-Primitive Data Structure

#### Primitive Data Structure

- Integer
- Floating (Decimal numbers)
- Character
- Boolean

#### Non-Primitive Data Structure

- Linear Data Structures
- Non-linear data structures

#### Linear Data Structures

A data structure is said to be linear if its element from a sequence or a linear list.In linear data structures, the data is arranged in a linear fashion although the way they are stored in memory need not to be sequential. Arrays, linked list, hash tables and queues are the example of linear data structures.

**Arrays**An array stores a collection of Items that are the same type at adjoining memory locations. These items are stored together so the position of each element can be calculated or retrieved easily by the help of an index. Arrays size can be fixed or flexible in length.**Stacks**A stack stores a collection of items in the linear order that is last in, first out (LIFO) or first in, first out (FIFO).**Queues**A queue stores a collection of items like a stack but there order of operation can only be first in, first out.**Linked Lists**A linked list stores a collection of items in a linear order in which each element or node contains a data item and a reference, or link, to the next item in the list.**Hash Tables**A hash table also known as a hash map which stores a collection of items in an associative array that plots keys to values. To convert an index into an array of buckets that contain the desired data item ,hash table uses a hash function .**Heap.**A heap is a tree-based structure in which each parent node’s associated key value pair which is greater than or equal to the key values of any of its children’s key values.

#### Non-linear data structures

A data structure is said to be known non linear If the data is not arrange in sequence. The insertion and deletion of the data is therefore not possible in a linear fashion trees and graph are examples of non-linear data structures.

**Trees**A tree stores a collection of items in an abstract, hierarchical way in which each node is associated with a key value pair. In this parent nodes linked to child nodes or subnodes. It has one root node which is the ancestor of all the nodes in the tree.**Graphs**A graph stores a collection of items in a nonlinear order. Graphs are made up of a finite set of nodes, also known as vertices, and lines that connect them is known as edges. These are very useful for representing real-world systems such as computer networks.

**How to choose a knowledge structure**

When it involves choose an information structure for a program or application, developers must make sure of the following three questions:

1. **Supported operations. **What functions and operations does the program actually need?

2. **Computational complexity.** What reasonably computational performance is tolerable? For speed, an information structure whose operations execute in time is linear to the amount of things managed using Big O notation: O(n) are going to be faster than a knowledge structure whose operations execute in time which is proportional to the square of the quantity of things managed O(n^2).

3.** Programming elegance.** **Are the organization of the information structure and its functional interface easy to use?**

**Here are some real-world examples include:**

* **Linked lists **consider best if a program is managing a group of things which don’t must be ordered and constant time is required for adding or removing an item from the gathering and increased search time is OK.

* **Stacks** consider best if the program is managing a set that has to support a LIFO order.

* **Queues** should be used if the program is managing a group that must support a FIFO order.

* **Binary trees **are good for managing a group of things with a parent-child relationship.

* **Binary search** trees are appropriate for managing a sorted collection where the goal is to optimize the time it takes to seek out specific items within the collection.

* **Graphs** work best if the appliance will analyze connectivity and relationships among a group of people in an exceedingly social media network.

Also read….INTERVIEW Q/A Series