Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Algorithm Parallel Processing Quiz: Search and Sorting Algorithms, Quizzes of Algorithms and Programming

A quiz on search and sorting algorithms, covering topics such as bubble sort, selection sort, merge sort, quick sort, linear search, binary search, heap sort, radix sort, insertion sort, and depth-first search. It includes explanations for each question and the time complexities of various algorithms.

Typology: Quizzes

2023/2024

Available from 06/02/2024

ricoputrabuana
ricoputrabuana 🇮🇩

28 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Gunadarma University
Subject : Algorithm Parallel Processing
Faculty : Industrial Technology
Program of Study : Informatics Engineering Major
Years : 2024
Search And Sorting Algorithm Quiz
1. Which of the following sorting algorithms has the best average-case time complexity?
A) Bubble Sort
B) Selection Sort
C) Merge Sort
D) Insertion Sort
Explanation: Merge Sort has an average-case time complexity of O(n logn), which is more
efficient than the average-case time complexities of Bubble Sort (O(n2)), Selection Sort (O(n2)),
and Insertion Sort (O(n2)).
2. What is the worst-case time complexity of Quick Sort?
A) O(n logn)
B) O(n2)
C) O(n)
D) O(logn)
Explanation: Quick Sort has a worst-case time complexity of O(n2), which occurs when the pivot
selection consistently results in unbalanced partitions. However, with good pivot selection
strategies, its average-case time complexity is O(n logn).
pf3
pf4

Partial preview of the text

Download Algorithm Parallel Processing Quiz: Search and Sorting Algorithms and more Quizzes Algorithms and Programming in PDF only on Docsity!

Gunadarma University

Subject : Algorithm Parallel Processing Faculty : Industrial Technology Program of Study : Informatics Engineering Major Years : 2024 Search And Sorting Algorithm Quiz

  1. Which of the following sorting algorithms has the best average-case time complexity? A) Bubble Sort B) Selection Sort C) Merge Sort D) Insertion Sort Explanation: Merge Sort has an average-case time complexity of O(n logn), which is more efficient than the average-case time complexities of Bubble Sort (O(n^2 )), Selection Sort (O(n^2 )), and Insertion Sort (O(n^2 )).
  2. What is the worst-case time complexity of Quick Sort? A) O(n logn) B) O(n^2 ) C) O(n) D) O(logn) Explanation: Quick Sort has a worst-case time complexity of O(n^2 ), which occurs when the pivot selection consistently results in unbalanced partitions. However, with good pivot selection strategies, its average-case time complexity is O(n logn).
  1. Which searching algorithm would be most efficient for searching through a sorted list? A) Linear Search B) Binary Search C) Jump Search D) Interpolation Search Explanation: Binary Search is efficient for searching through a sorted list with a time complexity of O(logn), much better than Linear Search's O(n).
  2. Which of the following sorting algorithms is not a comparison-based sorting algorithm? A) Quick Sort B) Heap Sort C) Radix Sort D) Merge Sort Explanation: Radix Sort is not a comparison-based sorting algorithm; it sorts numbers by processing individual digits. Quick Sort, Heap Sort, and Merge Sort are all comparison-based.
  3. In which case does Linear Search perform better than Binary Search? A) When the list is sorted B) When the list is unsorted C) When the list is empty D) When the element to be found is in the middle of the list Explanation: Linear Search performs better on unsorted lists because Binary Search requires the list to be sorted.
  1. What is the average-case time complexity of Binary Search? A) O(n) B) O(n^2 ) C) O(logn) D) O(1) Explanation: Binary Search has an average-case time complexity of O(logn), as it repeatedly divides the search interval in half.
  2. Which of the following statements is true about Bubble Sort? A) It is an optimal sorting algorithm B) It has a best-case time complexity of O(n logn) C) It can be easily optimized to detect already sorted lists D) It is faster than Quick Sort on large datasets Explanation: Bubble Sort can be optimized by adding a flag to detect if any elements were swapped during a pass. If no swaps are made, the list is already sorted, and the algorithm can terminate early. Its best-case time complexity remains O(n) when the list is already sorted.