Test your foundational knowledge of sorting and searching algorithms with this easy quiz, covering key concepts, methods, and the basics of how these algorithms work. Ideal for beginners seeking to review or practice sorting and searching essentials.
Definition of Sorting
Which of the following best defines the process of sorting in computer science?
- Replacing old data with new data
- Arranging data elements in a specific order
- Finding a specific item in a collection
- Grouping identical items together
Bubble Sort Basics
In bubble sort, what happens during one complete pass through the list?
- The middle element is placed first
- All elements are swapped with each other
- The smallest element is removed
- The largest unsorted element is moved to its correct position
Searching Algorithm Types
Which of the following is a searching algorithm?
- Heapify
- Bubble sort
- Merge sort
- Linear search
Result of Binary Search
What does binary search return if the target value is not found in a sorted array?
- The highest value in the array
- A special 'not found' value, such as -1
- A random element of the array
- The last element in the list
Insertion Sort Mechanism
In insertion sort, how are elements moved to their correct position?
- By comparing only the first and last item
- By shifting larger elements to the right
- By swapping each pair of elements
- By reversing the list
Sorted Array Requirement
Which searching method requires the array to be sorted beforehand?
- Linear search
- Breadth-first search
- Binary search
- Hash search
Best Case for Linear Search
In the best-case scenario, how many comparisons does a linear search require to find the target in a list?
- No comparisons needed
- One comparison
- Exactly N comparisons
- Half the length of the list
Selection Sort Feature
During each pass of selection sort, which element is selected?
- The smallest unsorted element
- The median element
- A random element
- The largest sorted element
Algorithm Stability
What does it mean if a sorting algorithm is stable?
- It works only on integers
- It preserves the relative order of equal elements
- It sorts in reverse order
- It crashes when data is large
Searching in Unsorted Data
Which searching algorithm can be used on an unsorted list without any prior arrangement?
- Linear search
- Interpolation search
- Timsearch
- Binary search
Bubble Sort Swap Action
What action is performed when two consecutive elements are out of order during bubble sort?
- The smaller moves to the end
- They are swapped
- Both are deleted
- They are ignored
Purpose of Sorting
Which is a main reason to sort data before searching?
- To increase searching speed using algorithms like binary search
- To hide duplicate entries
- To shuffle items randomly
- To save storage space
Outcome of Searching
If a searched value exists multiple times in a list, what will a basic linear search usually return?
- The index of the last occurrence
- All indices where it appears
- The index of the first occurrence
- The total number of occurrences
Sorting Order
What is it called when you arrange numbers from smallest to largest?
- Descending order
- Ascending order
- Random order
- Partial order
Initial Step for Binary Search
What is the first step to perform in a binary search on a sorted list?
- Check every element in order
- Start at the last entry
- Compare the target with the middle element
- Sort the list again