SlideShare a Scribd company logo
1 of 5
Chapter 1
Concepts of Data Structure
1.1 Data Types
A data type is defined as a set of data values which have some
predefined characteristics. Each data type share a common
property. For example : integer, string, float and so on. Each
of these data types have their own properties and limitations.
Such properties and limitations are defined by the
programming language used.
1.2 Data Structure
A data structure is defined as a grouping of data types along
with a set of operations for organizing and accessing the
collection. Each operation is a property manually provided to
the structure. The main concept is to define organization and
set of rules to implement and control the organization of such
structure. For eg : array, struct, class, stack, queue, list, graph
and so on.
1.3 Types of Data Structure
1.3.1 Primitive Data Structure:
Primitive data structure is the basic data structure that directly
operate upon the machine instructions. Their representation
depends on the hardware used or programming language used.
Eg : integer, string, float, character, pointer and so on.
1.3.2 Non Primitive Data Structure
Non primitive data structure is the data structure that are
derived from the primitive data structures. It is concerned with
grouping of similar or dissimilar data items together along
with the relationship between them. Eg: array, structure, stack
and so on.
1.4 Basic Data Structure Operations
1. Insertion : Addition of a new data element in a data
structure.
2. Deletion : Removing of a data element from a data structure
if exists.
3. Searching : Search for a specified data element in a data
structure.
4. Traversal : Processing all the data elements present in a
data structure.
5. Sorting : Arranging data elements in a specified order
(ascending or descending).
6. Merging : Combining elements of a similar data structures
to form a new data structure of same type.
1.5 Importance of Data Structure
- Store and organize data in most efficient way
- Organize data based on the problem
- Make locating, retrieval and manipulating of data easy
1.6 Abstract Data Types (ADT)
ADT is a abstraction of data structure for specifying the
logical properties of a data type. It is a basic mathematical
concept to define a particular data type.
ADT consists of following specification about a data
structure:
1. Data stored
2. Operations on the data
3. Error conditions associated with the data operations
Consider a simple calculating system of a rational numbers
for performing addition, subtraction and multiplication.
Here, the ADT can be specified as :
/*Value Definition (Defines collection of values)*/
abstract typedef <integer, integer> rational;
condition rational[1] != 0;
/*Operator Definition (abstract functions specifying possible operations)*/
abstract rational createRational(a,b)
int a, b;
precondition b != 0;
postcondition createRational[0] == a;
createRational[1] == b;
abstract rational add(a,b)
rational a, b;
postcondition add[0] == a[0] * b[1] + b[0] * a[1];
add[1] == a[1] * b[1];
abstract rational subtract(a,b)
rational a, b;
postcondition subtract[0] == a[0] * b[1] - b[0] * a[1];
subtract[1] == a[1] * b[1];
abstract rational multiply(a,b)
rational a, b;
postcondition multiply[0] == a[0] * b[0];
multiply[1] == a[1] * b[1];
1.7 Algorithm
Algorithm is defined as a set of rules defined in necessary
flow so as to complete a specific task. It provides a core logic
necessary to solve a problem.
The significant traits of a good algorithm are as follows :
1. An algorithm should be terminated in finite number of
steps and each step should consume finite amount of
time.
2. Each step of an algorithm should be clearly defined.
3. An algorithm must have finite number of inputs.
4. An algorithm must provide desirable output.
5. An algorithm should consume less time and less space to
execute.
1.8 Classification of Algorithm (Based on algorithmic
Paradigm)
1. Brute Force Algorithm (Looks for all the possibilities and
selects the best one)
2. Divide and Conquer Algorithm (Divides problem into
smaller parts and solve each part separately)
3. Greedy Algorithm (Chooses the best option at current stage
and does not consider about the future)
4. Dynamic Algorithm (Builds up to a solution from
previously built sub solutions)

More Related Content

What's hot

Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms ManishPrajapati78
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structurekalyanineve
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure Prof Ansari
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1Kumar
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary searchNisha Soms
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
data structure
data structuredata structure
data structurehashim102
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
 
Complete dbms notes
Complete dbms notesComplete dbms notes
Complete dbms notesTanya Makkar
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance Anaya Zafar
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST Kathirvel Ayyaswamy
 

What's hot (20)

Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Data structures
Data structuresData structures
Data structures
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Set data structure
Set data structure Set data structure
Set data structure
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
data structure
data structuredata structure
data structure
 
Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data Structure
 
Sorting
SortingSorting
Sorting
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 
Complete dbms notes
Complete dbms notesComplete dbms notes
Complete dbms notes
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 

Similar to Introduction to Data Structure and Algorithm

DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS Adams Sidibe
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresresamplopsurat
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its FundamentalsHitesh Mohapatra
 
1. Data structures introduction
1. Data structures introduction1. Data structures introduction
1. Data structures introductionMandeep Singh
 
Lesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdfLesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdfLeandroJrErcia
 
Data Structure - Elementary Data Organization
Data Structure - Elementary  Data Organization Data Structure - Elementary  Data Organization
Data Structure - Elementary Data Organization Uma mohan
 
Introduction to Data Structure.pptx
Introduction to Data Structure.pptxIntroduction to Data Structure.pptx
Introduction to Data Structure.pptxGlenardDSarmiento
 
Data structures Lecture no. 2
Data structures Lecture no. 2Data structures Lecture no. 2
Data structures Lecture no. 2AzharIqbal710687
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2RajSingh734307
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringRAJASEKHARV8
 

Similar to Introduction to Data Structure and Algorithm (20)

DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
Ch1
Ch1Ch1
Ch1
 
1. Data structures introduction
1. Data structures introduction1. Data structures introduction
1. Data structures introduction
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Lesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdfLesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdf
 
Data Structure - Elementary Data Organization
Data Structure - Elementary  Data Organization Data Structure - Elementary  Data Organization
Data Structure - Elementary Data Organization
 
Introduction to Data Structure.pptx
Introduction to Data Structure.pptxIntroduction to Data Structure.pptx
Introduction to Data Structure.pptx
 
Data structures
Data structuresData structures
Data structures
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Data structures Lecture no. 2
Data structures Lecture no. 2Data structures Lecture no. 2
Data structures Lecture no. 2
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 

More from Sagacious IT Solution

More from Sagacious IT Solution (16)

List - Operations and Implementation
List - Operations and ImplementationList - Operations and Implementation
List - Operations and Implementation
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Queue - Operations and Implementations
Queue - Operations and ImplementationsQueue - Operations and Implementations
Queue - Operations and Implementations
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Machine Learning Algorithms
Machine Learning AlgorithmsMachine Learning Algorithms
Machine Learning Algorithms
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Expert System
Expert SystemExpert System
Expert System
 
Game Playing Search Techniques - Examples
Game Playing Search Techniques - ExamplesGame Playing Search Techniques - Examples
Game Playing Search Techniques - Examples
 
Uninformed Search Examples
Uninformed Search ExamplesUninformed Search Examples
Uninformed Search Examples
 
Examples of Informed Search
Examples of Informed SearchExamples of Informed Search
Examples of Informed Search
 
Searching Algorithm
Searching AlgorithmSearching Algorithm
Searching Algorithm
 
Knowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and ReasoningKnowledge Representation, Inference and Reasoning
Knowledge Representation, Inference and Reasoning
 
Structured Knowledge Representation
Structured Knowledge RepresentationStructured Knowledge Representation
Structured Knowledge Representation
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Crypto Arithmetic Problem - Example
Crypto Arithmetic Problem - ExampleCrypto Arithmetic Problem - Example
Crypto Arithmetic Problem - Example
 
Introduction To Artificial Intelligence
Introduction To Artificial IntelligenceIntroduction To Artificial Intelligence
Introduction To Artificial Intelligence
 

Recently uploaded

INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Introduction to Data Structure and Algorithm

  • 1. Chapter 1 Concepts of Data Structure 1.1 Data Types A data type is defined as a set of data values which have some predefined characteristics. Each data type share a common property. For example : integer, string, float and so on. Each of these data types have their own properties and limitations. Such properties and limitations are defined by the programming language used. 1.2 Data Structure A data structure is defined as a grouping of data types along with a set of operations for organizing and accessing the collection. Each operation is a property manually provided to the structure. The main concept is to define organization and set of rules to implement and control the organization of such structure. For eg : array, struct, class, stack, queue, list, graph and so on. 1.3 Types of Data Structure 1.3.1 Primitive Data Structure: Primitive data structure is the basic data structure that directly operate upon the machine instructions. Their representation depends on the hardware used or programming language used. Eg : integer, string, float, character, pointer and so on.
  • 2. 1.3.2 Non Primitive Data Structure Non primitive data structure is the data structure that are derived from the primitive data structures. It is concerned with grouping of similar or dissimilar data items together along with the relationship between them. Eg: array, structure, stack and so on. 1.4 Basic Data Structure Operations 1. Insertion : Addition of a new data element in a data structure. 2. Deletion : Removing of a data element from a data structure if exists. 3. Searching : Search for a specified data element in a data structure.
  • 3. 4. Traversal : Processing all the data elements present in a data structure. 5. Sorting : Arranging data elements in a specified order (ascending or descending). 6. Merging : Combining elements of a similar data structures to form a new data structure of same type. 1.5 Importance of Data Structure - Store and organize data in most efficient way - Organize data based on the problem - Make locating, retrieval and manipulating of data easy 1.6 Abstract Data Types (ADT) ADT is a abstraction of data structure for specifying the logical properties of a data type. It is a basic mathematical concept to define a particular data type. ADT consists of following specification about a data structure: 1. Data stored 2. Operations on the data 3. Error conditions associated with the data operations Consider a simple calculating system of a rational numbers for performing addition, subtraction and multiplication. Here, the ADT can be specified as : /*Value Definition (Defines collection of values)*/
  • 4. abstract typedef <integer, integer> rational; condition rational[1] != 0; /*Operator Definition (abstract functions specifying possible operations)*/ abstract rational createRational(a,b) int a, b; precondition b != 0; postcondition createRational[0] == a; createRational[1] == b; abstract rational add(a,b) rational a, b; postcondition add[0] == a[0] * b[1] + b[0] * a[1]; add[1] == a[1] * b[1]; abstract rational subtract(a,b) rational a, b; postcondition subtract[0] == a[0] * b[1] - b[0] * a[1]; subtract[1] == a[1] * b[1]; abstract rational multiply(a,b) rational a, b; postcondition multiply[0] == a[0] * b[0]; multiply[1] == a[1] * b[1]; 1.7 Algorithm Algorithm is defined as a set of rules defined in necessary flow so as to complete a specific task. It provides a core logic necessary to solve a problem. The significant traits of a good algorithm are as follows : 1. An algorithm should be terminated in finite number of steps and each step should consume finite amount of time.
  • 5. 2. Each step of an algorithm should be clearly defined. 3. An algorithm must have finite number of inputs. 4. An algorithm must provide desirable output. 5. An algorithm should consume less time and less space to execute. 1.8 Classification of Algorithm (Based on algorithmic Paradigm) 1. Brute Force Algorithm (Looks for all the possibilities and selects the best one) 2. Divide and Conquer Algorithm (Divides problem into smaller parts and solve each part separately) 3. Greedy Algorithm (Chooses the best option at current stage and does not consider about the future) 4. Dynamic Algorithm (Builds up to a solution from previously built sub solutions)