Worksheet 5 – Sorting and Searching Name: __________________ 1. 2. Date: ________________ Respond True or False to the following statements about sorting: TRUE FALSE When a list is sorted in ascending order the first element in the list is the lowest. TRUE FALSE The term permutation refers to the rearrangement of a list where all the original values are maintained. TRUE FALSE One factor to consider when deciding on a sorting algorithm is the amount of memory required to perform the sort. TRUE FALSE Whether the data in a list is already partly in order or completely random has no bearing on the choice of sort routine. TRUE FALSE Sort routines that maintain the order of elements with equal value are considered stationary. TRUE FALSE Exchanging two elements in a list is referred to as shifting. TRUE FALSE To exchange two elements in a list, a temporary holding place is needed so no data is lost. TRUE FALSE Moving an element to a new position and then ‘sliding’ the remaining elements over is known as shifting. TRUE FALSE A shift does not require a temporary holding place. Identify the sort(s) based on the description provided: a. Orders elements as it finds them out of order: __________________________ b. Performs sorting in-place: __________________________ c. Uses recursion to sort: __________________________ d. Works well with partially sorted lists: __________________________ e. Despite an increase in elements, the speed of sort does not significantly decrease: __________________________ f. Uses a pivot element: __________________________ g. Uses shifting: __________________________ h. Uses swapping: __________________________ i. Has a big ‘O’ efficiency of O(nlogn): ___________________________ j. Has a big ‘O’ efficiency of O(n2): ___________________________ 3. Fill-in-the-blanks about information on searches. The item that is being searched for is called a ________. A search routine where each element is examined one at a time in order is called the __________________________. This search only works on a list that is sorted: ____________________. With each search interval or pass in a binary search, the area to search is ____________. If the item that is being searched for is located at the very first index of a list, the search routine that will find it faster is: ____________________. On average, the ____________ search is faster than the ________________ search. The binary search has an average big ‘O’ efficiency level of __________. 4. Create and manipulate a 1-D array that holds 30 integer numbers: a. Fill the array with the consecutive numbers 101 to 130. (Display the array.) b. Let the user enter a number to be removed from the list. (i.e. 108) c. Using the binary search method, find the number in the list. d. Once the number is found remove it by shifting proceeding numbers over to the left. Initialize the final empty cell at the end of the array to 0. (Display the array again.) Application Name: SearchAndRemove