Lesson 12 Flashcards

1
Q

Finite State Machine

A

is a graphical approach to describe the behavior of an automated system.
The states of an FSM are represented as circles.
The action of the system when in a state is described in each circle
Translation between states are represented using arrow
Initial state should

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

To program a FSM in Python

A
  1. Initialize an integer variable to keep track of the current state
  2. Record input values ( sensor, key presses, etc.)
  3. Evaluate transition logic
  4. Update the state
  5. Apply the state actions
  6. Repeat from step 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sort

A

Problem: Arranging elements in collection
Common sorting algorithms

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

Insertion sort

A

Efficient for small or nearly sorted datasets

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

Bubble sort

A

simple to implement but slow for large datatsets

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

Selection sort

A

Minimal swaps but slow for large datasets

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

Merge Sort

A

Fast for large datasets but requires more memory

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

Quick sort

A

Fast on average but poor worst case performance

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

Insertion sort:

A

Pull elements from a list and insert them in order into a new list

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

Common search algorithms

A

Linear search: checks elements one by one. Works on unsorted lists
Binary search: fast on sorted lists
Jump search: faster than linear on sorted lists, but slower than binary
Interpolation search: faster than binary for uniformly distributed and sorted data

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

Binary search

A

Compare the middle of a sorted list with the target. If the target is greater than the middle element, it must appear to the right of the middle. Otherwise it must appear to the left of the middle. Repeat

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