Sorting and Searching Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a Linear Search?

A

Linear Search is where all elements in an array are searched from the first position in the array to
the last position in the array and each element is compared against a search key.

If the end of the array is reached and no matches were found then the key is not in the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Binary Search?

A

A binary search finds the index mid-point of a an ordered (sorted) data set and determines whether of not the key that you are searching for is greater or less than the mid point. If the mid point does not match the key then the area to be searched is halved because the data
cannot be found in the other half that would have either all values greater than or less than the key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a selection sort?

A

A selection sort works by repeatedly selecting the smallest (or largest) element from the unsorted portion of the list and moving it to the sorted portion of the list. The algorithm repeatedly selects the smallest (or largest) element from the unsorted portion of the list and swaps it with the first element of the unsorted portion. This process is repeated for the remaining unsorted portion of the list until the entire list is sorted.

Simple Terms: It selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a bubble sort?

A

A bubble sort works by repeatedly swapping the adjacent elements if they are in the wrong order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly