Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ With screenshot ****************** 1) What are Sorting algorithms. Where

ID: 3794901 • Letter: I

Question

In C++ With screenshot

******************

1) What are Sorting algorithms.

    Where can you get a comprehensive list of them online ?

2) What are Searching algorithms

     Where can you get a comprehensive list of them online ?

3) List  5 algorithms to sort Link Lists.

    List a website for each that describes and its code

4) How do you sort a recursive list

5) What are the top 2 sorting and searching algorithms ?

    Explain why so...

Write a OOP program that store an array of 100 integers.

    Add/code 1 of the top 2 sorting algorithms you mentioned above

    Add/code 1 of the top 2 searching algorithms you mentioned above

    Have a function to ask the user for input.

    Have a function to print out the array

    Have a function to delete an integer

    Have the ability to know/printout the count the number of integers

Explanation / Answer

Linear search The simplest search algorithm is linear search. In linear search, we look at each item in the list in turn, quitting once we find an item that matches the search term or once we’ve reached the end of the list. Our “return value” is the index at which the search term was found, or some indicator that the search term was not found in the list. 3.1.1 Algorithm for linear search for (each item in list) { compare search term to current item if match, save index of matching item break } return index of matching item, or -1 if item not found

linear search works well in many cases, particularly if we don’t know if our list is in order. Its one drawback is that it can be slow. If N, the number of items in our list, is 1,000,000, then it can take a long time on average to find the search term in the list (on average, it will take 500,000 comparisons). What if our list is already in order? Think about looking up a name in the phone book. The names in the phone book are ordered alphabetically. Does it make sense, then, to look for “Sanjay Kumar” by starting at the beginning and looking at each name in turn? No! It makes more sense to exploit the ordering of the names, start our search somewhere near the K’s, and refine the search from there. Binary search exploits the ordering of a list. The idea behind binary search is that each time we make a comparison, we eliminate half of the list, until we either find the search term or determine that the term is not in the list. We do this by looking at the middle item in the list, and determining if our search term is higher or lower than the middle item. If it’s lower, we eliminate the upper half of the list and repeat our search starting at the point halfway between the first item and the middle item. If it’s higher, we eliminate the lower half of the list and repeat our search starting at the point halfway between the middle item and the last item.