Chapter 9 (Sorting and Searching Arrays)

Description

Computer Science Flashcards on Chapter 9 (Sorting and Searching Arrays), created by Andrew Lewis on 14/12/2020.
Andrew Lewis
Flashcards by Andrew Lewis, updated more than 1 year ago
Andrew Lewis
Created by Andrew Lewis over 3 years ago
3
0

Resource summary

Question Answer
This type of algorithm rearranges the values stored in an array in some particular order. Sorting Algorithm
If an array is sorted in this order, the values are stored from lowest to highest. Ascending Order
If an array is sorted in this order, the values are stored from highest to lowest. Descending Order
This algorithm makes several passes through an array and causes the larger values to gradually move or "bubble" toward the end of the array with each pass. Bubble Sort Algorithm
In this algorithm, the smallest value in the array is located and moved to the element 0. Then the next smallest value is located and moved to element 1. This process continues until all of the elements have been placed in their proper order. Selection Sort Algorithm
This algorithm sorts the first two elements which become the sorted part of the array. Then it inserts each of the remaining elements, one at a time, into the sorted part of the array at the correct location. Insertion Sort Algorithm
This search algorithm steps sequentially through an array, comparing each item with the search value. Best used for small array and not large ones. Sequential Search Algorithm
This search algorithm repeatedly divides the portion of an array being searched in half. Each time it divides the array, it eliminates the half of the array that doesn't contain the item. Requires that all values in the array are in ascending order. Binary Search Algorithm
Between binary search and sequential search, which is more efficient. Binary Search
True/False: Regardless of the programming language being used, it is not possible to use the bubble sort algorithm to sort strings. False: Bubble Sort, Selection Sort, and Insertion Sort are all capable to reorder strings.
True/False: The "average" number of comparisons performed by the sequential search algorithm on an array of "n" elements is "n/2" (assuming the search values are consistently found). True
True/False: The "maximum" number of comparisons performed by the sequential search algorithm on an array of "n" elements is "n/2" (assuming the search values are consistently found). False: It is possible to go through all the values of an array which means the maximum is "n" and not "n/2".
True/False: To successfully swap the contents of two variables, we need to declare a third variable that can serve as a temporary storage location. True
Assuming a temporary variable was made for the swap function, what are the following steps to swap the two values of variables "a" and "b"? - Assign the value of "a" to "temp". -Assign the value of "a" to "b". - Assign the value of "temp" to "b".
Show full summary Hide full summary

Similar

TOEFL English Vocab (A - M)
Ali Kane
Random German A-level Vocab
Libby Shaw
Vocabulary Words
Jenna Trost
TOEFL English Vocabulary (N - Z)
Ali Kane
L'environnement
Bryony Whitehead
TOEFL Vocabulary
aliking
French 1A Vocab
Jade Allatt
10 animals in spanish
Jlaal Mohammed
TOEFL Vocabulary Test
Ali Kane
French 1B Vocab (numbers)
Jade Allatt
French 1D Vocab
Jade Allatt