728x90

CS 31

[AI 개념 정리] 1. 선형회귀

[AI 개념 정리] 1. 선형회귀 머신러닝 시스템은 한 번도 본 적 없는 데이터로부터 의미 있는 예측을 생산하기 위해 입력값들을 어떻게 조합할지 배웁니다. 손실함수를 최적화하여 문제 상황에 가장 적합한 모델 파라미터를 찾아 모델을 완성시키는 것이 주목적입니다. [기본 용어] Feature : 입력변수 (x 변수) Label : 예측대상 (y 변수) Model : 모델은 Feature와 Label 간의 관계를 정의 Example : data 특정 예시, model을 train 하기 위해 사용 Training : 모델을 만들거나 학습한다. 모델에게 labeled 된 example을 제공하고, 모델이 feature와 label 사이 관계 학습 Inference : 추론, unlabeled 된 example들에..

CS/AI 2023.07.21

[ 자료구조 ] level order iterative inorder tree traversal

[ 자료구조 ] level order iterative inorder tree traversal 1. 반복적 중위 탐색(inorder traversal) 알고리즘 트리 탐색을 꼭 순환 알고리즘으로 작성해야 하는 것은 아니다. 아래 예는 중위 탐색 알고리즘을 반복적인 알고리즘으로 작성한 것이다. 각 노드를 방문하면서 과거 노드를 LIFO 순으로 기억해야 하기 때문에 스택을 사용하였다. void iter_inorder(tree_ptr node){ int top = -1; tree_ptr stack[MAX_STACK_SIZE]; while(1){ while(node){ push(&top, node); node = node->left_child; } node = pop(&top); if(!node) break;..

CS/자료구조 2021.11.29

[ 자료구조 ] inorder preorder postorder traversal 탐색 알고리즘

[ 자료구조 ] inorder preorder postorder traversal 탐색 알고리즘 1. 중위 탐색 (inorder traversal) 알고리즘 , 왼나오 중위 탐색 트리 알고리즘은 순환 알고리즘이 간단하다. void inorder(tree_ptr ptr) { if(ptr) { inorder(ptr->left_child); printf(“%d”,ptr->data); inorder(ptr->right_child); } } 2. 전위 탐색 (preorder traversal) , 나왼오 순환 알고리즘이다, 전위 탐색으로 모든 트리를 탐색한다. void inorder(tree_ptr ptr) { if(ptr) { printf(“%d”,ptr->data); inorder(ptr->left_child..

CS/자료구조 2021.11.28

[ 자료구조 ] Tree Linked List로 구현하기 (2)

[ 자료구조 ] Tree Linked List로 구현하기 (2) #include #include struct tnode { int data; struct tnode* left_child; struct tnode* right_child; }; typedef struct tnode node; typedef node* tree_ptr; int main(){ int i; tree_ptr head = NULL, temp = NULL; temp = (tree_ptr)malloc(sizeof(node)); temp->data = 0; temp->left_child = NULL; temp->right_child = NULL; head = temp; tree_ptr head = NULL, temp = NULL; temp..

CS/자료구조 2021.11.27

[ 자료구조 ] Tree Linked List로 구현하기 (1)

[ 자료구조 ] Tree Linked List로 구현하기 (1) #include #include struct tnode{ int data; struct tnode * left_child; struct tnode * right_child; }; typedef struct tnode node; typedef node * tree_ptr; tree_ptr insert(tree_ptr head, int * number){ tree_ptr tnodes[5]; tree_ptr temp = NULL; for(int i = 0; idata = number[i]; tnodes[i]->left_child = tnodes[i]->right_child = NULL; } head = tnodes[0]; tnodes[0]->le..

CS/자료구조 2021.11.26

[ 자료구조 ] linked list 원형 연결 리스트 이중 연결 리스트

[ 자료구조 ] linked list 원형 연결 리스트 이중 연결 리스트 linkedlist에서 뒤의 노드를 읽는 것은 링크로 연결해줘야 하기 때문에 읽기, 삭제하기, 삽입하기가 어렵다. 이를 개선하기 위해 원형 연결 리스트와 이중 연결 리스트가 등장했다. 연결 리스트의 데이터 개수가 n개 일 때 n번의 링크를 따라가야 한다 => O(n) 원형 연결 리스트 원형 연결 리스트 : 연결 리스트의 맨 끝 노드를 첫 번째 노드와 연결시켜 원형으로 만든 리스트이다. 맨 끝 링크는 맨 앞 노드를 가리킨다. 포인터는 맨 끝 노드를 가리킨다. => 맨 끝과 맨 앞을 바로 찾을 수 있다. 단순 원형 리스트 삽입 삭제 맨 처음 O(1) O(1) 맨 마지막 O(1) O(n) 원형 연결 리스트의 맨 뒤에 노드를 삽입하는 알고..

CS/자료구조 2021.11.03
728x90