Preview

09 - Sorting and Searching Algorithms

 1. A sorting algorithm will put items in a list into an order, such as alphabetical or numerical order. Put the following list of items in order from smallest to largest.
5,1,2,3,4

  1,2,3,4,5

  The list cannot be put in order

  5,4,3,2,1

  1,3,2,5,4

 2. Sorting a list of items can take a long time, especially if it is a large list. A computer program can be created to do this, making sorting a list of data much easier.

  True

  False

 3. There are many types of sorting algorithms.Which of the following is NOT a sorting algorithm. (Please refer to the SOLVE AND LEARN series No.7 (Searching and sorting) on www.teachyourselfpython.com for more information.
a) Bubble Sort
b) Insertion Sort
c) Merge Sort
d) Quick Sort
e) Moose Sort

  b

  c

  e

  a

 4. A bubble sort algorithm goes through a list of data a number of times, comparing two items that are side by side to see which is out of order. It will keep going through the list of data until all the data is sorted into order.

  False

  True

 5. Insertion sort is a sorting algorithm that sorts one element at a time. Most humans, when sorting a deck of cards, will use a strategy similar to insertion sort.

  True

  False

 6. We often need to find one particular item of data amongst many hundreds, thousands, millions or more. Searching algorithms are so vital! Which of the following are NOT searching algorithms?
a) Binary Search
b) Linear Search
c) Gremlin Search
d) C.S Lewis Search

  a and b

  a and d

  c and d

  All of the options are known search algorithms

 7. Suppose you had a list of 150 customers. What type of search will begin at customer 1 and go to each customer in turn until it reaches customer 150?

  Binary Search

  Kebble Smoothie

  Linear Search

  Bubble Sort

 8. Suppose you had the following list and were searching for the number '7'. In a linear search is it necessary for the list to be sorted?
5,8,2,7,3,33,99

  Yes, any search algorithm will only work with a sorted list

  Yes, a linear search will only work if the list is sorted

  No, a linear search will search a list which is unsorted and still work fine!

  I'm really not sure ...

 9. A Binary search is generally considered a faster method for searching for an item that is in an ordered list. In a binary search you would take any given list of numbers and start ....

  by blowing open the list with a hardware accelerator

  by splitting the list in half and finding the MID POINT ...

  by looking at the very first element in the list

  by looking at the last element in the list

 10. The biggest problem with a serial search is that it can be very s____ for larger lists. The advantage is that it can search a list that is not s_______

  sloppy | slippery

  slow | sorted

  snarly | sanitary

  specific | slow