Arrays-WPS Office
Arrays-WPS Office
5. Accessing an array element with an invalid index can lead to an error. True
10. It is efficient to use arrays when you need fast access to elements by index. True
Bubble Sort
1. Bubble Sort is a comparison-based algorithm. True
2. In Bubble Sort, the largest element is placed at the beginning of the list in each iteration. False
3. Bubble Sort repeatedly steps through the list, compares adjacent elements, and swaps them if they
are in the wrong order. True
5. Bubble Sort is considered an inefficient sorting algorithm for large datasets. True
6. Bubble Sort is stable, meaning it preserves the relative order of equal elements. True
7. Bubble Sort can be optimized by stopping the algorithm if the inner loop didn’t cause any swap. True
9. The average and worst-case time complexity of Bubble Sort is O(n log n). False
10. Bubble Sort works well on small or nearly sorted datasets. True
Selection Sort
1. The selection sort algorithm is a comparison-based algorithm.
- True
2. Selection sort finds the maximum element and places it at the beginning of the array.
- False (It finds the minimum element and places it at the beginning.)
3. Selection sort works by dividing the input list into a sorted and an unsorted region.
- True
- True
6. Selection sort repeatedly selects the largest remaining element and moves it to its correct position.
- True
8. Selection sort requires additional memory proportional to the size of the input list.
- False (It requires a constant amount of additional memory, O(1).)
9. The outer loop of selection sort runs 'n' times for an array of length 'n'.
- True
- False (Both the best-case and worst-case time complexities are O(n²).)
Insertion Sort