Chapter 9: More Python Flashcards

1
Q

Bubble Sort

A

Iterates through a list examining pairs of items at a time

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

Selection Sort

A

It works by finding the smallest item in a list and then placing it in the first position. It then finds the next smallest item and places it in second position.

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

Insertion Sort

A

It works by iterating through the sorted items in a list to determine the correct location at which to insert each new item.

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

What is the advantages of functions?

A

Hide the complexity of the code

Easy to understand

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

Recursion

A

breaking a problem down into subsets of the same problem

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

Cons of recursion

A

doesnt scale up like iteration
iterative solutions are mostly faster
more abstract
harder to understand than iterative solutions

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

Pros of recursion

A

fast and easy to code

practical for tree traversal and binary search

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

Advantages of Linear Search

A

It is quick and more efficient for smaller and unsorted data

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

Binary Search

A

It is referred to as the divide and conquer algorithm as when using binary search we compare the value to half the list to see if it is there and we keep halving and halving (comparing as well) until we find it.

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

Linear search

A

It is a search algorithm that iterates through each item in a list one at a time comparing it to a key
(Used to sort list and arrays
Only option for unsorted data)

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

Quick sort

A

Implement recursively.

The sorting algorithm is recursively repeated on subsets of the same problem until a specific stopping point is reached

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

Unit

A

smallest component of a program that can be tested

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

Advantages of Unit Testing

A

Fast
Allows bugs to be easily identified
Makes easy for others to check
Provides documentation

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

What is a Unit in programming?

A

The smallest component of a program that can be tested.

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

What is Recursion?

A

It means breaking a problem down into subsets of the same problem.

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

What are the cons of Recursion?

A

Don’t scale up, slow, and more abstract.

17
Q

What are the pros of Recursion?

A

Fast and easy to code; practical for free traversal and binary search.

18
Q

What is Linear Search?

A

A search algorithm that iterates through each item in a list one at a time comparing it to a key.

19
Q

When is Linear Search used?

A

Used to sort lists and arrays; the only option for unsorted data.

20
Q

What is Binary Search?

A

A divide and conquer method that compares the value to half the list and keeps halving until found.

21
Q

What are the characteristics of Binary Search?

A

Quick; data must be sorted.

22
Q

What is Selection Sort?

A

It finds the smallest item in a list and places it in the first position, then repeats for the next smallest.

23
Q

What is Insertion Sort?

A

It iterates through the sorted items in a list to determine the correct location for each new item.

24
Q

What is Bubble Sort?

A

It iterates through a list examining pairs of items at a time.

25
Q

What is Quicksort?

A

A sorting algorithm that can be implemented recursively, repeated on subsets until a stopping point is reached.

26
Q

Who developed Quicksort and when?

A

Developed by Tony Hoare in 1959.

27
Q

What is Unit Testing?

A

Unit tests use test cases.

28
Q

What are the advantages of Unit Testing?

A

Fast, allows bugs to be easily identified, makes it easy for others to check, provides documentation, and provides confidence that the code should work.