728x90
반응형
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 100)
fig, axs = plt.subplots(2, 3)
plt.rcParams['font.family'] = 'NanumGothic' # 한글 가능하도록 폰트 설정
fig.suptitle("시간 복잡도에서 빠른 순서:O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O(n^3) < O(2^n) < O(n!)")
axs[0, 0].plot(x, np.ones(99))
axs[0, 0].set_title('O(1)')
axs[0, 1].plot(x, np.log2(x))
axs[0, 1].set_title('O(log n)')
axs[0, 2].plot(x, x)
axs[0, 2].set_title('O(n)')
axs[1, 0].plot(x, x * np.log2(x))
axs[1, 0].set_title('O(n log n)')
axs[1, 1].plot(x, x ** 2)
axs[1, 1].set_title('O(n^2)')
axs[1, 2].plot(x, 2 ** x)
axs[1, 2].set_title('O(2^n)')
for ax in axs.flat:
ax.set(xlabel='Input Size', ylabel='Time Complexity')
for ax in axs.flat:
ax.label_outer()
plt.show()
728x90
반응형
'프로그램' 카테고리의 다른 글
[파이썬] 문제 : 학생들의 점수에 따른 등급 함수 (0) | 2023.05.15 |
---|---|
[파이썬] 문제 : (sklearn)Wine 데이터 분류 (DecisionTree / SVC / GaussianNB) (0) | 2023.05.13 |
[파이썬] 문제 : tkinter 숫자 맞추기 게임 (0) | 2023.05.12 |
[파이썬] 문제 : tkinter canvas에 사각형 그리고, 상하좌우 이동 (0) | 2023.05.12 |
[파이썬] tkinter 할 일 리스트(Text) 만들기 (0) | 2023.05.10 |
댓글