SlideShare a Scribd company logo
1 of 23
FUNDAMENTALS OF
DATASTRUCTURE
By
Sri. C. RANJITHKUMAR, M.Sc.(IT & M)., M.Phil.,
Assistant Professor,
Department of Computer Science,
VIVEKANANDA COLLEGE,
TIIRUVEDAKAM WEST MADURAI
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC
1
PROLOGUE
 Introduction
 Basic terminology
 Datastructures and its Classification
 Datastructure operations
 Applications of Datastructures
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, Vivekananda College 2
INTRODUCTION
 Data Structure is a way of collecting and organizing data, in such a way that user can perform
operations on these data in an effective way.
 Data Structures is about rendering data elements in terms of some relationship, for better
organization and storage.
For example
Consider we have data of player's name "Virat" and age 26. Here "Virat" is of String data type
and 26 is of Integer data type.
User can organize this data as a record like Player record. Now we can collect and store
player's records in a file or database as a data structure.
For example:
“Dhoni" 30, "Gambhir" 31, "Sehwag" 33.
 In simple language, Data Structures are structures programmed to store ordered data, so that
various operations can be performed on it easily.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, Vivekananda College 3
BASIC TERMINOLOGY OF DATA ORGANIZATION
 DATA : The term ‘DATA’ simply refers to a value or a set of values.
(EXAMPLE) roll no of a student, marks, name of an employee, address of person etc.
 DATA ITEM : A data item refers to a single unit of value.
Data items that can be divided into sub items are called group items
(Eg. Address, Date, Name)
Data items can not be divided in to sub items are called elementary items
(Eg. Roll no, Marks, City, Pin-code etc.)
 ENTITY – Data items with similar attributes is called an Entity set
( Eg. all employees of an organization)
 INFORMATION - Processed data, Data with given attribute
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 4
BASIC TERMINOLOGY OF DATA ORGANIZATION
 FIELD – It is a single elementary unit of information represented as an attribute of an entity
 RECORD – It is a collection of field values of a given entity
 FILE – It is a collection of records of the entities in a given entity set
(Eg.)
Name Age Sex Roll Number Branch
A 17 M 109cs0132 CSE
B 18 M 109ee1234 EE
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC
5
CLASSIFICATION OF DATASTRUCTURES
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 6
BASIC OPERATIONS
 TRAVERSING:
Accessing each record exactly once so that certain items in the record may be processed.
 SEARCHING:
Finding the location of a particular record with a given key value, or finding the location of all
records which satisfy one or more conditions.
 INSERTING:
Adding a new record to the structure.
 DELETING:
Removing the record from the structure.
 SORTING:
Managing the data or record in some logical order (Ascending or descending order).
 MERGING:
Combining the record in two different sorted files into a single sorted file.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 7
PRIMITIVE DATASTRUCTURES
 PRIMITIVE DATASTRUCTURES:
Primitive data structure is a fundamental type of data structure that stores the data of only one
type
(Eg.) Integer, float, character
Integer variable can hold integer type of value
Float variable can hold floating type of value
Character variable can hold character type of value
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC
8
NON-PRIMITIVE DATASTRUCTURES
 NON-PRIMITIVE DATA STRUCTURES are user-defined that stores the data of different types in a
single entity.
 It is categorized into two types:
1. LINEAR DATA STRUCTURE
2. NON-LINEAR DATA STRUCTURE
 LINEAR DATA STRUCTURES are sequential type of data structure, that is all the elements in the
memory are stored in a sequential manner
For example, element stored after the second element would be the third element, the element
stored after the third element would be the fourth element and so on.
Linear data structures holding the sequential values such as Array, Stack, Linked List and Queue
 NON-LINEAR DATA STRUCTURES is a kind of random type of data structure. The non-linear data
structures are Tree and Graph.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 9
DIFFERENCE
PRIMITIVE DATASTRUCTURES NON-PRIMITIVE DATASTRUCTURES
Primitive data structures stores the data of only
one type.
Non-primitive data structures that can store data that
are more than one type.
(Eg) integer, character, float. (Eg) Array, Stack, Linked list, stack.
These contains some value and cannot be
NULL.(empty)
These can store NULL value.(empty)
Size depends on the type of the data structure Size is not fixed.
It can hold a single value in a specific location
It can hold multiple values either in a contiguous
location or random locations
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 10
Characteristics of Primitive Datastructures
 INTEGER:
The integer data type contains the numeric values. It contains the whole numbers that can be
either negative or positive. When the range of integer data type is not large enough then in that
case, we can use long.
 FLOAT:
The float is a data type that can hold decimal values. When the precision of decimal value
increases then the Double data type is used.
 BOOLEAN:
It is a data type that can hold either a True or a False value. It is mainly used for checking the
condition.
 CHARACTER:
It is a data type that can hold a single character value both uppercase and lowercase such as 'A'
or 'a'.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 11
Characteristics of Non-Primitive Datastructures
ARRAY:
 Each element in an array is of the same data type and carries the same size that is 4 bytes.
 Elements in the array are stored at contiguous memory locations from which the first element is
stored at the smallest memory location.
 Elements of the array can be randomly accessed since we can calculate the address of each
element of the array with the given base address and the size of the data element.
 User can perform operations such insertion, deletion, traversing, searching and update.
For example:
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 12
Applications of Arrays
 To store the possible moves in a chess game.
 Password storage and generation
 Marks storage and generation
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 13
STACK
 A Stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle.
 Stack is one ended
 It contains top pointer which points to the topmost element of the stack.
 Any element added into the stack, it is added only at the top of the stack.
 A stack can be defined as a container in which insertion and deletion can be done from the one
end known as the top of the stack.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 14
Stack Operations
 push():
To insert an element in a stack then the operation is known as a push. If the stack is full then
the overflow condition occurs.
 pop():
To delete an element from the stack, the operation is known as a pop. If the stack is empty
means that no element exists in the stack, this state is known as an underflow state.
 isEmpty():
To determine whether the stack is empty or not.
 isFull():
To determine whether the stack is full or not.'
 peek():
To returns the element at the given position.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 15
Stack Operations
 count():
It returns the total number of elements available in a stack.
 change():
It changes the element at the given position.
 display():
It prints all the elements available in the stack.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC
16
PUSH operation in Stack
The steps involved in the PUSH operation is given below:
 To insert an element into a stack, user has to check whether the stack is full.
 If the user inserts an element into a stack when the stack is full, then it is a overflow condition.
 To initialize a stack, user has to set the value of top as -1 to check whether the stack is empty are not.
 To insert new element, it is pushed into a stack, first, the value of the top gets incremented, i.e., top=top+1,
and the element will be placed at the new position of the top.
 Elements can be inserted until we reach the max size of the stack.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 17
POP Operation
 To delete an element from the stack, user has to check whether the stack is empty.
 To delete an element from an empty stack, then it is an underflow condition.
 If the stack is not empty, first access is done on the element which is pointed by the top
 Pop operation is performed, the top is decremented by 1, i.e., top=top-1.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 18
Application for Stack
 Balancing of symbols: Stack is used for balancing a symbol.
 String reversal
 Undo/Redo
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 19
LINKED LIST
 Linked list is a linear data structure that includes a series of connected nodes.
 Linked list can be defined as the nodes that are randomly stored in the memory.
 A node in the linked list contains two parts,
 the Data part
 the Address part.
 The last node of the list contains a pointer to the null.
 After array, linked list is the second most used data structure.
 In a linked list, every link contains a connection to another link.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 20
Types of Linked List
 SINGLY LINKED LIST
 DOUBLY LINKED LIST
 CIRCULAR LINKED LIST
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 21
Operations in Linked List
 INSERTION:
This operation adds an element into the list.
 DELETION:
It is performed to delete an operation from the list.
 DISPLAY:
It is performed to display the elements of the list.
 SEARCH:
It is performed to search an element from the list using the given key.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 22
Applications of Linked List
 Image viewer
Previous and next images are linked, hence can be accessed by next and previous button.
 Previous and next page in web browser
User can access previous and next url searched in web browser by pressing back and next button
since, they are linked as linked list.
 Music Player
Songs in music player are linked to previous and next song. User can play songs either from starting
or ending of the list.
Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 23

More Related Content

Similar to Fundamental of Datastructure

DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
Data Structure
Data Structure Data Structure
Data Structure Ibrahim MH
 
2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdfSulabhPawaia
 
chapter three ppt.pptx
chapter three ppt.pptxchapter three ppt.pptx
chapter three ppt.pptxselemonGamo
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++Gopi Nath
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1Aahwini Esware gowda
 
SIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxSIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxsagabo1
 
Introduction to Data Structures .
Introduction to Data Structures        .Introduction to Data Structures        .
Introduction to Data Structures .Ashutosh Satapathy
 
datastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptxdatastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptxDEEPAK948083
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Tutort Academy
 
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEVenugopalavarma Raja
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data StructureRabin BK
 

Similar to Fundamental of Datastructure (20)

Dsa unit 1
Dsa unit 1Dsa unit 1
Dsa unit 1
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
Data Structure
Data Structure Data Structure
Data Structure
 
Data structure and its types.
Data structure and its types.Data structure and its types.
Data structure and its types.
 
2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf
 
chapter three ppt.pptx
chapter three ppt.pptxchapter three ppt.pptx
chapter three ppt.pptx
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1
 
SIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptxSIX WEEKS SUMMER TRAINING REPORT.pptx
SIX WEEKS SUMMER TRAINING REPORT.pptx
 
Introduction to Data Structures .
Introduction to Data Structures        .Introduction to Data Structures        .
Introduction to Data Structures .
 
DS_PPT.pptx
DS_PPT.pptxDS_PPT.pptx
DS_PPT.pptx
 
Intro ds
Intro dsIntro ds
Intro ds
 
datastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptxdatastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptx
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
 
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCEARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 

Recently uploaded

Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 

Recently uploaded (20)

Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 

Fundamental of Datastructure

  • 1. FUNDAMENTALS OF DATASTRUCTURE By Sri. C. RANJITHKUMAR, M.Sc.(IT & M)., M.Phil., Assistant Professor, Department of Computer Science, VIVEKANANDA COLLEGE, TIIRUVEDAKAM WEST MADURAI Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 1
  • 2. PROLOGUE  Introduction  Basic terminology  Datastructures and its Classification  Datastructure operations  Applications of Datastructures Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, Vivekananda College 2
  • 3. INTRODUCTION  Data Structure is a way of collecting and organizing data, in such a way that user can perform operations on these data in an effective way.  Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. For example Consider we have data of player's name "Virat" and age 26. Here "Virat" is of String data type and 26 is of Integer data type. User can organize this data as a record like Player record. Now we can collect and store player's records in a file or database as a data structure. For example: “Dhoni" 30, "Gambhir" 31, "Sehwag" 33.  In simple language, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, Vivekananda College 3
  • 4. BASIC TERMINOLOGY OF DATA ORGANIZATION  DATA : The term ‘DATA’ simply refers to a value or a set of values. (EXAMPLE) roll no of a student, marks, name of an employee, address of person etc.  DATA ITEM : A data item refers to a single unit of value. Data items that can be divided into sub items are called group items (Eg. Address, Date, Name) Data items can not be divided in to sub items are called elementary items (Eg. Roll no, Marks, City, Pin-code etc.)  ENTITY – Data items with similar attributes is called an Entity set ( Eg. all employees of an organization)  INFORMATION - Processed data, Data with given attribute Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 4
  • 5. BASIC TERMINOLOGY OF DATA ORGANIZATION  FIELD – It is a single elementary unit of information represented as an attribute of an entity  RECORD – It is a collection of field values of a given entity  FILE – It is a collection of records of the entities in a given entity set (Eg.) Name Age Sex Roll Number Branch A 17 M 109cs0132 CSE B 18 M 109ee1234 EE Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 5
  • 6. CLASSIFICATION OF DATASTRUCTURES Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 6
  • 7. BASIC OPERATIONS  TRAVERSING: Accessing each record exactly once so that certain items in the record may be processed.  SEARCHING: Finding the location of a particular record with a given key value, or finding the location of all records which satisfy one or more conditions.  INSERTING: Adding a new record to the structure.  DELETING: Removing the record from the structure.  SORTING: Managing the data or record in some logical order (Ascending or descending order).  MERGING: Combining the record in two different sorted files into a single sorted file. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 7
  • 8. PRIMITIVE DATASTRUCTURES  PRIMITIVE DATASTRUCTURES: Primitive data structure is a fundamental type of data structure that stores the data of only one type (Eg.) Integer, float, character Integer variable can hold integer type of value Float variable can hold floating type of value Character variable can hold character type of value Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 8
  • 9. NON-PRIMITIVE DATASTRUCTURES  NON-PRIMITIVE DATA STRUCTURES are user-defined that stores the data of different types in a single entity.  It is categorized into two types: 1. LINEAR DATA STRUCTURE 2. NON-LINEAR DATA STRUCTURE  LINEAR DATA STRUCTURES are sequential type of data structure, that is all the elements in the memory are stored in a sequential manner For example, element stored after the second element would be the third element, the element stored after the third element would be the fourth element and so on. Linear data structures holding the sequential values such as Array, Stack, Linked List and Queue  NON-LINEAR DATA STRUCTURES is a kind of random type of data structure. The non-linear data structures are Tree and Graph. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 9
  • 10. DIFFERENCE PRIMITIVE DATASTRUCTURES NON-PRIMITIVE DATASTRUCTURES Primitive data structures stores the data of only one type. Non-primitive data structures that can store data that are more than one type. (Eg) integer, character, float. (Eg) Array, Stack, Linked list, stack. These contains some value and cannot be NULL.(empty) These can store NULL value.(empty) Size depends on the type of the data structure Size is not fixed. It can hold a single value in a specific location It can hold multiple values either in a contiguous location or random locations Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 10
  • 11. Characteristics of Primitive Datastructures  INTEGER: The integer data type contains the numeric values. It contains the whole numbers that can be either negative or positive. When the range of integer data type is not large enough then in that case, we can use long.  FLOAT: The float is a data type that can hold decimal values. When the precision of decimal value increases then the Double data type is used.  BOOLEAN: It is a data type that can hold either a True or a False value. It is mainly used for checking the condition.  CHARACTER: It is a data type that can hold a single character value both uppercase and lowercase such as 'A' or 'a'. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 11
  • 12. Characteristics of Non-Primitive Datastructures ARRAY:  Each element in an array is of the same data type and carries the same size that is 4 bytes.  Elements in the array are stored at contiguous memory locations from which the first element is stored at the smallest memory location.  Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element.  User can perform operations such insertion, deletion, traversing, searching and update. For example: Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 12
  • 13. Applications of Arrays  To store the possible moves in a chess game.  Password storage and generation  Marks storage and generation Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 13
  • 14. STACK  A Stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle.  Stack is one ended  It contains top pointer which points to the topmost element of the stack.  Any element added into the stack, it is added only at the top of the stack.  A stack can be defined as a container in which insertion and deletion can be done from the one end known as the top of the stack. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 14
  • 15. Stack Operations  push(): To insert an element in a stack then the operation is known as a push. If the stack is full then the overflow condition occurs.  pop(): To delete an element from the stack, the operation is known as a pop. If the stack is empty means that no element exists in the stack, this state is known as an underflow state.  isEmpty(): To determine whether the stack is empty or not.  isFull(): To determine whether the stack is full or not.'  peek(): To returns the element at the given position. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 15
  • 16. Stack Operations  count(): It returns the total number of elements available in a stack.  change(): It changes the element at the given position.  display(): It prints all the elements available in the stack. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 16
  • 17. PUSH operation in Stack The steps involved in the PUSH operation is given below:  To insert an element into a stack, user has to check whether the stack is full.  If the user inserts an element into a stack when the stack is full, then it is a overflow condition.  To initialize a stack, user has to set the value of top as -1 to check whether the stack is empty are not.  To insert new element, it is pushed into a stack, first, the value of the top gets incremented, i.e., top=top+1, and the element will be placed at the new position of the top.  Elements can be inserted until we reach the max size of the stack. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 17
  • 18. POP Operation  To delete an element from the stack, user has to check whether the stack is empty.  To delete an element from an empty stack, then it is an underflow condition.  If the stack is not empty, first access is done on the element which is pointed by the top  Pop operation is performed, the top is decremented by 1, i.e., top=top-1. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 18
  • 19. Application for Stack  Balancing of symbols: Stack is used for balancing a symbol.  String reversal  Undo/Redo Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 19
  • 20. LINKED LIST  Linked list is a linear data structure that includes a series of connected nodes.  Linked list can be defined as the nodes that are randomly stored in the memory.  A node in the linked list contains two parts,  the Data part  the Address part.  The last node of the list contains a pointer to the null.  After array, linked list is the second most used data structure.  In a linked list, every link contains a connection to another link. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 20
  • 21. Types of Linked List  SINGLY LINKED LIST  DOUBLY LINKED LIST  CIRCULAR LINKED LIST Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 21
  • 22. Operations in Linked List  INSERTION: This operation adds an element into the list.  DELETION: It is performed to delete an operation from the list.  DISPLAY: It is performed to display the elements of the list.  SEARCH: It is performed to search an element from the list using the given key. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 22
  • 23. Applications of Linked List  Image viewer Previous and next images are linked, hence can be accessed by next and previous button.  Previous and next page in web browser User can access previous and next url searched in web browser by pressing back and next button since, they are linked as linked list.  Music Player Songs in music player are linked to previous and next song. User can play songs either from starting or ending of the list. Fundamentals of Datastructures by Sri.C.Ranjithkumar, Asst. Professor of CS, VC 23