SlideShare a Scribd company logo
1 of 25
Download to read offline
Data Structure and
Algorithm
COC2060
- Nadeem Akhtar
Course Objective
To introduce the concept of data structures including arrays, linked lists,
stacks, queues, binary trees, heaps, binary search trees, and graphs etc.,
and apply these data structures in problem solving.
To introduce applications of various data structures and its use in a manner
that adds to the efficiency of an algorithm in writing effective programs.
Course Outcome
After completion of this course, you will be able to
1. Learn how the choice of data structures and algorithm design methods
impact the performance of programs.
2. Analyze the importance and use of Abstract Data Types (ADTs)
3. Design and implement elementary Data Structures such as arrays, trees,
Stacks, Queues, and Hash Tables.
4. Identify algorithms as a pseudo-code to solve some common problems.
5. Explain best, average, and worst-cases of an algorithm using Big-O notation.
Recommended Books
Seymour Lipschutz, Data Structures, TMH
Aaron M. Tenenbaum, Langsam, Data structures using C, Pearson, 2008
Datastructures and
Algorithms
5
1/9/2
022 What is a Computer Program?
To exactly know, what is data structure? We must know:
What is a computer program?
Input
processing
Output
Data
Data is plural of datum- a piece of information
Data are values or a set of values
Data item refers to single unit of values
Data item
Group item :
Data item that can be subdivided into sub item.
Ex Name : First Name, Middle initial and Last Name
Elementary item:
Data item that can not be sub divided into sub item
Ex : PAN card number / Bank Pass Book Number is treated as single item
Elementary Data Organization
Collection of data are frequently organized into a hierarchy of fields,
records and files
Entity :
Something that has certain attributes or properties which may be assigned values
Values may be numeric or non-numeric
Ex: The employee of an organization
Attributes Name Age Sex Employee Code
Values John 33 M 13472
Elementary Data Organization
Entity with similar attributes ( e.g all employees of an organization) form an entity
set
Each attribute of an entity set has a range of values [ the set of possible values
that could be assigned to the particular attribute]
Information: Data with given attribute or processed data
Field is a single elementary unit of information representing an attribute of an
entity
Record is the collection of field values of a given entity
Fixed Length
Variable Length
File is the collection of records of the entities in a given entity set
Example
Issues in Data Structures
Study of Data Structure includes the following three steps
Logical or Mathematical description of the structure of data
Implementation of the structure on a computer
Quantitative analysis of the structure, which includes determining the amount of
memory needed to store the structure and the time required to process the
structure
Second and third step depends on whether data is stored in main memory
or secondary storage
In this course, we are concerned only with data stored in main memory
Data Structure
Data Structure
The logical or mathematical model of a particular organization of data
Choice of a model depends on two factor
It must be rich enough in structure to mirror the actual relationships of the data in
the real world
The structure should be simple enough that one can effectively process the data
when necessary
A data structure is a way to logically organize data that specifies:
A set of data elements i.e., a data object and
A set of operations which may legally be applied to elements of this data object.
Operations
Operations:
Data appearing in DS are processed by means of certain operation
A particular DS, one chooses for a given situation depends largely on the frequency
with which specific operations are performed
Main operations
Traversal
Search
Insertion
Deletion
Sort
Issues
Space needed
Operations efficiency (Time required to complete
operations)
Categorization
Datastructures and
Algorithms
14
1/9/2
022 Pictorial Representation
array
Linked list
tree
queue
stack
Algorithms
A list of well defined instructions for solving a particular
problem
High level and language independent instructions
Each instruction must be clear
Finite number of instructions
There may be many algorithms for solving a problem
Good Algorithm: Efficient Algorithm
Time
Space
Time-space trade-off
Each algorithm involve a particular data structure
Choice of data structure effect the efficiency of
algorithm
Time-space trade-off
Increasing the amount of space may reduce time
need and vice versa
Example: Search Algorithms
Suppose we have a file containing information about
employees
Name, Age, Sex, Telephone Number, Address
We are given name of an employee and want to search
for his/her Telephone number
Linear Search
Traverse the file linearly starting from the first record
Number of comparisons is equal to (n+1)/2
What if file is very large
Binary Search
Binary search can be used if names are sorted
alphabetically
General Idea of binary search
Compare given name with the name in the middle of list
Tells which half of the list contains given name
Repeat this process until given name is found
Number of comparisons is log2
n
Number of comparisons in Binary
Search
Number of comparisons in Binary
Search
For array of 15 elements, Number of comparisons is
Binary Search
Very efficient than linear search
Drawbacks
Sorted list
Direct access to middle element
insertion and deletion in sorted array is difficult
Example 1: time space trade-off
Example 1: time space trade-off
Example 1: time space trade-off
Example 2: time space trade-off
Roll No Name
55 Clark
712 Hill
3 Drew
124 White
943 Brown
345 Adams
231 Bill
Roll No can be used as address
No movement od data in insertion and deletion
Instant access to any record
Mostly empty locations- memory is allocated for non-existing records
Efficient Method: Hashing
A hash function H transform a key value K into address L

More Related Content

Similar to 1- Introduction.pptx.pdf

Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)MUHAMMAD AAMIR
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptxpoonamsngr
 
Module03
Module03Module03
Module03susir
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its FundamentalsHitesh Mohapatra
 
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARIntroduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARBHARATH KUMAR
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2RajSingh734307
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptiamsallauddin
 
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
 
Business Analytics Project Example
Business Analytics Project ExampleBusiness Analytics Project Example
Business Analytics Project ExampleMBA Capstone Project
 
Computer Data Processing And Representation 4
Computer Data Processing And Representation   4Computer Data Processing And Representation   4
Computer Data Processing And Representation 4Amit Chandra
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxAmrutaNavale2
 

Similar to 1- Introduction.pptx.pdf (20)

Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
Module03
Module03Module03
Module03
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
Data structure
Data structureData structure
Data structure
 
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARIntroduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
 
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
 
Business Analytics Project Example
Business Analytics Project ExampleBusiness Analytics Project Example
Business Analytics Project Example
 
Dsa unit 1
Dsa unit 1Dsa unit 1
Dsa unit 1
 
Computer Data Processing And Representation 4
Computer Data Processing And Representation   4Computer Data Processing And Representation   4
Computer Data Processing And Representation 4
 
Ch1
Ch1Ch1
Ch1
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
 

Recently uploaded

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

1- Introduction.pptx.pdf

  • 2. Course Objective To introduce the concept of data structures including arrays, linked lists, stacks, queues, binary trees, heaps, binary search trees, and graphs etc., and apply these data structures in problem solving. To introduce applications of various data structures and its use in a manner that adds to the efficiency of an algorithm in writing effective programs.
  • 3. Course Outcome After completion of this course, you will be able to 1. Learn how the choice of data structures and algorithm design methods impact the performance of programs. 2. Analyze the importance and use of Abstract Data Types (ADTs) 3. Design and implement elementary Data Structures such as arrays, trees, Stacks, Queues, and Hash Tables. 4. Identify algorithms as a pseudo-code to solve some common problems. 5. Explain best, average, and worst-cases of an algorithm using Big-O notation.
  • 4. Recommended Books Seymour Lipschutz, Data Structures, TMH Aaron M. Tenenbaum, Langsam, Data structures using C, Pearson, 2008
  • 5. Datastructures and Algorithms 5 1/9/2 022 What is a Computer Program? To exactly know, what is data structure? We must know: What is a computer program? Input processing Output
  • 6. Data Data is plural of datum- a piece of information Data are values or a set of values Data item refers to single unit of values Data item Group item : Data item that can be subdivided into sub item. Ex Name : First Name, Middle initial and Last Name Elementary item: Data item that can not be sub divided into sub item Ex : PAN card number / Bank Pass Book Number is treated as single item
  • 7. Elementary Data Organization Collection of data are frequently organized into a hierarchy of fields, records and files Entity : Something that has certain attributes or properties which may be assigned values Values may be numeric or non-numeric Ex: The employee of an organization Attributes Name Age Sex Employee Code Values John 33 M 13472
  • 8. Elementary Data Organization Entity with similar attributes ( e.g all employees of an organization) form an entity set Each attribute of an entity set has a range of values [ the set of possible values that could be assigned to the particular attribute] Information: Data with given attribute or processed data Field is a single elementary unit of information representing an attribute of an entity Record is the collection of field values of a given entity Fixed Length Variable Length File is the collection of records of the entities in a given entity set
  • 10. Issues in Data Structures Study of Data Structure includes the following three steps Logical or Mathematical description of the structure of data Implementation of the structure on a computer Quantitative analysis of the structure, which includes determining the amount of memory needed to store the structure and the time required to process the structure Second and third step depends on whether data is stored in main memory or secondary storage In this course, we are concerned only with data stored in main memory
  • 11. Data Structure Data Structure The logical or mathematical model of a particular organization of data Choice of a model depends on two factor It must be rich enough in structure to mirror the actual relationships of the data in the real world The structure should be simple enough that one can effectively process the data when necessary A data structure is a way to logically organize data that specifies: A set of data elements i.e., a data object and A set of operations which may legally be applied to elements of this data object.
  • 12. Operations Operations: Data appearing in DS are processed by means of certain operation A particular DS, one chooses for a given situation depends largely on the frequency with which specific operations are performed Main operations Traversal Search Insertion Deletion Sort Issues Space needed Operations efficiency (Time required to complete operations)
  • 14. Datastructures and Algorithms 14 1/9/2 022 Pictorial Representation array Linked list tree queue stack
  • 15. Algorithms A list of well defined instructions for solving a particular problem High level and language independent instructions Each instruction must be clear Finite number of instructions There may be many algorithms for solving a problem Good Algorithm: Efficient Algorithm Time Space
  • 16. Time-space trade-off Each algorithm involve a particular data structure Choice of data structure effect the efficiency of algorithm Time-space trade-off Increasing the amount of space may reduce time need and vice versa
  • 17. Example: Search Algorithms Suppose we have a file containing information about employees Name, Age, Sex, Telephone Number, Address We are given name of an employee and want to search for his/her Telephone number Linear Search Traverse the file linearly starting from the first record Number of comparisons is equal to (n+1)/2 What if file is very large
  • 18. Binary Search Binary search can be used if names are sorted alphabetically General Idea of binary search Compare given name with the name in the middle of list Tells which half of the list contains given name Repeat this process until given name is found Number of comparisons is log2 n
  • 19. Number of comparisons in Binary Search
  • 20. Number of comparisons in Binary Search For array of 15 elements, Number of comparisons is
  • 21. Binary Search Very efficient than linear search Drawbacks Sorted list Direct access to middle element insertion and deletion in sorted array is difficult
  • 22. Example 1: time space trade-off
  • 23. Example 1: time space trade-off
  • 24. Example 1: time space trade-off
  • 25. Example 2: time space trade-off Roll No Name 55 Clark 712 Hill 3 Drew 124 White 943 Brown 345 Adams 231 Bill Roll No can be used as address No movement od data in insertion and deletion Instant access to any record Mostly empty locations- memory is allocated for non-existing records Efficient Method: Hashing A hash function H transform a key value K into address L