Chapter 1 - Algorithms

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

24 Terms

1
New cards

What is an algorithm?

A finite sequence of step-by-step instructions used to solve a problem.

2
New cards

In a flowchart, what does the shape of each box represent?

The function or purpose of that step.

3
New cards

How can unordered lists be sorted?

Using algorithms such as bubble sort or quick sort.

4
New cards

What is the basic idea of bubble sort?

Compare adjacent items and swap them if they are not in order.

5
New cards

What happens if adjacent items in bubble sort are already in order?

They are left as they are.

6
New cards

When is a list sorted in bubble sort?

When a full pass is completed with no swaps.

7
New cards

What is the first step in quick sort?

Select a pivot.

8
New cards

How does quick sort split the list?

Into items less than the pivot and items greater than the pivot.

9
New cards

What happens after the initial split in quick sort?

Further pivots are chosen and the process is repeated on each sub-list.

10
New cards

What are the three bin-packing algorithms?

First-fit, first-fit decreasing, and full-bin.

11
New cards

How does the first-fit algorithm work?

Items are considered in the order they are given.

12
New cards

How does the first-fit decreasing algorithm work?

Items are sorted in descending order before applying first-fit.

13
New cards

How does the full-bin packing algorithm work?

Inspection is used to fill bins exactly, remaining items use first-fit.

14
New cards

What is an advantage of first-fit?

Quick to implement.

15
New cards

What is a disadvantage of first-fit?

Not likely to lead to a good solution.

16
New cards

What is an advantage of first-fit decreasing?

Usually gives a good solution and is easy to implement.

17
New cards

What is a disadvantage of first-fit decreasing?

May not produce an optimal solution.

18
New cards

What is an advantage of full-bin packing?

Usually gives a good solution.

19
New cards

What is a disadvantage of full-bin packing?

Difficult to do, especially with many or awkward numbers.

20
New cards

What does the order of an algorithm describe?

How run time grows as input size increases.

21
New cards

If an algorithm has order f(n), how does run time change from size n to m?

By approximately a factor of f(m) / f(n).

22
New cards

If problem size increases by factor k, how does linear time change?

It takes approximately k times as long.

23
New cards

If problem size increases by factor k, how does quadratic time change?

It takes approximately k² times as long.

24
New cards

If problem size increases by factor k, how does cubic time change?

It takes approximately k³ times as long.