Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Introduction

Data structures serve as the foundation for Abstract Data Types (ADT), which are the
logical form of data types. The data structure is a collection of data values and their
relationships, as well as data operations and functions. Because of its assistance in organizing,
managing, and storing data in a specific manner, users are capable of altering the data
effectively and easily. It helps to manage large amount of data, such as massive databases.
Efficient algorithms are build based on efficient data structures, it is also responsible for the
efficient retrieval of information from stored memory. It includes: Arrays, Linked Lists, Stacks,
Queues, Graphs, and so on and so forth.

This case study will solely focus on the effectiveness of such search algorithms in data
structures and its methods. Three examples of algorithms are to be explained in detail to
further understand its concepts clearly.

Searching:

Searching in data structure' refers to the process of identifying the needed


information from a set of objects stored in the form of elements in computer memory. These
collections of items can take the form of an array, tree, graph, or linked list. Another way to
define data structure searching is to locate the desired element of specified qualities in a
collection of items.
Body

In a data structure, there are numerous searching algorithms such as linear search,
binary search, interpolation search, jump search, exponential search, Fibonacci search, sublist
search, the ubiquitous binary search, unbounded binary search, recursive function for
substring search, and recursive program to search an element linearly in the given array.
However, in this case study it is only limited to linear search, binary search, and interpolation
search.

Linear Search:

The linear search methods iteratively searches all members of the array. It has a best
execution time of one and a worst execution time of n, where n is the number of elements in
the search array. It is the simplest basic search method in data structure, and it checks each
item in the set of elements until it matches the search element until the data collection is
completed. A linear search algorithm is preferred when the data is unsorted.

Complexities of Linear Search:

There are three complexities faced while performing a linear search algorithm, and
are mentioned as follows.

1.) Best Case


2.) Worst Case
3.) Average Case

Best Case Complexity

• The element being searched could be found in the first position.


• In this case, the search ends with a single successful comparison.
• Thus, in the best-case scenario, the linear search algorithm performs O(1)
operations.

Worst Case Complexity

• The element being searched may be at the last position in the array or not at
all.
• In the first case, the search succeeds in ‘n’ comparisons.
• In the next case, the search fails after ‘n’ comparisons.
• Thus, in the worst-case scenario, the linear search algorithm performs O(n)
operations.

Average Case Scenario

• The element to be searched is in the middle of the array, the average case of
the Linear Search Algorithm is O(n).

Space Complexity of Linear Search Algorithm

• The linear search algorithm takes up no extra space; its space complexity is
O(n) for an array of n elements.

Application

Linear search has several practical applications, for instance:

• Phonebook Search:
• Spell Checkers:
• Finding Minimum and Maximum Values:
• Searching through unsorted data:
Binary search

This algorithm finds specific items by comparing the middlemost items in the data
collection. When a match occurs, it returns the index of the item. When the middle item is
greater than the item, it searches for a central item of the left sub-array. In contrast, if the
middle item is smaller than the search item, it explores the middle of the item in the right
sub-array. It continues searching for an item until it finds it or until the sub-arrays size
becomes zero. Binary search needs sorted order of items. It is faster than a linear search
algorithm. It works on the divide and conquers principle.

Complexities of Binary Search Algorithm

• Worst-case complexity = 0 (n log n)

• Average complexity = 0 (n log n)

• Best case complexity = 0(1)

Application

• Searching in sorted arrays


• Finding closest values
• Spellcheckers and autocorrect
• Game development
Interpolation Search Algorithm

It is an improved variant of the binary search algorithm and works on the search
element’s probing position. Similar to binary search algorithms, it works efficiently only on
sorted data collection, where the values in a sorted array are uniformly distributed.
Interpolation constructs new data points within the range of a discrete set of known data
points. Binary Search always goes to the middle element to check. On the other hand,
interpolation search may go to different locations according to the value of the key being
searched. For example, if the value of the key is closer to the last element, interpolation
search is likely to start search toward the end side.

Conclusion

Three main techniques—interpolation search, binary search, and linear search—have


been examined in order to assess the effectiveness of search algorithms within data
structures. Every algorithm has unique properties that affect which circumstances it is
appropriate for. With a worst-case and average complexity of O(n) and a best-case complexity
of O(1), linear search is simple to use and works well with smaller or unsorted datasets.
However, using a "divide and conquer" approach, binary search, with its best-case complexity
of O(1) and logarithmic worst and average case complexities (O(log n)), performs
exceptionally well when searching through bigger, sorted datasets. Interpolation search
works well with uniformly distributed data, with best and average case complexity of O(1)
and O(log log n), respectively. Its efficacy could, however, be compromised by unequal data
distribution. The decision is complex and dependent on the particulars of the dataset when
assessing the effectiveness of these algorithms. While binary search excels in bigger, sorted
collections, linear search is useful for simplicity and smaller datasets. With its emphasis on
uniformly dispersed data, interpolation search provides benefits in some situations. In order
to achieve the best results in a variety of applications, the study emphasizes how crucial it is
to use the right search algorithm that is suited to the particular needs and data structures at
hand.

You might also like