본문 바로가기

의지박약/기본기가없다5

[자료구조] 데이터 구조 연산별 시간복잡도(Data Structure Operation) - javascript 자바스크립트 시간복잡도 표 참고용 만들어주신 Ben님 감사합니다. 출처 하단에 있습니다. Reference http://blog.benoitvallon.com/data-structures-in-javascript/data-structures-in-javascript/ 2021. 5. 20.
[python] Operations 별 시간복잡도(TimeComplexity) - list, set, dictionary 가능한 외우자.. l : List = [] Operation Example Complexity Notes Index l[i] O(1) List 인덱스 Store l[i] = 0 O(1) 인덱스 지정 저장 Length len(l) O(1) List 크기 Append l.append(j) O(1) List 값 추가 Pop - last l.pop() O(1) 인덱스 없이 가장 마지막 값 pop하는 경우만 Clear l.clear() O(1) l=[] 랑 똑같음 Slice l[a:b] O(b-a) l[1:5]:O(l)/l[:]:O(len(l)-0)=O(N) Extend l.extend(...) O(len(...)) extension의 길이에 의존 Construction list(...) O(len(...)) (.. 2021. 5. 20.
[python] 피보나치수열을 굳이 클로저를 사용해서.. 피보나치수는 0과 1로 시작하며 다음 피보나치수는 바로 앞의 두 피보나치 수의 합이 된다. 시간복잡도는 신경 안쓰고 그냥 클로저 라는 기능을 봤을때 피보나치수열이 생각나서 그냥 구현해봤다. def fibo(f,b): front = f back = b print(f"시작 값 1번째, 2번째 : {f}, {b}") result = 0 def nacci(): nonlocal front nonlocal back nonlocal result result = front + back front = back back = result return front, back, result return nacci # 시작 값 입력 0,1 c = fibo(0,1) # 10번만 돌려보자 for i in range(0,10): pri.. 2021. 5. 13.
[python] Collection과 Dictionary와 Hash와 Key-Value docs.python.org/3/library/collections.html#collections.Counter collections — Container datatypes — Python 3.9.5 documentation collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. namedtuple() factory f docs.python.org # 이.. 2021. 5. 13.