Well Hello there!!
From this blog myself would love to go with List search algorithms.
What are they ?
Let's go deep then !
Linear Search
This algorithm is also known as sequential search when it's comes to the programming.
"Linear Search is an algorithm for searching through elements of an array"
Let's try searching for the number 6.(Our objective is equals to Find 6)
First we examine the left most number in the array.In this Example it's 3.
We compare it with 6,and if it matches, the search ends. If it doesn't match we examine the next number to the right.In this case 9 is the next number.
We repeat this comparisons until the 6 is found.
We found the 6, so the search ends
As you can see, linear search is a simple technique for doing repeated comparisons in order from the beginning.
When there's a lot of data, the number of comparisons increases,and it takes more time.
This chapter concludes the explanation of linear search.
Binary Search
"Binary Search is an algorithm for searching through elements of a presorted array".
My objective is to find 6
First, we look at the number in the center of the array. In this case it's 5.
We compare 5 to the number 6 that we're searching for.Because 5 is less than 6, we know that the number 6 is to the right of 5.
From the Candidates, we remove numbers that are no longer needed.
Again we look at the number in the center of the remaining array. This time it's 7
We compare 7 to 6. Because 6 is less than 7, we know that the number 6 is to the left of 7.
From the candidates, we remove numbers that are no longer needed.
We look at the number in the center of the array. This time it's 6.
6=6 , so we found the number we were looking for.
In this way, we see that binary search makes use of a presorted array and continuously halves the numbers to search through, allowing it to search for numbers efficiently.
This chapter concludes the explanation of Binary Search.
From this blog myself would love to go with List search algorithms.
What are they ?
- Linear Search
- Binary Search
Let's go deep then !
Linear Search
This algorithm is also known as sequential search when it's comes to the programming.
"Linear Search is an algorithm for searching through elements of an array"
Let's try searching for the number 6.(Our objective is equals to Find 6)
First we examine the left most number in the array.In this Example it's 3.
We compare it with 6,and if it matches, the search ends. If it doesn't match we examine the next number to the right.In this case 9 is the next number.
We repeat this comparisons until the 6 is found.
We found the 6, so the search ends
As you can see, linear search is a simple technique for doing repeated comparisons in order from the beginning.
When there's a lot of data, the number of comparisons increases,and it takes more time.
This chapter concludes the explanation of linear search.
Binary Search
"Binary Search is an algorithm for searching through elements of a presorted array".
My objective is to find 6
First, we look at the number in the center of the array. In this case it's 5.
We compare 5 to the number 6 that we're searching for.Because 5 is less than 6, we know that the number 6 is to the right of 5.
From the Candidates, we remove numbers that are no longer needed.
Again we look at the number in the center of the remaining array. This time it's 7
We compare 7 to 6. Because 6 is less than 7, we know that the number 6 is to the left of 7.
From the candidates, we remove numbers that are no longer needed.
We look at the number in the center of the array. This time it's 6.
6=6 , so we found the number we were looking for.
In this way, we see that binary search makes use of a presorted array and continuously halves the numbers to search through, allowing it to search for numbers efficiently.
This chapter concludes the explanation of Binary Search.
Comments
Post a Comment