• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 3 pages
Exam (elaborations)

DSA Quiz 5 with correct answers 100% 2026

Document preview thumbnail
Preview 1 out of 3 pages

DSA Quiz 5 with correct answers 100% 2026 Bubble Sort - Correct Answer Sorting Algorithm: Compare two elements together. If the leftmost element is smaller than the rightmost, swap positions. Else, continue on. Stop when an element is in the position it is supposed to be. - Correct Answer How can we improve the previous sorting algorithm? Bubblesort: n(n-1) / 2 comparisons, 0 to n(n-1)/2 swaps (pairwise) Improved Bubble Sort: n-1 to pair wise comparisons, 0 to pairwise swaps. - Correct Answer What is the #comps and @swaps for the Bubble Sort? How about the improved Bubble Sort? Selection Sort - Correct Answer Sorting Algorithm: Look throughout the list, found out where the smallest and largest elements are, swap their position until the whole array is sorted. Check for when the input is already in sorted order and doesn't need anymore comparisons, thereby saving swaps. - Correct Answer How might we be able to improve the Selection Sort? Selection Sort: Pairwise comparisons, 0 to n-1 swaps. Improved Selection: n-1 to pairwise comparisons, 0 to n-1 swaps. - Correct Answer What is the comparisons and swap complexity of Selection Sort? How about the improved selection sort? Insertion Sort - Correct Answer Sorting Algorithm: Compare a value with items starting at the end of a sorted subarray. Shift with all items larger than the value. Stop when current item is smaller than the value. Use the binary search to find out where the item needs to be inserted into. - Correct Answer How can Insertion Sort be improved? Insertion Sort: n-1 to pairwise comparisons, 0 to pairwise comparisons Improved Insertion Sort: (n-1) / 2 to n(n-1) comparisons, 0 to n-1 swaps. - Correct Answer What is the comparisons and swap complexity of Insertion Sort? How about the improved insertion sort? Merge Sort - Correct Answer Sorting Algorithm: Split array into two subarrays until we have multiple subarrays of one. Merge them back together in ascending order. Quicksort - Correct Answer Use partition and pivoting in order to sort a list quickly. Search and compare elements from one end of a list to another until you are successful in finding a match or unsuccessful - Correct Answer How does a sequential search work? Eagerly advancing and eagerly stopping, eagerly checking is considered better because we are more likely to be advancing than stopping, ergo we are reducing the number of comparisons we need to make. - Correct Answer What are the two different approaches to sequential searching? Which one is considered better? Eagerly advancing: Best case, 2, next best case, 3, worst case n+1, average case (n+1) / 2. This applies for both successful and unsuccessful cases. Eagerly stopping (unsuccessful): Best case, 1, worst case 2n-1, average n-1 Successful: Best case 2, worst case 2n, average case n. - Correct Answer Show the difference in computational time between eagerly advancing sequential search and eagerly stopping


Document information

Uploaded on
March 26, 2026
Number of pages
3
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$10.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Wairimumburia
3.5
(2)
Sold
21
Followers
3
Items
2469
Last sold
2 weeks ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.