Searching And Sorting Algorithms

13 Questions

Settings
Please wait...
Data Structure Quizzes & Trivia

Questions and Answers
  • 1. 
    Searching and sorting algorithms are best implemented with which data structure?
    • A. 

      An array based list

    • B. 

      A linked list

    • C. 

      Both above

  • 2. 
    What is the key used in a search algorithm?
    • A. 

      Used in operations such as searching, sorting, inserting and deleting

    • B. 

      Used to encrypt the data

    • C. 

      Used in the compareTo() and equalsTo() operations

  • 3. 
    Which search algorithm is best for a large list?
    • A. 

      Sequential search

    • B. 

      Binary search

    • C. 

      A for each loop

  • 4. 
    A binary search algorithm can be best described as what?
    • A. 

      A instant lookup method

    • B. 

      A divide and conquer technique

    • C. 

      Start at the head, move through the list until found

  • 5. 
    On average, a sequential search algorithm would make N/2 number of comparisons for a list of size N.
    • A. 

      True

    • B. 

      False

  • 6. 
    A function f(n) is Big-O of g(n) if there exist positive constants c and n0 such that f(n) <= cg(n) for all n >= n0
    • A. 

      True

    • B. 

      False

  • 7. 
    The following best describes which algorithm? The elements are compared and swapped if the first is found to be greater than the second.
    • A. 

      Binary search algorithm

    • B. 

      Linear search algorithm

    • C. 

      Bubble sorting algorithm

  • 8. 
    The purpose of the bubble sorting algorithm is what?
    • A. 

      To speed up the search of an item in the list

    • B. 

      To sort the contents of the list

    • C. 

      Both choices above

    • D. 

      None of the above

  • 9. 
    • A. 

      Finding the smallest element in the list and moving this to the begining of the unsorted list

    • B. 

      Keeping a list of the smallest elements for later use when searching

    • C. 

      None of the above

  • 10. 
    The insertion sort algorithm improves on the selection sort method by reducing the number of comparisons.
    • A. 

      True

    • B. 

      False

  • 11. 
    The quick sort algorithm divides the list into two sublists, then sorts each sublists, and then combines both sublists.
    • A. 

      True

    • B. 

      False

  • 12. 
    The merge sort algorithm differs from the quick sort only in how it partitions the list, which is to create two nearly equal sublists.
    • A. 

      True

    • B. 

      False

  • 13. 
    The heap sort algorithm begins by converting the list into a heap, then sorting.
    • A. 

      True

    • B. 

      False