ArrayList in AP Computer Science A
How does selection sort work?
It divides the ArrayList into a sorted subarray and an unsorted subarray, selecting the smallest element and swapping it with the first element
It compares adjacent elements and swaps them if they are in the wrong order
It selects the largest element and moves it to the end of the ArrayList
It randomly shuffles the elements in the ArrayList
Which sorting algorithm can be most efficient when dealing with small datasets or nearly-sorted data?
Insertion Sort
Heap Sort
Merge Sort
Quick Sort
If you need to frequently check if values are contained within a dataset while keeping it sorted at all times, what data structure should you ideally use?
ArrayList
Hashtable
HashMap
TreeSet
What issue arises if you accidentally use a 'greater than' comparison instead of 'less than' during partitioning in a quicksort algorithm?
Elements could be partitioned incorrectly, resulting in an improperly sorted array.
This modification increases space complexity due to larger stack frames used by recursion.
All negative numbers would be lost during sorting operation if this mistake is made.
It leads to infinitely recursive calls without reaching base cases effectively.
What term describes the process of repeatedly finding the minimum element from an unsorted part and moving it to the beginning?
Selection sort
Binary search
Radix sort
Heap sort
What advantage does bubble sort offer over quicksort when considering the stability of sorting algorithms?
Bubble sort maintains the relative order of equal elements while sorting
Bubble Sort operates more efficiently in distributed systems compared to quicksort
Bubble sort has a faster worst-case runtime than quicksort's
Bubblesort uses less memory than quicksort during execution
Before an algorithm represents a suitable choice for real-time processing application?
Radix sort
Merge sort
Quick sort
Heap sort

How are we doing?
Give us your feedback and let us know how we can improve
Which tool helps identify logical errors by displaying output messages within your code?
Code formatters.
Syntax highlighters.
Console logs or print statements.
Compilers.
Which sorting algorithm divides the ArrayList into a sorted subarray and an unsorted subarray?
Insertion sort
Quick sort
Selection sort
Merge sort
In a modified merge sort algorithm, if the size of the list becomes less than a predetermined threshold, it switches to insertion sort; what is the primary reason for employing this hybrid approach?
It avoids stack overflow by limiting the depth of recursion.
It improves performance by exploiting insertion sort’s efficiency on small lists.
It ensures stable sorting regardless of duplicate elements.
It allows sorting of data that doesn't fit entirely in memory.