Back to marketplace

Algorithms

No description yet. This curated deck is ready for daily study.

Total cards: 17•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (17)

#1
Front (Question)

Loop invariant

Back (Answer)

an assertion about the loop that is relevant to the purpose of the loop and that holds true before and after each iteration through the loop

#2
Front (Question)

Sequential Search vs. Binary Search

Back (Answer)

Sequential Search is faster when the list is NOT sorted in ascending or descending order. Binary search employs the “half-half-half” method to find the target. This works best if the list is already sorted

#3
Front (Question)

Iterations for Binary Search (sorted)

Back (Answer)

for 2^k - 1 elements, binary search requires at most k iterations. With an array of n elements, this is log(base2)n iterations

#4
Front (Question)

Iterations for Sequential Search

Back (Answer)

n/2 (elements) < # iterations < n (elements)

#5
Front (Question)

Selection Sort

Back (Answer)

number of required comparisons is about n^2. Iterate for k from n down to 2: find the largest among the first k elements and swap it with the kth element

#6
Front (Question)

Insertion Sort

Back (Answer)

number of required comparisons is about n^2. iterate for k from 2 up to n. Keep the first (k-1) elements sorted and insert the k-th element among them where it belongs

#7
Front (Question)

Insertion Sort vs. Selection Sort:

Back (Answer)

Insertion Sort, on average, requires more moves than selection sort. NEITHER, however, ALWAYS requires more moves than the other

#8
Front (Question)

While vs. if in recursion

Back (Answer)

if usually replaces while loops for recursion methods, such is the entire PURPOSE of recursion

#9
Front (Question)

Merge sort comparison

Back (Answer)

nlogn

#10
Front (Question)

Merge sort method:

Back (Answer)

divide the array into two approximately equal halves; sort recursively each half, then merge them together into one sorted array

#11
Front (Question)

Technique of Sequential Search:

Back (Answer)

consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.[1] (Almost always slower than binary search)

#12
Front (Question)

Insertion Sort Technique:

Back (Answer)

Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. On a repetition, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain. It does NOT switch the elements.

#13
Front (Question)

Selection Sort Technique:

Back (Answer)

This is the one that DOES switch the elements.

#14
Front (Question)

Insertion Sort Run Times and storage complexities

Back (Answer)

Wort number of comparisons: n^2 Best comparisons: n Average: n^2

#15
Front (Question)

Selection Sort Run Times and storage complexities:

Back (Answer)

Worse number of comparisons: n^2 Best comparisons: n^2 Average: n^2

#16
Front (Question)

Merge Sort Technique:

Back (Answer)

divide and conquer (usually with recursion).

#17
Front (Question)

Merge Sort run times and storage complexities:

Back (Answer)

worst AND best case run time = nlogn Average = nlogn