Compsci Unit 5 - Algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

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.

20 Terms

1
New cards

Algorithm

a finite set of instructions to accomplish a task

2
New cards

sequencing

following steps in order (order of lines of code)

3
New cards

selection

making decisions on which step to execute next (if statement)

4
New cards

iteration

repeating some steps (loops)

5
New cards

problem

task that we want to do

  • some problems can be solved with an algorithm, and some can’t

6
New cards

decidable problem

a decision problem for which an algorithm cna be written to produce a correct output for all inputs or instances

7
New cards

undecidable problem

a problem for which no algorithm can be constructed that is always capable of providing a correct yes or no answer

  • may have some instances, but cannot solve ALL instances

8
New cards

searching

looking for a value or information within a collection of data

9
New cards

linear/sequential search

check each element of a list, in order, until the desired value is found or all elements in the list have been checked

  1. use a loop, traverse the list

  2. compare each value to what you are searching for within an if statement

  3. add other program code based on the problem you are solving

10
New cards

binary search

only works on sorted data

runs in logramithic time

  1. checks middle value to find out if too high or low

  2. eliminated half the values

  3. chooses the new middle

  4. and repeats until found or eliminated all values

11
New cards

selection sort

  1. travers the list and select what should be at index 0

  2. swap whats there with what should be there

  3. repeat for subsequent indexes

12
New cards

insertion sort

  1. traverse the list and compare each value with the value that comes immediately before

  2. move each value left until it is “Inserted” in the correct location

  3. repeat for subsequent indexes

can be faster than selection sort

13
New cards

efficiency

a measure of how many steps are needed to complete an algorithm in the worst case scenario

14
New cards

linear time

given liat size n, alrogirthm will run a max of n times

15
New cards

insertion and selection sort run how many times?

in the worst case scenario, given a list size of in it will run max (n²-n)/2 times — polynomial time

16
New cards

exponential efficiency

given list of size n, 2^n subsets to be found (unreasonable)

17
New cards

brute force algorithm

calculate the distance of every possible route and identify the shortest one

given a list of n cities, will run n! times — factorial time (unreasonable)

18
New cards

decision problem

a problem with a yes/no answer

19
New cards

optimization problem

a problem with the goal of finding the “best” solution among many

20
New cards

heuristic

an algorithm used that is “good enough” and runs in reasonable time is when an exact algorithm is either impossible or impractical