Академический Документы
Профессиональный Документы
Культура Документы
Abstract— Finding data in a in sequence with what is searched until the data
document is not an easy task. Searching is a is found or not found, Binary Search is one of the
method of finding data in an application, with search methods that handle the worst case (worst
a key. A search is needed to search for specific case) on sequential search. The binary search
data from a document when the exact location process can only be performed on data that has
of the data was previously unknown. There already been sequenced. The binary search
are many searching algorithms that have been method is to divide the two elements of the value
introduced, two of which are Sequential container and compare the values. [1] With the
Search and Binary Search. This research aims same goal, a comparison of Sequential Search
to compare the quality between Sequrential and Binary Search can be done in finding a more
Search and Binary Search. The researcher suitable method. The comparison results
compares these two algorithms using the obtained are expected to help to determine the
comparative method. Here the researchers right method and in accordance with the need to
use the data in the form of arrays as follows: overcome the problem in finding data.
1, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12. In the case of The method used is a comparative
finding data number 7 from the data array method. The comparative method is a method
above, Binary Search is faster than Sequential that aims to distinguish or compare. This method
Search. The Sequential Search algorithm is is carried out in order to compare between two or
simpler and the data does not need to be more facts or properties of the object under study
sorted. But Sequential Search is very based on a particular thought. This comparative
inefficient when used with more data. method is "expost facto", which means data
Whereas Binary Search requires us to sort the collected after the event in question occurs. This
data first. But Binary Search is more efficient comparative method tends to use quantitative
than Sequential Search when using lots of data. [2]
data.
II Method
A. Research Design
I Introduction
The design used in this research is to use
Finding data in a document is not an
a comparative method of comparing Sequential
easy task. Searching is a method of finding data
Search and Binary Search algorithms, with the
in an application, with a key. A search is needed
aim to see the statistical results of each algorithm,
to search for specific data from a document when
and find which algorithm is better between the
the exact location of the data was previously
two.
unknown.
B. Method
Algorithms are fundamental to
The method used in this research is to
computers processing information. As
use a comparative method that compares the java
Thompson Susabda Ngoen said, the algorithm is
script data search algorithm in the form of integer
a computational step that converts inputs into
data including:
correct outputs.
1. Sequential Search
There are many searching algorithms
2. Binary Search
that have been introduced, two of which are
In comparing the two algorithms, based
Sequential Search and Binary Search. Sequential
on the level of speed or in the form of the length
search is a data search technique in arrays that
of time used to perform the algorithm and the
will trace all elements of the array from
sequence of data in the form of ascending or
beginning to end, where the data does not need to
descending sequential data.
be sorted first. Sequential search uses the
following principle: Data is compared one by one
The stages of the process undertaken to return arr[mid];
use this method are as follows: } else if (arr[mid] < i && arr.length > 1) {
1. Prepare an integer data in the form console.log('mid lower', arr[mid], i,c);
of an array. Here I prepare the c++;
numbers 1,3,4,5,6,7,8,9,0,11,12 to returnbinarySearch(arr.splice(mid,
be tested. Number.MAX_VALUE), i, c);
2. Conduct testing by using a java } else if (arr[mid] > i && arr.length > 1) {
script algorithm coding to console.log('mid higher', arr[mid], i);
determine which algorithm is c++;
better. return binarySearch(arr.splice(0, mid),
3. Evaluate. Evaluation is done to get i,c);
the results of the tests that have } else {
been done. To find out which console.log('not here', i);
algorithm is better and which c++;
algorithm does fewer iterations. return -1;
}
III Design }
The design of this study uses a javascript var result = binarySearch(array, 12, c);
code coding, namely: console.log(result);
1. Sequential Search : </script>
<script>
var array = [1,3,4,5,6,7,8,9,0,11,12]; Both codes will be run using Google
var c = 1; Chrome.
Best-Case :
Worst-Case
Array = 1, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12
Arrays must be sorted first.
Array = 0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 12 Best-Case
Array Sorted = 0 1 2 3 4 5 6 7 8 9 10
The data needed = 5
Process -1
Low = 0
High = 10
Mid = (0 + 10) / 2 = 5
Index-5 = 6
6>5
Worst-Case
Process-2
Low = 0
High = 5 – 1 = 4
Mid = (0 + 4) / 2 = 2
Index-2 = 3
3<5
Process-3
Low = 2 + 1 = 3
High = 4
Mid = (3 + 4) / 2 = 3
Index-3 = 4
4<5
Process-4
Low = 3 + 1 = 4
High = 4 From this research we can find out that
Mid = (4 + 4) / 2 = 4 Binary Search must sort the data first. If the data
Index-4 = 5 is in the middle order, the faster the data will be
5 == 5 found.
Here the researcher will search for the
Requires 4 processes to find data 5. same data using these two algorithms. Data to be
Thisincludes the worst-case of binary search, but used is 7.
it's still better than sequential search.
1. Sequential Search
While the best-case of Binary Search
will occur if the data sought is in the middle of
the array.
Best-Case
Array = 1, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12
Arrays must be sorted first.
Array = 0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 12
Array Sorted = 0 1 2 3 4 5 6 7 8 9 10
The data needed = 6
Process-1
Low = 0
High = 10
Mid = (0 + 10) / 2 = 5
Index-5 = 6
V Conclusion
This research was conducted using the
comparative method, by comparing the
Sequential Search and Binary Search algorithms.
The data used is array data. Because of this
research we can conclude that, Sequential Search
Algorithm is simpler and the data does not need
to be sorted. But Sequential Search is very
inefficient when used with more data. Whereas
Binary Search requires us to sort the data first.
But Binary Search is more efficient than
Sequential Search when using lots of data.