Data Structures are the programmatic way of storing data so that data can be
used efficiently. Almost every enterprise application uses various types of data
structures in one or the other way. This tutorial will give you a great
understanding on Data Structures needed to understand the complexity of
enterprise level applications and need of algorithms, and data structures.
A computer program is a collection of instructions to perform a specific task.
For this, a computer program may need to store data, retrieve data, and
perform computations on the data.
A data structure is a named location that can be used to store and organize
data. And, an algorithm is a collection of steps to solve a particular problem.
Learning data structures and algorithms allow us to write efficient and
optimized computer programs.
Applications of Data Structure and Algorithms
Algorithm is a step-by-step procedure, which defines a set of instructions to
be executed in a certain order to get the desired output. Algorithms are
generally created independent of underlying languages, i.e. an algorithm can
be implemented in more than one programming language.
From the data structure point of view, following are some important categories
of algorithms −
Search − Algorithm to search an item in a data structure.
Sort − Algorithm to sort items in a certain order.
Insert − Algorithm to insert item in a data structure.
Update − Algorithm to update an existing item in a data structure.
Delete − Algorithm to delete an existing item from a data structure.
,Data Definition
Data Definition defines a particular data with the following characteristics.
Atomic − Definition should define a single concept.
Traceable − Definition should be able to be mapped to some data
element.
Accurate − Definition should be unambiguous.
Clear and Concise − Definition should be understandable.
Data Object
Data Object represents an object having a data.
Data Type
Data type is a way to classify various types of data such as integer, string, etc.
which determines the values that can be used with the corresponding type of
data, the type of operations that can be performed on the corresponding type
of data. There are two data types −
Built-in Data Type
Derived Data Type
Built-in Data Type
Those data types for which a language has built-in support are known as
Built-in Data types. For example, most of the languages provide the following
built-in data types.
Integers
Boolean (true, false)
Floating (Decimal numbers)
Character and Strings
,Derived Data Type
Those data types which are implementation independent as they can be
implemented in one or the other way are known as derived data types. These
data types are normally built by the combination of primary or built-in data
types and associated operations on them. For example −
List
Array
Stack
Queue
Basic Operations
The data in the data structures are processed by certain operations. The
particular data structure chosen largely depends on the frequency of the
operation that needs to be performed on the data structure.
Traversing
Searching
Insertion
Deletion
Sorting
Merging
Arrays
Array is a container which can hold a fix number of items and these items
should be of the same type. Most of the data structures make use of arrays to
implement their algorithms. Following are the important terms to understand
the concept of Array.
Element − Each item stored in an array is called an element.
Index − Each location of an element in an array has a numerical index,
which is used to identify the element.
, Array Representation
Arrays can be declared in various ways in different languages. For illustration,
let's take C array declaration.
Arrays can be declared in various ways in different languages. For illustration,
let's take C array declaration.
As per the above illustration, following are the important points to be
considered.
Index starts with 0.
Array length is 10 which means it can store 10 elements.
Each element can be accessed via its index. For example, we can
fetch an element at index 6 as 9.
Basic Operations
Following are the basic operations supported by an array.
Traverse − print all the array elements one by one.
Insertion − Adds an element at the given index.
Deletion − Deletes an element at the given index
Search − Searches an element using the given index or by the value
Update − Updates an element at the given index.