Week 6 Flashcards

1
Q

are fundamental algorithms

A

Searching data and sorting through data

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

involves going through elements in a data structure to find specific data,

A

Searching

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

involves arranging elements in a particular order.

A

while sorting

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

is the task of looking for a specific element inside a data structure.

A

As mentioned, searching

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

works by going through each element of the array one index after another sequentially.

A

A linear search

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

Sequentially checks each element in a list until the target value is found or the list ends.

A

Linear Search Code

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

Is a searching algorithm that works on sorted data. Unlike the linear search algorithm, in which every element of the array is checked,

A

Binary Search

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

can check the middle value to see whether the desired value is greater or smaller than it. If the desired value is smaller, this algorithm can search through the smaller parts, or it can search through the bigger parts if the desired value is bigger

A

binary searches

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

is one of the most important topics in computer science; it is faster and easier to locate items in a sorted array than in an unsorted sorted array.

A

Sorting

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

is the simplest sorting algorithm. It simply iterates over the entire array and swaps elements if one is bigger than the other.

A

Bubble sorting

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

is the worst type of sort because it compares every pair possible, whereas other sorting algorithms take advantage of the presorted parts of the array. Because bubble sort uses nested loops, it has a time complexity of O(n2).

A

Bubble sort

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

works by scanning the elements for the smallest element and inserting it into the current position of the array. This algorithm is marginally better than bubble sort.

A

Selection sorting

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

works similarly to selection sort by searching the array sequentially and moving the unsorted items into a sorted sublist on the left side of the array.

A

Insertion sort

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

works by obtaining a pivot and partitioning the array around it (bigger elements on one side and smaller elements on the other side) until everything is sorted. The ideal pivot is the median of the array since it will partition the array evenly but getting the median of an unsorted array linear time to compute. Hence, a pivot is typically obtained by taking the median value of the first, middle, and last elements in the partition. This sort is a recursive one and uses the divide-and-conquer methodology to break the quadratic complexity barrier and get the time complexity down to O(nlog2(n)). However, with a pivot that partitions everything on one side, the time complexity is worse case: O(n2).

A

Quicksort

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

is a selection algorithm to find the kth smallest element in an unordered list. Quickselect uses the same approach as a quicksort algorithm. A pivot is chosen, and the array is partitioned. Instead of recursing both sides like quicksort, however, it recurses only the side for the element. This reduces the complexity from O(nlog2(n)) to O(n)

A

Quickselect

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

works by dividing the array into subarrays until each array has one element. Then, each subarray is concatenated (merged) in a sorted order.

A

Mergesort

17
Q

can be done in O(k+n) because it does not compare values. It works only for numbers and given a certain range. Instead of sorting by swapping elements, this count works by counting occurrences of each element in the array. Once occurrences of each element are counted, the new array can be created using those occurrences. This sorts the data without having to swap elements

A

Count sort