SlideShare a Scribd company logo
1 of 37
PROGRAMMING AND
DATA STRUCTURES IN C
Ms. UMA. S
Assistant Professor
Computer Science/Computer Applications
Thiruvalluvar University College of Arts and Science, Tirupattur
OBJECTIVES
 Learning program independent view of data structures,
including its representation and operations performed on
them, which are then linked to sorting, searching and
indexing methods to increase the knowledge of usage of
data structures in algorithmic perspective.
 UNIT-I
 Abstract Data Types –
 Asymptotic Notations: Big-Oh, Omega and Theta –
 Best, Worst and Average case Analysis: Definition and an example –
 Arrays and its representations –
 Stacks and Queues –
 Linked lists –
 Linked list based implementation of Stacks and Queues –
 Evaluation of Expressions –
 Linked list based polynomial addition.
 UNIT-II
 Trees –
 Binary Trees – Binary tree representation and traversals –
 Threaded binary trees –
 Binary tree representation of trees –
 Application of trees: Set representation and Union-
 Find operations –
 Graph and its representations –
 Graph Traversals –
 Connected components
 UNIT-III
 AVL Trees – Red-Black Trees – Splay Trees – Binary Heap – Leftist Heap
UNIT–IV
 Insertion sort – Merge sort – Quick sort – Heap sort – Sorting with disks – k-
way merging – Sorting with tapes – Polyphase merge.
 UNIT-V
 Linear Search – Binary Search - Hash tables – Overflow handling – Cylinder
Surface Indexing – Hash Index – B-Tree Indexing.
 TEXT BOOK
 1. Ellis Horowitz and Sartaj Sahni, Fundamentals of Data Structures, Galgotia
Book Sorce, Gurgaon, 1993.
 2. Gregory L. Heilman, Data Structures, Algorithms and Object Oriented
Programming, Tata Mcgraw-Hill, New Delhi, 2002.
 REFERENCES
 1. Jean-Paul Tremblay and Paul G. Sorenson, An Introduction to Data
Structures with Applications, Second Edition, Tata McGraw-Hill, New Delhi,
1991.
 2. Alfred V. Aho, John E. Hopcroft and Jeffry D. Ullman, Data Structures and
Algorithms, Pearson Education, New Delhi, 2006
Data Structure
 Data structure is a representation of data and
the operations allowed on that data.
 A data structure is a way to store and organize data in
order to facilitate the access and modifications.
 Data Structure are the method of representing of
logical relationships between individual data elements
related to the solution of a given problem.
Basic Data Structure
Basic Data Structures
Linear Data Structures Non-Linear Data Structures
Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables
array
Linked list
tree
queue
stack
Selection of Data Structure
 The choice of particular data model depends on
two consideration:
It must be rich enough in structure to represent
the relationship between data elements
The structure should be simple enough that one
can effectively process the data when
necessary
Types of Data Structure
Linear: In Linear data structure, values
are arrange in linear fashion.
 Array: Fixed-size
 Linked-list: Variable-size
 Stack: Add to top and remove from top
 Queue: Add to back and remove from front
 Priority queue: Add anywhere, remove the highest priority
Types of Data Structure
 Non-Linear: The data values in this structure
are not arranged in order.
 Hash tables: Unordered lists which use a ‘hash
function’ to insert and search
 Tree: Data is organized in branches.
 Graph: A more general branching structure, with
less strict connection conditions than for a tree
Type of Data Structures
 Homogenous: In this type of data structures,
values of the same types of data are stored.
 Array
 Non-Homogenous: In this type of data structures,
data values of different types are grouped and
stored.
 Structures
 Classes
Abstract Data Type and Data Structure
 Definition:-
 Abstract Data Types (ADTs) stores data and allow
various operations on the data to access and change
it.
 A mathematical model, together with various
operations defined on the model
 An ADT is a collection of data and associated
operations for manipulating that data
 Data Structures
 Physical implementation of an ADT
 data structures used in implementations are provided
in a language (primitive or built-in) or are built from the
language constructs (user-defined)
 Each operation associated with the ADT is implemented
by one or more subroutines in the implementation
Abstract Data Type
 ADTs support abstraction, encapsulation, and
information hiding.
 Abstraction is the structuring of a problem into well-
defined entities by defining their data and
operations.
 The principle of hiding the used data structure and to
only provide a well-defined interface is known as
encapsulation.
Core Operations of ADT
 Every Collection ADT should provide a way to:
 add an item
 remove an item
 find, retrieve, or access an item
 Other possibilities
 is the collection empty
 make the collection empty
 give me a sub set of the collection
• No single data structure works well for all purposes, and
so it is important to know the strengths and limitations
of several of them
19
Analyzing Algorithms
 Predict the amount of resources required:
• memory: how much space is needed?
• computational time: how fast the algorithm runs?
 FACT: running time grows with the size of the
input
 Input size (number of elements in the input)
 Size of an array, polynomial degree, # of elements in
a matrix, # of bits in the binary representation of the
input, vertices and edges in a graph
Def: Running time = the number of primitive
operations (steps) executed before termination
 Arithmetic operations (+, -, *), data movement,
control, decision making (if, while), comparison
22
Algorithm Analysis: Example
 Alg.: MIN (a[1], …, a[n])
m ← a[1];
for i ← 2 to n
if a[i] < m
then m ← a[i];
 Running time:
 the number of primitive operations (steps) executed
before termination
T(n) =1 [first step] + (n) [for loop] + (n-1) [if
condition] +
(n-1) [the assignment in then] = 3n - 1
 Order (rate) of growth:
The leading term of the formula
Expresses the asymptotic behavior of the
algorithm
25
Typical Running Time Functions
 1 (constant running time):
 Instructions are executed once or a few times
 logN (logarithmic)
 A big problem is solved by cutting the original problem in smaller
sizes, by a constant fraction at each step
 N (linear)
 A small amount of processing is done on each input element
 N logN
 A problem is solved by dividing it into smaller problems, solving them
independently and combining the solution
26
Typical Running Time Functions
 N2 (quadratic)
 Typical for algorithms that process all pairs of data items (double
nested loops)
 N3 (cubic)
 Processing of triples of data (triple nested loops)
 NK (polynomial)
 2N (exponential)
 Few exponential algorithms are appropriate for practical use
27
Growth of Functions
Complexity Graphs
log(n)
n
Complexity Graphs
log(n)
n
n
n log(n)
Complexity Graphs
n10
n log(n)
n3
n2
Complexity Graphs (log scale)
n10
n20
nn
1.1n
2n
3n
Algorithm Complexity
 Worst Case Complexity:
 the function defined by the maximum number of steps taken
on any instance of size n
 Best Case Complexity:
 the function defined by the minimum number of steps taken
on any instance of size n
 Average Case Complexity:
 the function defined by the average number of steps taken
on any instance of size n
Best, Worst, and Average Case Complexity
Worst Case
Complexity
Average Case
Complexity
Best Case
Complexity
Number
of steps
N
(input size)
Doing the Analysis
It’s hard to estimate the running time
exactly
Best case depends on the input
Average case is difficult to compute
So we usually focus on worst case analysis
Easier to compute
Usually close to the actual running time
Strategy: find a function (an equation)
that, for large n, is an upper bound to
the actual function (actual number of
steps, memory usage, etc.)
Upper bound
Lower bound
Actual function
Motivation for Asymptotic Analysis
 An exact computation of worst-case running time
can be difficult
 Function may have many terms:
 4n2 - 3n log n + 17.5 n - 43 n⅔ + 75
 An exact computation of worst-case running time
is unnecessary
 Remember that we are already approximating running
time by using RAM model

More Related Content

Similar to Data Structures unit I Introduction - data types

Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresresamplopsurat
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptxOnkarModhave
 
Data clustering using map reduce
Data clustering using map reduceData clustering using map reduce
Data clustering using map reduceVarad Meru
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures BasicsDurgaDeviCbit
 
Data structures and Alogarithims
Data structures and AlogarithimsData structures and Alogarithims
Data structures and AlogarithimsVictor Palmar
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxmexiuro901
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyMalikireddy Bramhananda Reddy
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its FundamentalsHitesh Mohapatra
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptxpoonamsngr
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - IntroductionDeepaThirumurugan
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdNimmi Weeraddana
 
CHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxCHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxOnkarModhave
 
EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxiamultapromax
 

Similar to Data Structures unit I Introduction - data types (20)

Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
 
Data clustering using map reduce
Data clustering using map reduceData clustering using map reduce
Data clustering using map reduce
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures Basics
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Data structures and Alogarithims
Data structures and AlogarithimsData structures and Alogarithims
Data structures and Alogarithims
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
CSE 443 (1).pptx
CSE 443 (1).pptxCSE 443 (1).pptx
CSE 443 (1).pptx
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - Introduction
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
 
CHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxCHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptx
 
EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
 

Recently uploaded

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
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
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
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
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
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
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
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
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 

Recently uploaded (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.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
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
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.
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.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
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
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
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

Data Structures unit I Introduction - data types

  • 1. PROGRAMMING AND DATA STRUCTURES IN C Ms. UMA. S Assistant Professor Computer Science/Computer Applications Thiruvalluvar University College of Arts and Science, Tirupattur
  • 2. OBJECTIVES  Learning program independent view of data structures, including its representation and operations performed on them, which are then linked to sorting, searching and indexing methods to increase the knowledge of usage of data structures in algorithmic perspective.
  • 3.  UNIT-I  Abstract Data Types –  Asymptotic Notations: Big-Oh, Omega and Theta –  Best, Worst and Average case Analysis: Definition and an example –  Arrays and its representations –  Stacks and Queues –  Linked lists –  Linked list based implementation of Stacks and Queues –  Evaluation of Expressions –  Linked list based polynomial addition.
  • 4.  UNIT-II  Trees –  Binary Trees – Binary tree representation and traversals –  Threaded binary trees –  Binary tree representation of trees –  Application of trees: Set representation and Union-  Find operations –  Graph and its representations –  Graph Traversals –  Connected components
  • 5.  UNIT-III  AVL Trees – Red-Black Trees – Splay Trees – Binary Heap – Leftist Heap UNIT–IV  Insertion sort – Merge sort – Quick sort – Heap sort – Sorting with disks – k- way merging – Sorting with tapes – Polyphase merge.  UNIT-V  Linear Search – Binary Search - Hash tables – Overflow handling – Cylinder Surface Indexing – Hash Index – B-Tree Indexing.
  • 6.  TEXT BOOK  1. Ellis Horowitz and Sartaj Sahni, Fundamentals of Data Structures, Galgotia Book Sorce, Gurgaon, 1993.  2. Gregory L. Heilman, Data Structures, Algorithms and Object Oriented Programming, Tata Mcgraw-Hill, New Delhi, 2002.  REFERENCES  1. Jean-Paul Tremblay and Paul G. Sorenson, An Introduction to Data Structures with Applications, Second Edition, Tata McGraw-Hill, New Delhi, 1991.  2. Alfred V. Aho, John E. Hopcroft and Jeffry D. Ullman, Data Structures and Algorithms, Pearson Education, New Delhi, 2006
  • 7. Data Structure  Data structure is a representation of data and the operations allowed on that data.  A data structure is a way to store and organize data in order to facilitate the access and modifications.  Data Structure are the method of representing of logical relationships between individual data elements related to the solution of a given problem.
  • 8. Basic Data Structure Basic Data Structures Linear Data Structures Non-Linear Data Structures Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables
  • 10. Selection of Data Structure  The choice of particular data model depends on two consideration: It must be rich enough in structure to represent the relationship between data elements The structure should be simple enough that one can effectively process the data when necessary
  • 11. Types of Data Structure Linear: In Linear data structure, values are arrange in linear fashion.  Array: Fixed-size  Linked-list: Variable-size  Stack: Add to top and remove from top  Queue: Add to back and remove from front  Priority queue: Add anywhere, remove the highest priority
  • 12. Types of Data Structure  Non-Linear: The data values in this structure are not arranged in order.  Hash tables: Unordered lists which use a ‘hash function’ to insert and search  Tree: Data is organized in branches.  Graph: A more general branching structure, with less strict connection conditions than for a tree
  • 13. Type of Data Structures  Homogenous: In this type of data structures, values of the same types of data are stored.  Array  Non-Homogenous: In this type of data structures, data values of different types are grouped and stored.  Structures  Classes
  • 14. Abstract Data Type and Data Structure  Definition:-  Abstract Data Types (ADTs) stores data and allow various operations on the data to access and change it.  A mathematical model, together with various operations defined on the model  An ADT is a collection of data and associated operations for manipulating that data
  • 15.  Data Structures  Physical implementation of an ADT  data structures used in implementations are provided in a language (primitive or built-in) or are built from the language constructs (user-defined)  Each operation associated with the ADT is implemented by one or more subroutines in the implementation
  • 16. Abstract Data Type  ADTs support abstraction, encapsulation, and information hiding.  Abstraction is the structuring of a problem into well- defined entities by defining their data and operations.  The principle of hiding the used data structure and to only provide a well-defined interface is known as encapsulation.
  • 17. Core Operations of ADT  Every Collection ADT should provide a way to:  add an item  remove an item  find, retrieve, or access an item  Other possibilities  is the collection empty  make the collection empty  give me a sub set of the collection
  • 18. • No single data structure works well for all purposes, and so it is important to know the strengths and limitations of several of them
  • 19. 19 Analyzing Algorithms  Predict the amount of resources required: • memory: how much space is needed? • computational time: how fast the algorithm runs?  FACT: running time grows with the size of the input
  • 20.  Input size (number of elements in the input)  Size of an array, polynomial degree, # of elements in a matrix, # of bits in the binary representation of the input, vertices and edges in a graph
  • 21. Def: Running time = the number of primitive operations (steps) executed before termination  Arithmetic operations (+, -, *), data movement, control, decision making (if, while), comparison
  • 22. 22 Algorithm Analysis: Example  Alg.: MIN (a[1], …, a[n]) m ← a[1]; for i ← 2 to n if a[i] < m then m ← a[i];
  • 23.  Running time:  the number of primitive operations (steps) executed before termination T(n) =1 [first step] + (n) [for loop] + (n-1) [if condition] + (n-1) [the assignment in then] = 3n - 1
  • 24.  Order (rate) of growth: The leading term of the formula Expresses the asymptotic behavior of the algorithm
  • 25. 25 Typical Running Time Functions  1 (constant running time):  Instructions are executed once or a few times  logN (logarithmic)  A big problem is solved by cutting the original problem in smaller sizes, by a constant fraction at each step  N (linear)  A small amount of processing is done on each input element  N logN  A problem is solved by dividing it into smaller problems, solving them independently and combining the solution
  • 26. 26 Typical Running Time Functions  N2 (quadratic)  Typical for algorithms that process all pairs of data items (double nested loops)  N3 (cubic)  Processing of triples of data (triple nested loops)  NK (polynomial)  2N (exponential)  Few exponential algorithms are appropriate for practical use
  • 31. Complexity Graphs (log scale) n10 n20 nn 1.1n 2n 3n
  • 32. Algorithm Complexity  Worst Case Complexity:  the function defined by the maximum number of steps taken on any instance of size n  Best Case Complexity:  the function defined by the minimum number of steps taken on any instance of size n  Average Case Complexity:  the function defined by the average number of steps taken on any instance of size n
  • 33. Best, Worst, and Average Case Complexity Worst Case Complexity Average Case Complexity Best Case Complexity Number of steps N (input size)
  • 34. Doing the Analysis It’s hard to estimate the running time exactly Best case depends on the input Average case is difficult to compute So we usually focus on worst case analysis Easier to compute Usually close to the actual running time
  • 35. Strategy: find a function (an equation) that, for large n, is an upper bound to the actual function (actual number of steps, memory usage, etc.)
  • 37. Motivation for Asymptotic Analysis  An exact computation of worst-case running time can be difficult  Function may have many terms:  4n2 - 3n log n + 17.5 n - 43 n⅔ + 75  An exact computation of worst-case running time is unnecessary  Remember that we are already approximating running time by using RAM model