Introduction to Data Structure

Data Structure

Before we start understanding what is the use of Data Structure and why it is necessary to learn this topic we first need to know the term Data. 


What is Data?

If we go with the basic dictionary definition, the quantities, characters, or symbols on which operations are performed by a computer, may be stored and transmitted in the form of electrical signals and recorded on magnetic, optical, or mechanical recording media.


Now often people get confused between two terms that are Data and Information and people think that both words have similar meanings but it is not correct for this we need to understand when Data become Information. 


Data is an unordered and unrefined collection of facts and if the data is arranged in a systematic way then it gets a structure and becomes meaningful. This meaningful or processed data is called Information.

Before learning about different types of data structures let us first understand the basic difference between Data Type and Abstract Data Type.


What is Data Type?

In programming, a data type is used to define a certain type of value a variable can store and what kind of mathematical, relational, or logical operations are allowed on those values. Let's understand this with two different examples.

For example, the int data type can take only integer values, and all kinds of operations like addition, subtraction, multiplication, bitwise operations, etc are allowed. (alert-passed)

For example, the float data type can take only floating point values and bitwise and % (modulo operations) are not allowed. (alert-passed)


The data types like boolean, byte, short, int, long, float, double, and char are known as primitive data types, and apart from this, there is a concept of user-defined data type in which operations and values of the user-defined data type are not specified by the programming language but user have to specify by themselves. Example of user-defined data type is Structure, union, and enumeration.


What is Abstract Data Type (ADT)?

ADTs are like user-defined data types which define operations on values using functions without specifying what is there inside the function and how the operations are performed. ADT hides the inner structure and design of the data type from the user.


Example: Stack ADT

A stack consists of elements of the same type arranged in sequential order and it can be implemented using arrays or linked lists.

The list of operations that we can perform on the stack are:

  • initialize() - Initializing it to be empty.
  • push() - Insert an element into the stack.
  • pop() - Delete an element from the stack.
  • isEmpty() - Checks if stack is empty.
  • isFull() - Checks if stack is full.
Note: Stack itself is a data structure that is implemented using other data structures like arrays or linked lists. (alert-success) 

What is Data Structure?

A data structure (DS) is a way of organizing data so that it can be used effectively. It is a way of organizing data in some fashion so that later on it can be accessed reread or updated the data quickly and easily. 

From the above explanation of ADT, we can say that data structure is used to implement an ADT.
In reality, different implementations of ADT are compared for time and space efficiency. The one best suited according to the current requirement of the user will be selected. (alert-passed)

Advantages of Data Structure:

  • Efficiency: Proper choice of data structures make the program efficient in terms of space and time.
  • Reusability: One implementation can be used by multiple client programs.
  • Abstraction: Data structure is specified by an ADT which provides a level of abstraction. The client program doesn't have to worry about the implementation details.  

Why do we need Data Structure?

A Data Structure is a systematic way to organize data so that it can be used efficiently in terms of time and space com. We need Data Structure to provide an appropriate way to structure the data in such a way that it can produce some meaningful information that we can use in a more efficient way.


There are multiple different kinds of Data Structures available to store and manage our data but here we are going to take the example of one of the very popular data structures named Arrays. An array is a linear data structure that can store the elements of the same data type in a contiguous manner so instead of creating multiple variables of the same type we can create an array to store all the values. Like Array, we also use the String data structure to store the sequence of characters. 


Real Life Example of some popular Data Structure.

  • Stack Data Structure is used in implementing redoing and undoing features in any application.
  • Graph Data Structure stores friendship information on a social networking site.

Type of Data Structure.

There are basically two types of data structure, one a linear data structure and the other a non-linear data structure.

When all the elements are arranged in a linear (sequential) order then that data structure is known as a Linear data structure. Examples, are Arrays, Stack, Queue, and Linked List.

When all the elements are not arranged in a linear (sequential) order then that data structure is known as a non-linear data structure. Examples are trees and Graphs.

Static and Dynamic Data structure.

Static data structure: Memory allocation is done at compile time in a static data structure. The maximum size of the static data structure is fixed and it cannot be changed at run time. It provides faster access to elements but insertion and deletion are quite expensive. Example: Array

Dynamic Data structure: Memory is allocated at run time in a dynamic data structure. The size of the dynamic data structure is not fixed, they are flexible in size. It allows faster insertion and deletion but access to elements is quite expensive. Example: Linked List

👉Support Us by Sharing our post with others if you really found this useful and also share your valuable feedback in the comment section below so we can work on them and provide you best ðŸ˜Š.(alert-success) 

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS