Algorithms Flashcards

1
Q

What is an algorithm?

A

A set of instructions used to solve a problem

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

How can algorithms be represented?

A

Using pseudocode or flowcharts

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

What are the symbols used in flow diagrams and what are their functions?

A

Line - Flow from one component to the next
Rectangle - Process
Parallelogram - Input/ Output
Rhombus - Decision
Oval -Start/Stop
*Rectangle w/ lines - Subroutine

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

What are the symbols used in flow diagrams and what are their functions?

A

Line - Flow from one component to the next
Rectangle - Process
Parallelogram - Input/ Output
Rhombus - Decision
Oval -Start/Stop
*Rectangle w/ lines - Subroutine

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

What is decomposition?

A

The breakdown of large problems into smaller , more manageable chunks

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

What is abstraction?

A

The removal of unnecessary details in a problem

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

Name 2 searching algorithms:

A

Linear search and Binary search

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

Describe how linear search works:

A

The algorithms starts at the beginning term of a list.
It the compares it to the value that is being searched, if the value matches, the algorithm stops as the value is found.
If not, it goes to the next term of that list and repeats the process.
This is repeated until either the value is found, or the end of the list has been reached, thus the value is not in the list.

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

Describe how binary search works:

A

Compare the searched value with the middle term in an ordered list.
If the values don’t match, split the list in half, if the searched value is smaller than the middle term, get rid of the bigger half, if it’s bigger, get rid of the smaller half.
Then, compare with the middle value of the new list, and repeat the process until the value is found

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

Compare binary and linear search:

A
  1. Binary search is more efficient for longer lists
  2. Linear search is simpler and better for shorter lists
    3.Linear search can be used for unordered lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Name 2 sorting algorithms:

A

Bubble sort and Merge sort

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

Describe how bubble sort works:

A

The algorithm starts with the first value in a list, it is compared to the second value - if the first value is bigger a swap is preformed, if not, they remain in that order.
The second value is then compared to the third value and the same process is performed.
This is done continuously until the end of the list is reached - one pass is done.
If the list is still not ordered the algorithm continues the process, until it is finally sorted
If the end of the list is reached with no swaps being made, the list is sorted

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