Need Help With This Assignment?

Let Our Team of Professional Writers Write a PLAGIARISM-FREE Paper for You!

Linear Search and Sorting Algorithm

Linear Search and Sorting Algorithm

Linear search is identified as one of the two popular search methods, also termed the sequential search algorithm. It involves passing over the list entirely and matching each element with an item on the designated location of the list (Rahim et al., 2017). When the match is found, the outcome is returned as true; otherwise, the algorithm returns the outcome as NULL. Therefore, implementing a linear search for an ordered list involves traversing the elements on the list through a for loop. For every iteration, one should compare the search element with an element from the array. When the comparison has been made and the element matches, the algorithm will yield the index of the corresponding array element (Rahim et al., 2017). On the contrary, the algorithm will have to proceed to the next element if the element fails to match. Conclusively, if the search element is absent within the ordered list provided, the algorithm will return -1 (Rahim et al., 2017). It makes sense to stop a search if the specific item has been found or when the list provided is composed of many items.

On the other hand, a sorting algorithm is a collection of instructions that takes in a list as input and arranges the items in a certain order. An example of a sorting algorithm is Bubble sort. Bubble sort is a simple algorithm that allows the smallest or the largest values to bubble up to the top (Lipu et al., 2016). This algorithm works by traversing a list and comparing values against each other. When the values are disorderly, the algorithm swaps and arranges them correctly (Lipu et al., 2016). It makes the most sense to use the bubble sort when one is required to sort a small number of elements and also when the elements are already sorted partially. On the contrary, it is not efficient for one to use bubble sort when the array involved is large.

An example of a bubble sort entails sorting the following list – 41, 25, 62, 38, and 79. The algorithm will pass through this list and compare the first two elements, 41 and 15. It would then swap them because 25<41. The array will appear this way: 25, 41, 62, 38, and 79. It then compares the next two values, 42 and 62. The algorithm moves to the next since these values are already in order. The next two values are also swapped because 38<62. Since the last two values are already in order, the algorithm leaves them in that order.

References

Lipu, A. R., Amin, R., Mondal, M. N. I., & Al Mamun, M. (2016, December). Exploiting parallelism for faster implementation of Bubble sort algorithm using FPGA. In 2016 2nd International Conference on Electrical, Computer & Telecommunication Engineering (ICECTE) (pp. 1-4). IEEE.

Rahim, R., Nurarif, S., Ramadhan, M., Aisyah, S., & Purba, W. (2017, December). Comparison searching process of linear, binary and interpolation algorithms. In Journal of Physics: Conference Series (Vol. 930, No. 1, p. 012007). IOP Publishing.

ORDER A PLAGIARISM-FREE PAPER HERE

We’ll write everything from scratch

Question 


Linear Search and Sorting Algorithm

Linear Search and Sorting Algorithm

Respond to the following in a minimum of 175 words with example Python code and references.

How would you implement a linear search for an ordered list? When does it make sense to stop a search?
What is 1 example of a sorting algorithm? When does it make the most sense to use the sort you chose? Share an example.

CYB/135: Object-oriented Security Scripting