What is Data Structure?
The data structure name indicates itself that organizing the data in memory. There are many ways
of organizing the data in the memory as we have already seen one of the data structures, i.e.,
array in C language. Array is a collection of memory elements in which data is stored
sequentially, i.e., one after another. In other words, we can say that array stores the elements in a
continuous manner. This organization of data is done with the help of an array of data structures.
There are also other ways to organize the data in memory. Let's see the different types of data
structures.
The data structure is not any programming language like C, C++, java, etc. It is a set of
algorithms that we can use in any programming language to structure the data in the memory.
To structure the data in memory, 'n' number of algorithms were proposed, and all these
algorithms are known as Abstract data types. These abstract data types are the set of rules.
Types of Data Structures
There are two types of data structures:
○ Primitive data structure
○ Non-primitive data structure
1
, Data Structures and Algorithms
Primitive Data structure
The primitive data structures are primitive data types. The int, char, float, double, and pointer are
the primitive data structures that can hold a single value.
Non-Primitive Data structure
The non-primitive data structure is divided into two types:
○ Linear data structure
○ Non-linear data structure
Linear Data Structure
The arrangement of data in a sequential manner is known as a linear data structure. The data
structures used for this purpose are Arrays, Linked list, Stacks, and Queues. In these data
structures, one element is connected to only one another element in a linear form.
Non-linear Data Structure
When one element is connected to the 'n' number of elements known as a non-linear data
structure. The best example is trees and graphs. In this case, the elements are arranged in a
random manner.
We will discuss the above data structures in brief in the coming topics. Now, we will see the
common operations that we can perform on these data structures.
Data Structure Operations
The major or the common operations that can be performed on the data structures are:
○ Searching: We can search for any element in a data structure.
○ Sorting: We can sort the elements of a data structure either in an ascending or descending
order.
○ Insertion: We can also insert the new element in a data structure.
○ Updation: We can also update the element, i.e., we can replace the element with another
element.
○ Deletion: We can also perform the delete operation to remove the element from the data
structure.
Advantages of Data structures
2
, Data Structures and Algorithms
The following are the advantages of a data structure:
○ Efficiency: If the choice of a data structure for implementing a particular ADT is proper,
it makes the program very efficient in terms of time and space.
○ Reusability: The data structure provides reusability means that multiple client programs
can use the data structure.
○ Abstraction: The data structure specified by an ADT also provides the level of
abstraction. The client cannot see the internal working of the data structure, so it does not
have to worry about the implementation part. The client can only see the interface.
Basic Terminologies related to Data Structures
Data Structures are the building blocks of any software or program. Selecting the suitable data
structure for a program is an extremely challenging task for a programmer.
The following are some fundamental terminologies used whenever the data structures are
involved:
1. Data: We can define data as an elementary value or a collection of values. For example,
the Employee's name and ID are the data related to the Employee.
2. Data Items: A Single unit of value is known as Data Item.
3. Group Items: Data Items that have subordinate data items are known as Group Items. For
example, an employee's name can have a first, middle, and last name.
4. Elementary Items: Data Items that are unable to divide into sub-items are known as
Elementary Items. For example, the ID of an Employee.
5. Entity and Attribute: A class of certain objects is represented by an Entity. It consists of
different Attributes. Each Attribute symbolizes the specific property of that Entity. For
example,
Attributes ID Name Gender Job Title
Entities with similar attributes form an Entity Set. Each attribute of an entity set has a range of
values, the set of all possible values that could be assigned to the specific attribute.
3
, Data Structures and Algorithms
The term "information" is sometimes utilized for data with given attributes of meaningful or
processed data.
1. Field: A single elementary unit of information symbolizing the Attribute of an Entity is
known as Field.
2. Record: A collection of different data items are known as a Record. For example, if we
talk about the employee entity, then its name, id, address, and job title can be grouped to
form the record for the employee.
3. File: A collection of different Records of one entity type is known as a File. For example,
if there are 100 employees, there will be 25 records in the related file containing data
about each employee.
Why should we learn Data Structures?
1. Data Structures and Algorithms are two of the key aspects of Computer Science.
2. Data Structures allow us to organize and store data, whereas Algorithms allow us
to process that data meaningfully.
3. Learning Data Structures and Algorithms will help us become better
Programmers.
4. We will be able to write code that is more effective and reliable.
5. We will also be able to solve problems more quickly and efficiently.
What is Time Complexity? (Definition)
Time complexity is a metric used to describe how the execution time of an algorithm
changes relative to the size of the input data. It provides a way to estimate the number of
steps an algorithm will take to complete its task as the amount of data increases.
This is crucial in data structures and algorithms (DSA) because it helps predict how
algorithms will perform as they handle larger datasets, ensuring that applications remain
efficient and responsive under various conditions.
Thus, time complexity helps developers choose the most appropriate data structures and
algorithms, ensuring optimal performance for software applications.
What is Big O Notation in Time Complexity?
4