0% found this document useful (0 votes)
0 views

Introduction

The document provides an overview of data structures, defining them as specialized formats for organizing and storing data efficiently. It categorizes data structures into linear and non-linear types, discusses operations such as traversing, searching, inserting, and deleting, and highlights the importance of characteristics like correctness, time complexity, and space complexity. Additionally, it explains the concept of algorithms, their properties, and the significance of time and space complexity in evaluating their performance.

Uploaded by

Hasnain Nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Introduction

The document provides an overview of data structures, defining them as specialized formats for organizing and storing data efficiently. It categorizes data structures into linear and non-linear types, discusses operations such as traversing, searching, inserting, and deleting, and highlights the importance of characteristics like correctness, time complexity, and space complexity. Additionally, it explains the concept of algorithms, their properties, and the significance of time and space complexity in evaluating their performance.

Uploaded by

Hasnain Nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

DATA STRUCTURE ALGORITHMS & APPLICATIONS

INTRODUCTION
Data Structures
 A data structure is a specialized format for organizing and storing data.
 Data Structures are the programmatic way of storing data so that data can be used efficiently.
 Different types of data structures include array, file, record, tables and trees etc.
 Any data structure is designed to operate data for a specific purpose.
 A data structure helps the user to store data in such a way that it can be used and processed efficiently.
 Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an
effective way.
Types of data Structures
Two types of data structure are as follows:
1. Linear Data Structures
 A type of data structure in which data elements are stored in linear sequence is
called a linear data structures.
 Array, stack, queue and linked list are examples of linear data structure.
2. Non Linear Data Structures

 A type of data structure in which the data elements are stored in non linear
sequence is non linear data structure.
 Trees and graphs are example of non linear data structure.
 Data Structure Operations
The data appearing in data structure are processed by means of certain operations
1. Traversing
 The process of accessing each record exactly once so that certain items in the record
may be processed is called traversing.
 It is also called visiting.
2. Searching
 The process of finding the location of record with a given key value is called searching.
 It may include finding the locations of all records which satisfy one or more conditions.
3. Inserting
 The process of adding new record with a given key value is called searching.

4. Deleting
 The process of removing a record from the data structure is called deleting.
Basic types of Data Structures
 As we have discussed above, anything that can store data can be called as a data structure, hence Integer, Float, Boolean,
Char etc, all are data structures. They are known as Primitive Data Structures.
Then we also have some complex Data Structures, which are used to store large and connected data. Some example
of Abstract Data Structure are :
 Linked List
 Tree
 Graph
 Stack, Queue etc.
 All these data structures allow us to perform different operations on data. We select these data structures based on which
type of operation is required.
The data structures can also be classified on the basis of the following characteristics:

Characteristic Description
Linear In Linear data structures,the data items are arranged in a linear sequence. Example: Array
Non-Linear In Non-Linear data structures,the data items are not in sequence. Example: Tree, Graph
Homogeneous In homogeneous data structures,all the elements are of same type. Example: Array
Non-Homogeneous In Non-Homogeneous data structure, the elements may or may not be of the same type.
Example: Structures
Static Static data structures are those whose sizes and structures associated memory locations
are fixed, at compile time. Example: Array
Dynamic Dynamic structures are those which expands or shrinks depending upon the program
need and its execution. Also, their associated memory locations changes. Example: Linked
List created using pointers
Characteristics of a Data Structure
1)Correctness − Data structure implementation should implement its interface correctly.
2)Time Complexity − Running time or the execution time of operations of data structure
must be as small as possible.
3)Space Complexity − Memory usage of a data structure operation should be as little as
possible.
Need for Data Structure
As applications are getting complex and data rich, there are three common problems that
applications face now-a-days.
1. Data Search − Consider an inventory of 1 million(106) items of a store. If the application
is to search an item, it has to search an item in 1 million(106) items every time slowing
down the search. As data grows, search will become slower.
2. Processor speed − Processor speed although being very high, falls limited if the data
grows to billion records.
3. Multiple requests − As thousands of users can search data simultaneously on a web
server, even the fast server fails while searching the data.
To solve the above-mentioned problems, data structures come to rescue. Data can be
organized in a data structure in such a way that all items may not be required to be searched,
and the required data can be searched almost instantly.
Execution Time Cases
There are three cases which are usually used to compare various data structure's execution time in a relative
manner.
1. Worst Case − This is the scenario where a particular data structure operation takes maximum time it can
take. If an operation's worst case time is ƒ(n) then this operation will not take more than ƒ(n) time where
ƒ(n) represents function of n.
2. Average Case − This is the scenario depicting the average execution time of an operation of a data
structure. If an operation takes ƒ(n) time in execution, then m operations will take mƒ(n) time.
3. Best Case − This is the scenario depicting the least possible execution time of an operation of a data
structure. If an operation takes ƒ(n) time in execution, then the actual operation may take time as the
random number which would be maximum as ƒ(n).
Basic Terminology
 Data − Data are values or set of values.
 Data Item − Data item refers to single unit of values.
 Group Items − Data items that are divided into sub items are called as Group Items.
 Elementary Items − Data items that cannot be divided are called as Elementary Items.
 Attribute and Entity − An entity is that which contains certain attributes or properties, which
may be assigned values.
 Entity Set − Entities of similar attributes form an entity set.
 Field − Field is a single elementary unit of information representing an attribute of an entity.
 Record − Record is a collection of field values of a given entity.
 File − File is a collection of records of the entities in a given entity set.
What is an Algorithm ?
An algorithm is a finite set of instructions or logic, written in order, to accomplish a certain predefined task.
Algorithm is not the complete code or program, it is just the core logic(solution) of a problem, which can be expressed either
as an informal high level description as pseudocode or using a flowchart.
 Every Algorithm must satisfy the following properties:
 Input- There should be 0 or more inputs supplied externally to the algorithm.
 Output- There should be atleast 1 output obtained.
 Definiteness- Every step of the algorithm should be clear and well defined.
 Finiteness- The algorithm should have finite number of steps.
 Correctness- Every step of the algorithm must generate a correct output.
 An algorithm is said to be efficient and fast, if it takes less time to execute and consumes
less memory space. The performance of an algorithm is measured on the basis of following
properties :
 Time Complexity
 Space Complexity
 Space Complexity
 Its the amount of memory space required by the algorithm, during the course of its execution. Space complexity must be
taken seriously for multi-user systems and in situations where limited memory is available.
 An algorithm generally requires space for following components :
 Instruction Space: Its the space required to store the executable version of the program. This space is fixed, but varies
depending upon the number of lines of code in the program.
 Data Space: Its the space required to store all the constants and variables(including temporary variables) value.
 Environment Space: Its the space required to store the environment information needed to resume the suspended
function.
 Time Complexity
Time Complexity is a way to represent the amount of time required by the program to run till its completion. It's generally a
good practice to try to keep the time required minimum, so that our algorithm completes it's execution in the minimum time
possible.

You might also like