본문 바로가기

문법13

이진트리(Binary Tree) 출처:https://www.mathwarehouse.com/programming/gifs/binary-search-tree.php#binary-search-tree-insertion-node) Understand Binary Search Tree through Gifs Binary Search Tree Degredation Gif Insertion of a node into Tree Description --> Binary Search Tree vs Sorted Array Animated Gif Comparing Sorted Array vs Binary Search Tree Description --> Optimal Binary Search Tree from Sorted Array Subtopic --.. 2023. 10. 25.
BFS(너비 우선 탐색) 스택을 이용하는 DFS와 달리 BFS는 반복 구조를 구현할 때 큐를 사용한다. 재귀로 구현 불가 큐를 이용하는 반복구현만 가능하다. graph = { 'A': ['B', 'C'], 'B': ['A', 'D'], 'C': ['A', 'G', 'H', 'I'], 'D': ['B', 'E', 'F'], 'E': ['D'], 'F': ['D'], 'G': ['C'], 'H': ['C'], 'I': ['C', 'J'], 'J': ['I'] } BFS 구현(큐 2개 사용) visited = deque() need_visited = deque() need_visited.append(list(graph.keys())[0]) 첫번째 키 값인 'A'를 먼저 방문이 필요한 큐에 넣어준다. while need_visited:.. 2023. 10. 23.
[Python]Deque Deque * 앞과 뒤에서 데이터를 처리할 수 있는 양방향 자료형 * stack(스택)처럼 써도 되고 queue(큐)처럼 써도 된다. * from colections import deque 추가해서 사용하면 된다. Deque 시간복잡도에 관해 Python 리스트와 Deque의 차이 * List 시간 복잡도 Average Case Amortized Worst Case Copy O(n) O(n) Append[1] O(1) O(1) Pop last O(1) O(1) Pop intermediate[2] O(n) O(n) Insert O(n) O(n) Get Item O(1) O(1) Set Item O(1) O(1) Delete Item O(n) O(n) Iteration O(n) O(n) Get Slice O.. 2023. 10. 19.
리눅스 명령어 ls(list) ls [옵션] + 파일/디렉토리 [옵션]내용 -a(all) 해당경로 or 지정경로에서 숨겨진 파일이나 디렉토리를 보여준다. -l(long) 자세한 내용을 출력한다. 소유자, 그룹, 파일크기, 수정일자, 파일이름 -h(human) K,M,G 단위를 사용하여 파일 크기를 사람이 보기 좋게 표시한다. [centos@ip-172-31-0-74 ~]$ ls -a . .aws .bash_logout .bashrc .rnd WC nlogger package .. .bash_history .bash_profile .pki .ssh install openssl prefix [centos@ip-172-31-0-74 ~]$ ls -l 합계 4 drwxrwxr-x. 3 centos centos 26 3월 4 .. 2023. 10. 18.