Chapter 9: More Python Flashcards

You may prefer our related Brainscape-certified 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