2.3.1 analysis, design and comparison algorithms

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

1/20

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.

21 Terms

1
New cards

time complexity

how much time an algorithm requires to solve a particular problem

2
New cards

big o cheat sheet

knowt flashcard image
3
New cards

O(1) time complexity

  • constant time complexity

  • time taken is independent from the number of elements inputted

4
New cards

O(n) time complexity

  • linear time complexity

  • time taken is directly proportional to the number of elements inputted

5
New cards

O(n²) time complexity

  • time taken is directly proportional to the square of the elements inputted

  • quadratic

6
New cards

0(2ⁿ)

  • exponential

  • time taken will double with every additional item

7
New cards

0(log n)

  • logarithmic

  • each step cuts the problem size in half

8
New cards

0(n log n)

  • linearithmic

  • the algorithm does n operations, but each operation takes log n time, so the total is n × log n steps

9
New cards

time complexities in order

fastest

  • O(1)

  • O(log n)

  • O(n)

  • O(n log n)

  • O(n2)

  • O(2n)

  • O(n!)

10
New cards

space complexity

the amount of storage the algorithm takes

11
New cards

in place sort

  • elements of the array are sorted directly within the array itself

  • space complexity remains O(1)

  • Bubble Sort, Insertion Sort, quick sort

12
New cards

out of place sort

  • additional arrays are used as part of the sort requiring more memory

  • O(n)

  • e.g. the sub-arrays created during merge sort

13
New cards

reduce space complexity

preforms all the changes on the original piece of data

14
New cards

reduce time complexity

  • reduce the number of embedded loops

  • reduce the number of items you have to complete the operations on

15
New cards

algorithm

a series of steps that completes a task

16
New cards

linear search

  • starts at the first item in the list and checks each item one by one

  • doesn’t require data to be in order

  • can be efficient for small data sets

  • inefficient for large data sets

17
New cards

linear search in pseudocode

knowt flashcard image
18
New cards

linear search in python

knowt flashcard image
19
New cards

binary search

  • starts at the middle item in the list and repeatedly divides the list in half

  • each time checking if the midpoint is the item being searched for

  • discarding half of the data after each iteration, quickly reducing large data sets

  • requires the data set to be sorted

  • efficient for large data sets

20
New cards

binary search in pseudocode

knowt flashcard image
21
New cards

binary search in python

knowt flashcard image