Software Engineering Flashcards
Big o notation for 000.5n^3
n^3 we ignore all smaller terms, do some big O exampels
BIG 0 order
2^N>n^3>N^2logn>N^2>NlogN>n>1(constant)
Big O, O(x+Y)
the greater of x or y
Big) (XY)
OxOy
Bubble sort
start at index o
compare with item next to you. if its less than you, swap,
incriment.
repeat whole list until there are no swaps
total passes for bubble sort of n length
n(n-1)/2
bubble sort time
best O(n)
avg n^2
worst n^2
Insertion sort
assume first item is sorted.
place the next item in the correct spot for the sorted section.
increase the sorted seciton
total passes for insertion sort
n-1
insertion sort time
best n
worst n^2
avg n^2
selection sort
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.
seleciton sort time
n^2 all
merge sort
Find the middle point to divide the array into two halves:
middle m = (l+r)/2
2. Call mergeSort for first half:
Call mergeSort(arr, l, m)
3. Call mergeSort for second half:
Call mergeSort(arr, m+1, r)
4. Merge the two halves sorted in step 2 and 3:
Call merge(arr, l, m, r)
merge sort timing
nlogn for all
Pivot sort
Pick a “pivot”
- Divide into less-than & greater-than pivot
- Sort each side recursively