SEARCHING TECHNIQUES
IN DATA STRUCTURE
Name-Subhrasis Biswal
Regd no.-220301120168
What is searching?
 Searching is a method to locate elements in
a list based on a given value or element.
 The success of a search depends on
whether the item is found or not.
 This operation helps determine the position
of an element within the list.
 The technique aims to identify the existence
and location of the specified value.
Searching Techniques
There are tow types of searching in data
structure
 Linear Search
 Binary Search
Linear Search
 Linear search is a simple algorithm,
sequentially checking items one by one.
 It searches for a match and returns the item
if found.
 If no match, the search continues until the
end of the data collection.
 This method is straightforward but may be
inefficient for large datasets.
Linear Search Algorithm
 Linear Search ( Array A, Value x)
 Step 1: Set i to 1
 Step 2: if i > n then go to step 7
 Step 3: if A[i] = x then go to step 6
 Step 4: Set i to i + 1
 Step 5: Go to Step 2
 Step 6: Print Element x Found at index i and go to
step 8
 Step 7: Print element not found
 Step 8: Exit
Binary search
Searching is a method to locate elements in a
list based on a given value or element.
The success of a search depends on whether
the item is found or not.
This operation helps determine the position of
an element within the list.
 The technique aims to identify the existence
and location of the specified value.
Binary Search Algorithm
 Compare x with the middle element.
 If x matches with middle element, we return
the mid index.
 Else If x is greater than the mid element, then
x can only lie in right half subarray after the
mid element. So we recur for right half.
 Else (x is smaller) recur for the left half.
Binary vs. Linear Search
•Input data needs to be sorted in Binary Search and not in Linear
Search
•Linear search does the sequential access whereas Binary search
access data randomly.
•Time complexity of linear search -O(n) , Binary search has time
complexity O(log n).
•Linear search performs equality comparisons and Binary search
performs ordering comparisons
Thank
you

seaching internal 2 ppt

  • 1.
    SEARCHING TECHNIQUES IN DATASTRUCTURE Name-Subhrasis Biswal Regd no.-220301120168
  • 2.
    What is searching? Searching is a method to locate elements in a list based on a given value or element.  The success of a search depends on whether the item is found or not.  This operation helps determine the position of an element within the list.  The technique aims to identify the existence and location of the specified value.
  • 3.
    Searching Techniques There aretow types of searching in data structure  Linear Search  Binary Search
  • 4.
    Linear Search  Linearsearch is a simple algorithm, sequentially checking items one by one.  It searches for a match and returns the item if found.  If no match, the search continues until the end of the data collection.  This method is straightforward but may be inefficient for large datasets.
  • 5.
    Linear Search Algorithm Linear Search ( Array A, Value x)  Step 1: Set i to 1  Step 2: if i > n then go to step 7  Step 3: if A[i] = x then go to step 6  Step 4: Set i to i + 1  Step 5: Go to Step 2  Step 6: Print Element x Found at index i and go to step 8  Step 7: Print element not found  Step 8: Exit
  • 6.
    Binary search Searching isa method to locate elements in a list based on a given value or element. The success of a search depends on whether the item is found or not. This operation helps determine the position of an element within the list.  The technique aims to identify the existence and location of the specified value.
  • 7.
    Binary Search Algorithm Compare x with the middle element.  If x matches with middle element, we return the mid index.  Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for right half.  Else (x is smaller) recur for the left half.
  • 8.
    Binary vs. LinearSearch •Input data needs to be sorted in Binary Search and not in Linear Search •Linear search does the sequential access whereas Binary search access data randomly. •Time complexity of linear search -O(n) , Binary search has time complexity O(log n). •Linear search performs equality comparisons and Binary search performs ordering comparisons
  • 9.