SlideShare una empresa de Scribd logo
1 de 32
Introduction to Searching techniques and
Matrices

Objectives
In this lesson, you will learn to:
 State the algorithm for linear search
 Perform operations on matrices
 State the applications of matrices
 Implement Recursion




                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 1 of 32
Introduction to Searching techniques and
Matrices

Searching
 Searching is an operation that returns either:
      The location of a given item of information
      A message that the given information is not found
 Searching algorithm depends on the type of data
  structure used to store data
 For example, there can be a data structure with:
      Faster search operation (sorted array)
      Faster modification operation (linked list)



                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 2 of 32
Introduction to Searching techniques and
Matrices

Searching (Contd..)
 There is a trade-off in these data structures
      Sorted array insertion and deletion is time
       consuming
      Linked list traversal is time-consuming
 The different searching techniques are:
      Linear search
      Binary search




                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 3 of 32
Introduction to Searching techniques and
Matrices

Linear Search
 Is the simplest search technique
 In this technique begin at one end and scan until:
      The item is found
      The end of the list is reached
 Benefits:
      Can be used on any data structure
      No restrictions on the way data is arranged




                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 4 of 32
Introduction to Searching techniques and
Matrices

Linear Search (Contd..)
 Drawbacks:
      Performance is dependant on the length of the
       array
      Average number of comparisons 1/2(n+1)
      Even if required data is not present the complete
       array is searched




                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                              4/Slide 5 of 32
Introduction to Searching techniques and
Matrices

Binary Search
 Binary search technique is faster than linear search
  technique
 After every search the number of items to be
  searched is reduced by half
 In this search technique:
      Start by comparing the middle element




                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                              4/Slide 6 of 32
Introduction to Searching techniques and
Matrices

Binary Search (Contd..)
 Then the next quarter and so on until
      The required item is found
      No more data is left for searching
 Benefits:
      Faster search
      After each step number of items to be searched
       reduces by half
      More efficient for searching large volume of data



                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 7 of 32
Introduction to Searching techniques and
Matrices

Binary Search (Contd..)
 Average number of comparisons for 1 million items is
  only 20
 Drawbacks:
      Data has to be sorted
      Cannot be used on all data structures




                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                              4/Slide 8 of 32
Introduction to Searching techniques and
Matrices

Problem Statement 4.D.1
 Write a program to accept 20 numbers and store it in
  an array. Now accept a number and search it in an
  array, make sure that, before searching a number you
  perform bubble sort it in.
   Note: Implement using arrays




                  Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 9 of 32
Introduction to Searching techniques and
Matrices

Just A Minute
 In a sorted array insertion and deletion are less time
  consuming than searching.(True/False)
 In a binary tree searching is more time consuming than
  linked list ( True/False)




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 10 of 32
Introduction to Searching techniques and
Matrices

Matrices
A rectangular arrangement of rows and columns is a
matrix
                                      COLUMNS




                A            B           C           D
                      E           F           G           H


         ROWS
                E            F           G           H
                      I           J           K           L



                I            J           K           L




                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                             4/Slide 11 of 32
Introduction to Searching techniques and
Matrices

Matrices (Contd..)
 The size of the matrix is called the dimensions of the
  matrix
 The sum of rows and columns of a matrix identify the
  size
 Each number in a matrix is called an element




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 12 of 32
Introduction to Searching techniques and
Matrices

Matrices (Contd..)
 A matrix with the same number of rows and columns
  is called a square matrix



                 A         B         C
                      E         F


                 E         F         G
                      I         J


                 I         J         K




                 Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                          4/Slide 13 of 32
Introduction to Searching techniques and
Matrices

Matrices (Contd..)


               A   X                    D


               X             Z
                                  D

                       Z

                                             E


 The above figure shows another type of matrix that is,
  a sparse matrix
 A matrix with lot of blank elements is called a sparse
  matrix

                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 14 of 32
Introduction to Searching techniques and
Matrices

Operations on Matrices
 The basic operations on a matrix can be listed as:
      Create
      Store
      Delete
      Retrieve




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 15 of 32
Introduction to Searching techniques and
Matrices

Multi-dimensional Matrix


                  4 Pages




         2 Rows




                            3 Columns



 The syntax for declaring a three-dimensional matrix is
  same as that of two-dimensional array


                             Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                                      4/Slide 16 of 32
Introduction to Searching techniques and
Matrices

Multi-dimensional Matrix (Contd..)
 Example:
      int Newone[2][3][4];
      The array Newone[2][3][4] contains 2*3*4=24
       elements
 The subscripts of the array are called:
      row
      column
      page



                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                              4/Slide 17 of 32
Introduction to Searching techniques and
Matrices

Multi-dimensional Matrix (Contd..)
 In this array, we can store 8 different set of details.
 Sum of row and page gives the number of different
  sets of information that can be stored
 Example: 4*2 = 8 for the array Newone




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 18 of 32
Introduction to Searching techniques and
Matrices

Applications
 Matrices can be applied in:
   Finding the shortest route
      Map coloring
      Search engines for the WEB when combined with
       queues and hash tables




                      Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 19 of 32
Introduction to Searching techniques and
Matrices

Problem Statement 4.D.2
Write a program to store the details of a student
( Student name, Registration number, and the Subject
marks) in a three-dimensional array. Also, give an option
to the user to query and print the details for a specific
student requested by the user by entering the
registration number of the student. Accept the student
data from the user?




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 20 of 32
Introduction to Searching techniques and
Matrices

Recursion
 Whenever a function invokes itself, it is called
  recursion.
 Every time a recursive function calls itself, it must call
  itself with different values.
 A recursive procedure or function must satisfy the
  following two conditions:
      There must be certain values called base values
       for which the function will not call back itself.
      Each time the function refers to itself, the
       arguments passed must be closer to its base
       value.
 It is useful in writing clear, short, and simple programs
                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                             4/Slide 21 of 32
Introduction to Searching techniques and
Matrices

Practice Statement 4.P.1
 Identify the erroneous step(s) in the following Table
  A.2

         Step 1               0!=1

         Step 2               1! =1*1=1

         Step 3               2!=2*1=2

         Step 4               3! =3x2 =6




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 22 of 32
Introduction to Searching techniques and
Matrices

Just a Minute…
 The factorial() function will repeatedly invoke itself until
  the parameter passed to it is _____.
 When the above function is invoked with a parameter of
  5, the factorial() function is invoked ____ times in all.
 State whether True or False.
   With large values (say,100) of the parameter passed to
   the factorial() function, there is a danger of the program
   crashing.




                      Introduction to Searching techniques and Matrices/Lesson
  ©NIIT
                                                               4/Slide 23 of 32
Introduction to Searching techniques and
Matrices

Summary
In this lesson, you learned that:
 Information retrieval is one of the most important
  applications of computers
 Searching is an operation, which:
        Returns the location in memory of some given
     item of information




                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                             4/Slide 24 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 The search algorithm depends mainly on the type of
  data structure we use to store the data in memory
 In a sorted array the search time can be greatly
  reduced by using a search technique called binary
  search
 In sorted array, there is an overhead-involved that is,
  insertion and deletion of data is a time-consuming
  process




                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 25 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 In a linked List:
      Search time will be high
      Only sequential search is possible
      Insertion and deletion will be fast
 Binary Tree combines the advantage of sorted array
  and a linked list




                      Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 26 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 Linear search is also referred to as sequential search
  is the simplest search technique
 In Linear Search, to search an item begin at one end
  of the list and scan down the list until:
          The desired item is found
          The end of the list is reached




                       Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                                4/Slide 27 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 The average number of comparison for a linear
  search can be worked out by applying the formula
  1/2(n+1)
 Linear search technique has some drawbacks:
      Even if there is no match for the item in the list, the
       complete list is searched
      The search time is directly proportional to the
       length of the list




                      Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 28 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 Binary search is faster than linear search technique
 In Binary Search, to search an item begin at the
  middle of the list and scan one half of the list , then
  the quarter and so on until:
      the desired item is found or
      there is no more data to search
 In a binary search, after every comparison, the data to
  be searched reduces by half.




                     Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                              4/Slide 29 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 The drawbacks of binary search are:
      The list has to be sorted
      There should be a method to access the middle
       element of the list
 A rectangular arrangement of rows and columns is
  called a matrix
 A matrix with the same number of rows and columns
  is called a square matrix
 A matrix with a lot of zero or unused elements is
  generally called a sparse matrix

                    Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                             4/Slide 30 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
The basic operations on a matrix can be listed as:
      Create
      Store
      Delete
      Retrieve
The subscripts of a three-dimensional array are called:
      Row
      Column
      Page
                   Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                            4/Slide 31 of 32
Introduction to Searching techniques and
Matrices

Summary (Contd..)
 Matrices can be applied for:
      Finding a shortest route
      Map coloring
 Recursion can be defined as defining something in
  terms of itself. A function is recursive if it makes a call
  to itself, i.e. invokes itself.
 Advantage of recursion is that it is useful in writing
  clear, short, and simple programs.




                      Introduction to Searching techniques and Matrices/Lesson
 ©NIIT
                                                               4/Slide 32 of 32

Más contenido relacionado

Destacado

National Air And Space Museum Washington DC
National Air And Space Museum Washington DCNational Air And Space Museum Washington DC
National Air And Space Museum Washington DCShivakumar Patil
 
Dc parent 14 2
Dc parent 14 2Dc parent 14 2
Dc parent 14 2mtaft
 
Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Andreas Jaffke
 
Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Saba SEO
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
Ancient Ideas of Creation & Evolution
Ancient Ideas of Creation & EvolutionAncient Ideas of Creation & Evolution
Ancient Ideas of Creation & EvolutionJohn Lynch
 
History of Creationism, Parts II & III
History of Creationism, Parts II & IIIHistory of Creationism, Parts II & III
History of Creationism, Parts II & IIIJohn Lynch
 
The Chemical Revolution
The Chemical RevolutionThe Chemical Revolution
The Chemical RevolutionJohn Lynch
 
The Scientific Revolution
The Scientific RevolutionThe Scientific Revolution
The Scientific RevolutionJohn Lynch
 
Why Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceWhy Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceJohn Lynch
 
Introduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bIntroduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bShahi Raz Akhtar
 
Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"John Lynch
 

Destacado (20)

National Air And Space Museum Washington DC
National Air And Space Museum Washington DCNational Air And Space Museum Washington DC
National Air And Space Museum Washington DC
 
Dc parent 14 2
Dc parent 14 2Dc parent 14 2
Dc parent 14 2
 
Google at a glance 1998 - 2008
Google at a glance 1998 - 2008Google at a glance 1998 - 2008
Google at a glance 1998 - 2008
 
Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.Google Algorithm Change History - 2k14-2k16.
Google Algorithm Change History - 2k14-2k16.
 
Google
GoogleGoogle
Google
 
simple-sorting algorithms
simple-sorting algorithmssimple-sorting algorithms
simple-sorting algorithms
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Ancient Ideas of Creation & Evolution
Ancient Ideas of Creation & EvolutionAncient Ideas of Creation & Evolution
Ancient Ideas of Creation & Evolution
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
 
sPen Data Management
sPen Data ManagementsPen Data Management
sPen Data Management
 
Sorting pnk
Sorting pnkSorting pnk
Sorting pnk
 
How We Got Where We Are: 40 Years of Planning...
How We Got Where We Are: 40 Years of Planning...How We Got Where We Are: 40 Years of Planning...
How We Got Where We Are: 40 Years of Planning...
 
History of Creationism, Parts II & III
History of Creationism, Parts II & IIIHistory of Creationism, Parts II & III
History of Creationism, Parts II & III
 
The Chemical Revolution
The Chemical RevolutionThe Chemical Revolution
The Chemical Revolution
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
The Scientific Revolution
The Scientific RevolutionThe Scientific Revolution
The Scientific Revolution
 
Why Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & ScienceWhy Ben Stein Is Wrong About History & Science
Why Ben Stein Is Wrong About History & Science
 
CSS 3, Style and Beyond
CSS 3, Style and BeyondCSS 3, Style and Beyond
CSS 3, Style and Beyond
 
Introduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_bIntroduction to Information Technology ch 01_b
Introduction to Information Technology ch 01_b
 
Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"Introduction to "Origins, Evolution & Creation"
Introduction to "Origins, Evolution & Creation"
 

Similar a Ds 4

From data mining to knowledge discovery in
From data mining to knowledge discovery inFrom data mining to knowledge discovery in
From data mining to knowledge discovery inRaj Kumar Ranabhat
 
Efficient Temporal Association Rule Mining
Efficient Temporal Association Rule MiningEfficient Temporal Association Rule Mining
Efficient Temporal Association Rule MiningIJMER
 
Classification Techniques: A Review
Classification Techniques: A ReviewClassification Techniques: A Review
Classification Techniques: A ReviewIOSRjournaljce
 
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351IRJET Journal
 
Study of Density Based Clustering Techniques on Data Streams
Study of Density Based Clustering Techniques on Data StreamsStudy of Density Based Clustering Techniques on Data Streams
Study of Density Based Clustering Techniques on Data StreamsIJERA Editor
 
A classification of methods for frequent pattern mining
A classification of methods for frequent pattern miningA classification of methods for frequent pattern mining
A classification of methods for frequent pattern miningIOSR Journals
 
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...theijes
 
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEY
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEYCLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEY
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEYEditor IJMTER
 
BI Chapter 04.pdf business business business business
BI Chapter 04.pdf business business business businessBI Chapter 04.pdf business business business business
BI Chapter 04.pdf business business business businessJawaherAlbaddawi
 

Similar a Ds 4 (20)

Ds 7
Ds 7Ds 7
Ds 7
 
Ijetcas14 338
Ijetcas14 338Ijetcas14 338
Ijetcas14 338
 
Ds 1
Ds 1Ds 1
Ds 1
 
From data mining to knowledge discovery in
From data mining to knowledge discovery inFrom data mining to knowledge discovery in
From data mining to knowledge discovery in
 
Efficient Temporal Association Rule Mining
Efficient Temporal Association Rule MiningEfficient Temporal Association Rule Mining
Efficient Temporal Association Rule Mining
 
Efficient Temporal Association Rule Mining
Efficient Temporal Association Rule MiningEfficient Temporal Association Rule Mining
Efficient Temporal Association Rule Mining
 
A04010105
A04010105A04010105
A04010105
 
Classification Techniques: A Review
Classification Techniques: A ReviewClassification Techniques: A Review
Classification Techniques: A Review
 
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351
Irjet v4 iA Survey on FP (Growth) Tree using Association Rule Mining7351
 
COMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERING
COMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERINGCOMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERING
COMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERING
 
E502024047
E502024047E502024047
E502024047
 
E502024047
E502024047E502024047
E502024047
 
Study of Density Based Clustering Techniques on Data Streams
Study of Density Based Clustering Techniques on Data StreamsStudy of Density Based Clustering Techniques on Data Streams
Study of Density Based Clustering Techniques on Data Streams
 
Ay4201347349
Ay4201347349Ay4201347349
Ay4201347349
 
J017114852
J017114852J017114852
J017114852
 
A classification of methods for frequent pattern mining
A classification of methods for frequent pattern miningA classification of methods for frequent pattern mining
A classification of methods for frequent pattern mining
 
G045033841
G045033841G045033841
G045033841
 
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...
Applying K-Means Clustering Algorithm to Discover Knowledge from Insurance Da...
 
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEY
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEYCLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEY
CLASSIFICATION ALGORITHM USING RANDOM CONCEPT ON A VERY LARGE DATA SET: A SURVEY
 
BI Chapter 04.pdf business business business business
BI Chapter 04.pdf business business business businessBI Chapter 04.pdf business business business business
BI Chapter 04.pdf business business business business
 

Más de Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Último

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Ds 4

  • 1. Introduction to Searching techniques and Matrices Objectives In this lesson, you will learn to: State the algorithm for linear search Perform operations on matrices State the applications of matrices Implement Recursion Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 1 of 32
  • 2. Introduction to Searching techniques and Matrices Searching Searching is an operation that returns either: The location of a given item of information A message that the given information is not found Searching algorithm depends on the type of data structure used to store data For example, there can be a data structure with: Faster search operation (sorted array) Faster modification operation (linked list) Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 2 of 32
  • 3. Introduction to Searching techniques and Matrices Searching (Contd..) There is a trade-off in these data structures Sorted array insertion and deletion is time consuming Linked list traversal is time-consuming The different searching techniques are: Linear search Binary search Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 3 of 32
  • 4. Introduction to Searching techniques and Matrices Linear Search Is the simplest search technique In this technique begin at one end and scan until: The item is found The end of the list is reached Benefits: Can be used on any data structure No restrictions on the way data is arranged Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 4 of 32
  • 5. Introduction to Searching techniques and Matrices Linear Search (Contd..) Drawbacks: Performance is dependant on the length of the array Average number of comparisons 1/2(n+1) Even if required data is not present the complete array is searched Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 5 of 32
  • 6. Introduction to Searching techniques and Matrices Binary Search Binary search technique is faster than linear search technique After every search the number of items to be searched is reduced by half In this search technique: Start by comparing the middle element Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 6 of 32
  • 7. Introduction to Searching techniques and Matrices Binary Search (Contd..) Then the next quarter and so on until The required item is found No more data is left for searching Benefits: Faster search After each step number of items to be searched reduces by half More efficient for searching large volume of data Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 7 of 32
  • 8. Introduction to Searching techniques and Matrices Binary Search (Contd..) Average number of comparisons for 1 million items is only 20 Drawbacks: Data has to be sorted Cannot be used on all data structures Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 8 of 32
  • 9. Introduction to Searching techniques and Matrices Problem Statement 4.D.1 Write a program to accept 20 numbers and store it in an array. Now accept a number and search it in an array, make sure that, before searching a number you perform bubble sort it in. Note: Implement using arrays Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 9 of 32
  • 10. Introduction to Searching techniques and Matrices Just A Minute In a sorted array insertion and deletion are less time consuming than searching.(True/False) In a binary tree searching is more time consuming than linked list ( True/False) Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 10 of 32
  • 11. Introduction to Searching techniques and Matrices Matrices A rectangular arrangement of rows and columns is a matrix COLUMNS A B C D E F G H ROWS E F G H I J K L I J K L Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 11 of 32
  • 12. Introduction to Searching techniques and Matrices Matrices (Contd..) The size of the matrix is called the dimensions of the matrix The sum of rows and columns of a matrix identify the size Each number in a matrix is called an element Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 12 of 32
  • 13. Introduction to Searching techniques and Matrices Matrices (Contd..) A matrix with the same number of rows and columns is called a square matrix A B C E F E F G I J I J K Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 13 of 32
  • 14. Introduction to Searching techniques and Matrices Matrices (Contd..) A X D X Z D Z E The above figure shows another type of matrix that is, a sparse matrix A matrix with lot of blank elements is called a sparse matrix Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 14 of 32
  • 15. Introduction to Searching techniques and Matrices Operations on Matrices The basic operations on a matrix can be listed as: Create Store Delete Retrieve Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 15 of 32
  • 16. Introduction to Searching techniques and Matrices Multi-dimensional Matrix 4 Pages 2 Rows 3 Columns The syntax for declaring a three-dimensional matrix is same as that of two-dimensional array Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 16 of 32
  • 17. Introduction to Searching techniques and Matrices Multi-dimensional Matrix (Contd..) Example: int Newone[2][3][4]; The array Newone[2][3][4] contains 2*3*4=24 elements The subscripts of the array are called: row column page Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 17 of 32
  • 18. Introduction to Searching techniques and Matrices Multi-dimensional Matrix (Contd..) In this array, we can store 8 different set of details. Sum of row and page gives the number of different sets of information that can be stored Example: 4*2 = 8 for the array Newone Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 18 of 32
  • 19. Introduction to Searching techniques and Matrices Applications Matrices can be applied in: Finding the shortest route Map coloring Search engines for the WEB when combined with queues and hash tables Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 19 of 32
  • 20. Introduction to Searching techniques and Matrices Problem Statement 4.D.2 Write a program to store the details of a student ( Student name, Registration number, and the Subject marks) in a three-dimensional array. Also, give an option to the user to query and print the details for a specific student requested by the user by entering the registration number of the student. Accept the student data from the user? Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 20 of 32
  • 21. Introduction to Searching techniques and Matrices Recursion Whenever a function invokes itself, it is called recursion. Every time a recursive function calls itself, it must call itself with different values. A recursive procedure or function must satisfy the following two conditions: There must be certain values called base values for which the function will not call back itself. Each time the function refers to itself, the arguments passed must be closer to its base value. It is useful in writing clear, short, and simple programs Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 21 of 32
  • 22. Introduction to Searching techniques and Matrices Practice Statement 4.P.1 Identify the erroneous step(s) in the following Table A.2 Step 1 0!=1 Step 2 1! =1*1=1 Step 3 2!=2*1=2 Step 4 3! =3x2 =6 Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 22 of 32
  • 23. Introduction to Searching techniques and Matrices Just a Minute… The factorial() function will repeatedly invoke itself until the parameter passed to it is _____. When the above function is invoked with a parameter of 5, the factorial() function is invoked ____ times in all. State whether True or False. With large values (say,100) of the parameter passed to the factorial() function, there is a danger of the program crashing. Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 23 of 32
  • 24. Introduction to Searching techniques and Matrices Summary In this lesson, you learned that: Information retrieval is one of the most important applications of computers Searching is an operation, which: Returns the location in memory of some given item of information Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 24 of 32
  • 25. Introduction to Searching techniques and Matrices Summary (Contd..) The search algorithm depends mainly on the type of data structure we use to store the data in memory In a sorted array the search time can be greatly reduced by using a search technique called binary search In sorted array, there is an overhead-involved that is, insertion and deletion of data is a time-consuming process Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 25 of 32
  • 26. Introduction to Searching techniques and Matrices Summary (Contd..) In a linked List: Search time will be high Only sequential search is possible Insertion and deletion will be fast Binary Tree combines the advantage of sorted array and a linked list Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 26 of 32
  • 27. Introduction to Searching techniques and Matrices Summary (Contd..) Linear search is also referred to as sequential search is the simplest search technique In Linear Search, to search an item begin at one end of the list and scan down the list until: The desired item is found The end of the list is reached Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 27 of 32
  • 28. Introduction to Searching techniques and Matrices Summary (Contd..) The average number of comparison for a linear search can be worked out by applying the formula 1/2(n+1) Linear search technique has some drawbacks: Even if there is no match for the item in the list, the complete list is searched The search time is directly proportional to the length of the list Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 28 of 32
  • 29. Introduction to Searching techniques and Matrices Summary (Contd..) Binary search is faster than linear search technique In Binary Search, to search an item begin at the middle of the list and scan one half of the list , then the quarter and so on until: the desired item is found or there is no more data to search In a binary search, after every comparison, the data to be searched reduces by half. Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 29 of 32
  • 30. Introduction to Searching techniques and Matrices Summary (Contd..) The drawbacks of binary search are: The list has to be sorted There should be a method to access the middle element of the list A rectangular arrangement of rows and columns is called a matrix A matrix with the same number of rows and columns is called a square matrix A matrix with a lot of zero or unused elements is generally called a sparse matrix Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 30 of 32
  • 31. Introduction to Searching techniques and Matrices Summary (Contd..) The basic operations on a matrix can be listed as: Create Store Delete Retrieve The subscripts of a three-dimensional array are called: Row Column Page Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 31 of 32
  • 32. Introduction to Searching techniques and Matrices Summary (Contd..) Matrices can be applied for: Finding a shortest route Map coloring Recursion can be defined as defining something in terms of itself. A function is recursive if it makes a call to itself, i.e. invokes itself. Advantage of recursion is that it is useful in writing clear, short, and simple programs. Introduction to Searching techniques and Matrices/Lesson ©NIIT 4/Slide 32 of 32