-
전위순회(preorder), 중위순회(inorder), 후위순회(postorder) 요약
코드로 간단히 설명하면 func(Node* root) { print(root->value); //preorder func(root->left); print(root->value); //inorder func(root->right); print(root->value); //postorder } 말로 풀어서 설명하면, root 노드부터, 왼쪽 노드, 오른쪽 노드는 preorder, 왼쪽 노드부터, root 노드, 오른쪽 노드는 inorder, 왼쪽 노드부터, 오른쪽 노드, root 노드는 postorder. 그림으로 설명하면 위와 같은 그림이 있을 때, preorder: 0 1 2...
-
(C++) AVL Tree concepts and implementation - Insertion
What is AVL tree? AVL tree is represented as a prefix alphabet of the person who wrote the report related to it. It is a tree to maintain the balance in the BST(Binary Search Tree). Basic concepts Binary Search Tree could be unbalanced, depending on inserting order. For example, Let...
-
(ALGO) 백준 1158 문제 - 조세퍼스 문제
순환 단방향 링크드 리스트를 사용해서 풀면 된다. 시간 복잡도는 N번 반복문을 돌며 M번 참조하는 연산을 하므로 O(NM)인데, 1<=M<=N<=5000 이라는 조건이 주어졌으므로 충분히 풀 수 있다. 공간 복잡도는 O(N)이다. 이 문제를 풀며 역시 리스트는 그림을 그리며 푸는게 최고라는 생각이 들었다.. 아래는 소스. #include <iostream> using namespace std; class Node { public:...
-
(python) multithreading과 multiprocessing 요약
프로세스(Process)와 스레드(Thread) 프로세스(Process) 실행되고 있는 프로그램의 인스턴스. CPU 시간이나 메모리 등의 시스템 자원이 할당되는 독립적인 개체이다. 프로세스 간 자원을 공유할 때, context switching 때문에 발생하는 오버헤드(overhead)가 상대적으로 더 크다. context switching: 문맥 교환(Context Switch)이란 하나의 프로세스가 CPU를 사용 중인 상태에서 다른 프로세스가 CPU를 사용하도록 하기 위해, 이전의 프로세스의 상태(문맥)를 보관하고...
-
How to select option in selenium webdriver using python
At first, I tried to click the option like this: select_elem = driver.find_element_by_xpath("//select[@name='" + select_name + "']") select_elem.click() option_elem = select_elem.find_element_by_xpath("./option[contains(text(),'" + option_text + "')]") option_elem.click() or select_elem = driver.find_element_by_xpath("//select[@name='" + select_name + "']") for option in select_elem.find_elements_by_tag_name('option'): if option.text == option_text: option.click() ## select() in earlier versions of webdriver...