2.3 - Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a systematic approach to problem solving?

A
  • Reaching a solution by identifying the individual steps required.
  • a set of rules allows an algorithm that is followed to be precisely lead to an answer.
  • Allows developers to automate solutions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does abstraction allow?

A

It allows us to think about what is important and what is not.

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

What 4 steps should you take for a systematic approach?

A
  1. Break the problem down.
  2. Think about what data is important or not important.
  3. Consider relevent data structures.
  4. Tackle each part of the problem step by step.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an algorithm?

(Simplified)

A

A sequence of steps followed in order to solve a problem.

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

How does a linear search work?

A

It starts at the first item in the list and checks each item one by one to find an item in a sorted or unsorted list.

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

What are the 4 characteristics of a linear search?

A
  • Doesn’t require the data set to be in order e.g settings file.
  • Can be efficient for smaller data sets.
  • Is inefficient for large data sets.
  • Easiest searching algorithm to implement but usually the most ineffient.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a typical use of a linear search?

A

The find-and-replace function in a word processor.

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

When is an algorithm correct?

A

If the result is correct for all input instances.

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

What 4 things does a linear search algorithm have to do?

A
  • Be able to locate an item in a data set (if it exists).
  • Be able to locate the item regardless of whether the data set is sorted or unsorted.
  • Run without crashing even if the item being searched for doesn’t exist in the data set.
  • Check each item sequentially, starting with the first item.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a binary search algorithm?1

A

An efficient algorithm for finding an item in a sorted data set.
It starts at the middle item in the list and repeatedly divides the list in half.

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

What are the 2 characteristics to be a binary search?

A
  • Requires the data set to be sorted first (e.g. numerical or alphabetical order)
  • Is efficient for large data sets.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When would you use a binary search?

A

When you need to search for an item in a large, sorted data set. (e.g. online dictionary in alphabetical order).

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