SlideShare a Scribd company logo
DATA STRUCTURE
Unit – I Part A
Syllabus:
• Introduction:
• Pseudo code
• Algorithm Header
• Purpose, Conditions, Return
• Statement Numbers
• Variables
• Algorithm Analysis
• Statement Constructs
• Pseudo Example
• The Abstract Data Type
• Atomic and Composite Data
• Data Structure
• Abstract Data Type
• A model for an Abstract Data Type
• ADT Operations
• ADT Data Structure
• ADT Class Templates
• Algorithm Efficiency
• Linear Loops
• Logarithmic Loops
• Nested Loops
• Big-O Notation
• Standard Measures of Efficiency
• Big-O Analysis Examples
• Searching:
• List Searches
• Sequential Search
• Sequential Search Algorithm
• Variations on Sequential
• Searches
• Sentinel Search
• Probability Search
• Ordered List Search
• Binary Search
• Target Found
• Target Not Found
• Binary Search Algorithm
• Binary Search Algorithms
• Analyzing Search Algorithms
• Sequential Search
• Binary Search
• Hashed List Searches
• Basic Concepts
• Hashing Methods
• Direct Method
• Subtraction Method
• Modulo-division Method
• Digit-extraction Method
• Midsquare Method
• Folding Methods
• Rotation Method
• Pseudorandom Hashing
• One Hashing Algorithm
• Collision Resolution
• Open Addressing
• Linear Probe
• Quadratic Probe Pseudorandom Collision
• Resolution
• Key Offset
• Linked List Resolution
• Bucket Hashing
• Combination Approaches
• Hash List Example
Pseudo Code:
• Several tools are used to define algorithms, one of the
most common is pseudo code.
• It is an English like representation of the code required for
an algorithm.
• It provides a related syntax that is easy to read.
Pseudo code
• It is a compact and informal high-level description
program.
• {
• pseudo = imitation or false,
• code = instruct written in program language
• }
• It is used for planning a program
• It is also called as Program Design Language (PDL).
• Logical Structure of Pseudo code:
• Sequence logic
• Selection logic
• Iteration logic
• One of the most common tools for defining
algorithms is pseudo code, which is part English, part
structured code.
• This data definition describes a node in a self-
referential linked list that consists of a nested
structure (data) and a pointer to the next node (link).
Algorithm:
Data structure Unit-I Part A
Data structure Unit-I Part A
Data structure Unit-I Part A
Algorithm Header:
• Each algorithm begins with a header that names it,
describes its parameters, and lists any pre and post
conditions.
• Important because the programmer using the algorithm
often sees only the header information, not the complete
algorithm.
Data structure Unit-I Part A
Purpose:
• It is a short statement about what the algorithms does.
• It needs to describe only the general algorithms
processing.
• It should not attempt to describe all of the processing.
Conditions:
• Precondition:
• It lists any precursor requirements for the parameters.
• Postcondition:
• It identifies any action taken and the status of any output
parameters.
Return:
• If a value is returned, it will be identified by a return
condition.
• Often there is none, and no return condition is needed.
Statements Numbers:
• They are numbered using an abbreviated decimal
notation in which only the last of the number sequence.
• It is shown on each statement.
• End/Exit conditions:
• The end of the selection is indicated by the end.
• The end of the loop is indicated by end statement/loop.
Variables:
• It is not necessary to define every variable used in the
algorithm, especially when the context of the data is
indicated by its name.
• The selection of the name for an algorithm or variable
goes a long way toward making the algorithm and its
coded implementation more readable.
Rules:
Don’t use single character names.
• Example:
• Variable i and j use in C++ for loops.
• There is always a better name.
Don’t use generic names.
• Example:
• Generic names are count, sum, total, row, column and file.
Abbreviations aren’t excluded as intelligent data names.
• Example:
• stuCnt is good abbreviation for studentCount.
Algorithm Analysis:
• Not every line of code is explained.
• Rather, the analysis examines only those points that
either need to be emphasized or that may require some
clarification.
• It also often introduces style or efficiency considerations.
Statement Constructs:
• Niklaus Wirth stated that any algorithm could be written
with only three programming constructs: sequence,
selection and loop.
• Our pseudo code contains only these three basic
constructs.
Sequence Statements:
• It is a series of statements that don’t alter the execution
path within an algorithm.
• It is obvious that statements such as assign and add are
sequence statements.
• It is lies in the structured programming concept.
• When an algorithm completes, it returns to the statement
immediately after the call that invoked it.
Selection Statements:
• It evaluate one or more alternatives.
• If the alternatives are true, one path is taken.
• If the alternatives are false, a different path is taken.
• The typical selection statement is the two-way selection
Data structure Unit-I Part A
Loop Statement:
• It iterates a block of code.
• The loop that we use in our pseudo code most closely
resembles the while loop.
Data structure Unit-I Part A
Pseudocode Example:
• Algorithm deviation
• Pre nothing
• Post average and numbers with their deviation
printed
• 1 i = 0
• 2 loop (not end of file)
• 1 read number into array[i]
• 2 sum = sum + number
• 3 I = i+1
• 3 end loop
• 4 average = sum / i
• 5 print (average)
• 6 j = 0
• 7 loop (j < i)
• 1 devFromAve = array[j] – average
• 2 print (array[j], devFromAve)
• 3 j = j +1
• 8 end loop
• 9 return
• end deviation
The Abstract Data Type:
• We started with non-structured, linear programs, known as
spaghetti code.
• In which the logic flow wound through the program like
spaghetti on a plate.
• The concept of modular programming, in which programs were
organized in functions, each of which still used a linear coding
techniques.
• Data Type:
• A set of data
• Example: Integer data type – whole numbers in some defined range.
• Operations that can be performed on the data
• Example: add, subtract, divide, multiply and other operation
• Object Oriented Programming:
• The latest development in the theory of program design.
• The functions are developed around an object, such as a linked list.
• Encapsulation:
• One of the part of OOPs concept.
• It is one of the primary concepts behind the abstract data type.
• Abstract data type is implemented in C++ class.
Data Types:
• Atomic data
• Composite data
Atomic data:
• They are data that we choose to consider as a single,
non-decomposable/inseparable entity.
• Example: Integer 4562 consider as a single integer value.
• An atomic data type is a set of atomic data with identical
properties.
• Atomic data types are defined by a set of values and a
set of operations that act on the values.
Atomic data type:
• A set of atomic values
• A set of operations on those values
Example for atomic data types:
• Integer values:- -2, -1, 0, 1, 2, 765
operation: +,-,*,/……
• Float-point values:- ,……,0.0, 0.1, 2.34, 35.890
operations:+,-,*,/….
• Character values: ‘A’,’B’,……’Z’, ‘a’, ’b’…..
operation:+,-,
Composite data:
• The opposite of atomic data is composite data.
• It can be broken out into sub-fields that have meeting.
• Example:
• Your telephone number.
• Because the number has three different parts.
• First – area code
• Second – ph.no is actually two different data items, a
prefix consisting of a three-digit exchange
• Third – The number within exchange, consisting of four
digits.
• Prefixes were names such as DAvenport and Cypress.
Example for composite data types:
Data
• Values: 09-09-2020
• Separated into day, month & year
• Operations: add two data values
• subtract two data values
Data Structure:
• A data structure is an aggregation of atomic and
composite data types into a set with defined relationships.
• Data is a value
• Structure is a set of rules that hold the data together.
• Otherwise, if we take a combination of data types and fit
them into a structure such can define its relating rules.
• Example:
• Array and record
Important:
• A combination of elements each of which is either a data
type or another data structure.
• A set of associations or relationships involving the
combined elements.
Array Record
Homogeneous sequence of data or
data types known as elements
Heterogeneous combination of data
into a single structure with an
identified key.
Position association among the
elements
No association
Abstract Data Type (ADT):
• When we first started programming, there were no abstract
data types.
• If we wanted to read a file, we wrote the code to read the
physical file
• device.
• It did not take long to realize that we were writing the same
code over and over again.
• We wrote the code to read a file and placed it in a library
for all programmers to use.
• This concept is found in modern languages today.
• The code to read the keyboard is an ADT.
• It has a data structure, a character, and a set of
operations that can be used to read that data structure.
• Using the ADT we can not only read characters but we
can also convert them into different data structures such
as integers and strings.
• The ADT consists of a set of definitions that allow
programmers to use the functions while hiding the
implementation.
• This generalization of operations with unspecified
implementations is known as abstraction.
The concept of abstraction means:
• 1. We know what a data type can do.
• 2. How it is done is hidden.
Solutions:
• We can write a program that simulates the queue our
analyst needs.
• We can write a queue ADT that can be used to solve any
queue problem.
• An abstract data type is a data declaration packaged
together with the operations that are meaningful for the
data type.
• We can encapsulate the data and the operations on the
data, and then we hide them from the user.
Abstract Data Type
• 1. Declaration of data
• 2. Declaration of operations
• 3. Encapsulation of data and operations
Data structure Unit-I Part A
ADT Operations:
• Types of ADT operations:
• Constructors
• No preconditions
• Postconditions describe the “value” of the ADT instance,
by telling what the access functions return
• Access functions
• No postconditions
• Manipulation procedures
• Postconditions describe the “value” of the ADT instance,
by telling what the access functions return
ADT Data Structure:
• Develop like stacks, queues, lists, binary search
• trees, AVL trees, B-trees, heaps, and graphs.
Data structure Unit-I Part A
ADT Class Templates:
• Two general components of structure are the data and
key identifier.
• The data structure is given a template identifier of TYPE
which the application programmer must use ADT class us
defined.
• The template is a key type identifier, KTYPE.
• The application programmer must use this type when
creating the data structure in the program.
ADT Class Template Implementation:

More Related Content

What's hot (20)

PPTX
Getting Started with R
Sankhya_Analytics
 
PPTX
Javaiostream
Manav Prasad
 
PPT
Data structure
Muhammad Farhan
 
PDF
What is in a Lucene index?
lucenerevolution
 
ODP
Search Lucene
Jeremy Coates
 
PDF
Flexible Indexing in Lucene 4.0
Lucidworks (Archived)
 
PDF
Munching & crunching - Lucene index post-processing
abial
 
PPT
INTERNET PROTOCOL VERSION 6
Chaitanya Ram
 
PDF
Berlin Buzzwords 2013 - How does lucene store your data?
Adrien Grand
 
PPT
Lucene BootCamp
GokulD
 
PPT
Comparison between ipv4 and ipv6
Dharmesh Patel
 
PPTX
Internet Protocol version 6
Rekha Yadav
 
PDF
Ii pu cs practical viva voce questions
Prof. Dr. K. Adisesha
 
PPT
Hashing
Devyani Vaidya
 
PPTX
Indexing structure for files
Zainab Almugbel
 
PPT
Internet Protocol Version 6 By Suvo 2002
suvobgd
 
PPTX
Unit 1 abstract data types
LavanyaJ28
 
PPTX
Email Forensics
primeteacher32
 
PPT
Data Structures & Algorithms
Ain-ul-Moiz Khawaja
 
PPTX
IPv6 address
Pina Parmar
 
Getting Started with R
Sankhya_Analytics
 
Javaiostream
Manav Prasad
 
Data structure
Muhammad Farhan
 
What is in a Lucene index?
lucenerevolution
 
Search Lucene
Jeremy Coates
 
Flexible Indexing in Lucene 4.0
Lucidworks (Archived)
 
Munching & crunching - Lucene index post-processing
abial
 
INTERNET PROTOCOL VERSION 6
Chaitanya Ram
 
Berlin Buzzwords 2013 - How does lucene store your data?
Adrien Grand
 
Lucene BootCamp
GokulD
 
Comparison between ipv4 and ipv6
Dharmesh Patel
 
Internet Protocol version 6
Rekha Yadav
 
Ii pu cs practical viva voce questions
Prof. Dr. K. Adisesha
 
Indexing structure for files
Zainab Almugbel
 
Internet Protocol Version 6 By Suvo 2002
suvobgd
 
Unit 1 abstract data types
LavanyaJ28
 
Email Forensics
primeteacher32
 
Data Structures & Algorithms
Ain-ul-Moiz Khawaja
 
IPv6 address
Pina Parmar
 

Similar to Data structure Unit-I Part A (20)

PPTX
Chap_________________1_Introduction.pptx
Ronaldo Aditya
 
PPTX
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
PPTX
ADS Introduction
NagendraK18
 
PPTX
Unit 1, ADA.pptx
jinkhatima
 
PPTX
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
PPT
Basics of c++ Programming Language
Ahmad Idrees
 
DOCX
Data structure and algorithm.
Abdul salam
 
PPTX
Aspdot
Nishad Nizarudeen
 
PDF
Data structures and algorithms Module-1.pdf
DukeCalvin
 
PPT
ds 1 Introduction to Data Structures.ppt
AlliVinay1
 
PPT
Basic elements of java
Ahmad Idrees
 
PDF
INTRODUCTION TO C PROGRAMMING in basic c language
GOKULKANNANMMECLECTC
 
PPTX
Intro to Data Structure & Algorithms
Akhil Kaushik
 
PDF
DSA
rrupa2
 
PPTX
Data Structure and Algorithms
iqbalphy1
 
PDF
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
NGUYNTHNHQUC2
 
PPT
Basic terminologies & asymptotic notations
Rajendran
 
PPTX
Searching Algorithms
Afaq Mansoor Khan
 
PPTX
C programming language tutorial
Dr. SURBHI SAROHA
 
PPT
Intro.ppt
Anonymous9etQKwW
 
Chap_________________1_Introduction.pptx
Ronaldo Aditya
 
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
ADS Introduction
NagendraK18
 
Unit 1, ADA.pptx
jinkhatima
 
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Basics of c++ Programming Language
Ahmad Idrees
 
Data structure and algorithm.
Abdul salam
 
Data structures and algorithms Module-1.pdf
DukeCalvin
 
ds 1 Introduction to Data Structures.ppt
AlliVinay1
 
Basic elements of java
Ahmad Idrees
 
INTRODUCTION TO C PROGRAMMING in basic c language
GOKULKANNANMMECLECTC
 
Intro to Data Structure & Algorithms
Akhil Kaushik
 
DSA
rrupa2
 
Data Structure and Algorithms
iqbalphy1
 
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
NGUYNTHNHQUC2
 
Basic terminologies & asymptotic notations
Rajendran
 
Searching Algorithms
Afaq Mansoor Khan
 
C programming language tutorial
Dr. SURBHI SAROHA
 
Intro.ppt
Anonymous9etQKwW
 
Ad

More from SSN College of Engineering, Kalavakkam (20)

PDF
Localization, Classification, and Evaluation.pdf
SSN College of Engineering, Kalavakkam
 
PPTX
Database Management System - 2a
SSN College of Engineering, Kalavakkam
 
PPTX
Database Management System
SSN College of Engineering, Kalavakkam
 
PPTX
Unit III - Inventory Problems
SSN College of Engineering, Kalavakkam
 
PPTX
Unit II B - Game Theory
SSN College of Engineering, Kalavakkam
 
PPTX
Unit II A - Game Theory
SSN College of Engineering, Kalavakkam
 
PPTX
Unit V - Queuing Theory
SSN College of Engineering, Kalavakkam
 
PPTX
Unit IV-Project Management
SSN College of Engineering, Kalavakkam
 
PPTX
Web technology Unit-II Part-C
SSN College of Engineering, Kalavakkam
 
PPTX
Data structure Unit-I Part-C
SSN College of Engineering, Kalavakkam
 
PPTX
Data structure unit I part B
SSN College of Engineering, Kalavakkam
 
PPTX
Web technology Unit-II Part A
SSN College of Engineering, Kalavakkam
 
PPTX
Web technology Unit-I Part E
SSN College of Engineering, Kalavakkam
 
Ad

Recently uploaded (20)

PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Dimensions of Societal Planning in Commonism
StefanMz
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 

Data structure Unit-I Part A

  • 2. Syllabus: • Introduction: • Pseudo code • Algorithm Header • Purpose, Conditions, Return • Statement Numbers • Variables • Algorithm Analysis • Statement Constructs • Pseudo Example
  • 3. • The Abstract Data Type • Atomic and Composite Data • Data Structure • Abstract Data Type • A model for an Abstract Data Type • ADT Operations • ADT Data Structure • ADT Class Templates • Algorithm Efficiency • Linear Loops • Logarithmic Loops • Nested Loops • Big-O Notation • Standard Measures of Efficiency • Big-O Analysis Examples
  • 4. • Searching: • List Searches • Sequential Search • Sequential Search Algorithm • Variations on Sequential • Searches • Sentinel Search • Probability Search • Ordered List Search • Binary Search • Target Found • Target Not Found • Binary Search Algorithm • Binary Search Algorithms • Analyzing Search Algorithms • Sequential Search • Binary Search
  • 5. • Hashed List Searches • Basic Concepts • Hashing Methods • Direct Method • Subtraction Method • Modulo-division Method • Digit-extraction Method • Midsquare Method • Folding Methods • Rotation Method • Pseudorandom Hashing • One Hashing Algorithm • Collision Resolution • Open Addressing • Linear Probe • Quadratic Probe Pseudorandom Collision • Resolution • Key Offset • Linked List Resolution • Bucket Hashing • Combination Approaches • Hash List Example
  • 6. Pseudo Code: • Several tools are used to define algorithms, one of the most common is pseudo code. • It is an English like representation of the code required for an algorithm. • It provides a related syntax that is easy to read.
  • 7. Pseudo code • It is a compact and informal high-level description program. • { • pseudo = imitation or false, • code = instruct written in program language • } • It is used for planning a program • It is also called as Program Design Language (PDL).
  • 8. • Logical Structure of Pseudo code: • Sequence logic • Selection logic • Iteration logic • One of the most common tools for defining algorithms is pseudo code, which is part English, part structured code.
  • 9. • This data definition describes a node in a self- referential linked list that consists of a nested structure (data) and a pointer to the next node (link).
  • 14. Algorithm Header: • Each algorithm begins with a header that names it, describes its parameters, and lists any pre and post conditions. • Important because the programmer using the algorithm often sees only the header information, not the complete algorithm.
  • 16. Purpose: • It is a short statement about what the algorithms does. • It needs to describe only the general algorithms processing. • It should not attempt to describe all of the processing.
  • 17. Conditions: • Precondition: • It lists any precursor requirements for the parameters. • Postcondition: • It identifies any action taken and the status of any output parameters.
  • 18. Return: • If a value is returned, it will be identified by a return condition. • Often there is none, and no return condition is needed.
  • 19. Statements Numbers: • They are numbered using an abbreviated decimal notation in which only the last of the number sequence. • It is shown on each statement. • End/Exit conditions: • The end of the selection is indicated by the end. • The end of the loop is indicated by end statement/loop.
  • 20. Variables: • It is not necessary to define every variable used in the algorithm, especially when the context of the data is indicated by its name. • The selection of the name for an algorithm or variable goes a long way toward making the algorithm and its coded implementation more readable.
  • 21. Rules: Don’t use single character names. • Example: • Variable i and j use in C++ for loops. • There is always a better name. Don’t use generic names. • Example: • Generic names are count, sum, total, row, column and file. Abbreviations aren’t excluded as intelligent data names. • Example: • stuCnt is good abbreviation for studentCount.
  • 22. Algorithm Analysis: • Not every line of code is explained. • Rather, the analysis examines only those points that either need to be emphasized or that may require some clarification. • It also often introduces style or efficiency considerations.
  • 23. Statement Constructs: • Niklaus Wirth stated that any algorithm could be written with only three programming constructs: sequence, selection and loop. • Our pseudo code contains only these three basic constructs.
  • 24. Sequence Statements: • It is a series of statements that don’t alter the execution path within an algorithm. • It is obvious that statements such as assign and add are sequence statements. • It is lies in the structured programming concept. • When an algorithm completes, it returns to the statement immediately after the call that invoked it.
  • 25. Selection Statements: • It evaluate one or more alternatives. • If the alternatives are true, one path is taken. • If the alternatives are false, a different path is taken. • The typical selection statement is the two-way selection
  • 27. Loop Statement: • It iterates a block of code. • The loop that we use in our pseudo code most closely resembles the while loop.
  • 29. Pseudocode Example: • Algorithm deviation • Pre nothing • Post average and numbers with their deviation printed • 1 i = 0 • 2 loop (not end of file) • 1 read number into array[i] • 2 sum = sum + number • 3 I = i+1 • 3 end loop • 4 average = sum / i • 5 print (average)
  • 30. • 6 j = 0 • 7 loop (j < i) • 1 devFromAve = array[j] – average • 2 print (array[j], devFromAve) • 3 j = j +1 • 8 end loop • 9 return • end deviation
  • 31. The Abstract Data Type: • We started with non-structured, linear programs, known as spaghetti code. • In which the logic flow wound through the program like spaghetti on a plate. • The concept of modular programming, in which programs were organized in functions, each of which still used a linear coding techniques.
  • 32. • Data Type: • A set of data • Example: Integer data type – whole numbers in some defined range. • Operations that can be performed on the data • Example: add, subtract, divide, multiply and other operation • Object Oriented Programming: • The latest development in the theory of program design. • The functions are developed around an object, such as a linked list. • Encapsulation: • One of the part of OOPs concept. • It is one of the primary concepts behind the abstract data type. • Abstract data type is implemented in C++ class.
  • 33. Data Types: • Atomic data • Composite data
  • 34. Atomic data: • They are data that we choose to consider as a single, non-decomposable/inseparable entity. • Example: Integer 4562 consider as a single integer value. • An atomic data type is a set of atomic data with identical properties. • Atomic data types are defined by a set of values and a set of operations that act on the values.
  • 35. Atomic data type: • A set of atomic values • A set of operations on those values
  • 36. Example for atomic data types: • Integer values:- -2, -1, 0, 1, 2, 765 operation: +,-,*,/…… • Float-point values:- ,……,0.0, 0.1, 2.34, 35.890 operations:+,-,*,/…. • Character values: ‘A’,’B’,……’Z’, ‘a’, ’b’….. operation:+,-,
  • 37. Composite data: • The opposite of atomic data is composite data. • It can be broken out into sub-fields that have meeting. • Example: • Your telephone number. • Because the number has three different parts. • First – area code • Second – ph.no is actually two different data items, a prefix consisting of a three-digit exchange • Third – The number within exchange, consisting of four digits. • Prefixes were names such as DAvenport and Cypress.
  • 38. Example for composite data types: Data • Values: 09-09-2020 • Separated into day, month & year • Operations: add two data values • subtract two data values
  • 39. Data Structure: • A data structure is an aggregation of atomic and composite data types into a set with defined relationships. • Data is a value • Structure is a set of rules that hold the data together. • Otherwise, if we take a combination of data types and fit them into a structure such can define its relating rules. • Example: • Array and record
  • 40. Important: • A combination of elements each of which is either a data type or another data structure. • A set of associations or relationships involving the combined elements.
  • 41. Array Record Homogeneous sequence of data or data types known as elements Heterogeneous combination of data into a single structure with an identified key. Position association among the elements No association
  • 43. • When we first started programming, there were no abstract data types. • If we wanted to read a file, we wrote the code to read the physical file • device. • It did not take long to realize that we were writing the same code over and over again. • We wrote the code to read a file and placed it in a library for all programmers to use.
  • 44. • This concept is found in modern languages today. • The code to read the keyboard is an ADT. • It has a data structure, a character, and a set of operations that can be used to read that data structure. • Using the ADT we can not only read characters but we can also convert them into different data structures such as integers and strings.
  • 45. • The ADT consists of a set of definitions that allow programmers to use the functions while hiding the implementation. • This generalization of operations with unspecified implementations is known as abstraction. The concept of abstraction means: • 1. We know what a data type can do. • 2. How it is done is hidden.
  • 46. Solutions: • We can write a program that simulates the queue our analyst needs. • We can write a queue ADT that can be used to solve any queue problem.
  • 47. • An abstract data type is a data declaration packaged together with the operations that are meaningful for the data type. • We can encapsulate the data and the operations on the data, and then we hide them from the user. Abstract Data Type • 1. Declaration of data • 2. Declaration of operations • 3. Encapsulation of data and operations
  • 49. ADT Operations: • Types of ADT operations: • Constructors • No preconditions • Postconditions describe the “value” of the ADT instance, by telling what the access functions return • Access functions • No postconditions • Manipulation procedures • Postconditions describe the “value” of the ADT instance, by telling what the access functions return
  • 50. ADT Data Structure: • Develop like stacks, queues, lists, binary search • trees, AVL trees, B-trees, heaps, and graphs.
  • 52. ADT Class Templates: • Two general components of structure are the data and key identifier. • The data structure is given a template identifier of TYPE which the application programmer must use ADT class us defined. • The template is a key type identifier, KTYPE. • The application programmer must use this type when creating the data structure in the program.
  • 53. ADT Class Template Implementation: