CS Study/Data Structure (2) 썸네일형 리스트형 Project 2 : Heap Implementation #코드 설명 # HEAP createHeap() 1. HEAP h라는 포인터 변수에 메모리를 할당한다. 2. h의 ADT value 중에 integer value인 size는 0으로, integer array pointer인 heapData는 100의 사이즈를 갖도록 초기화한다. 3. HEAP h를 return 한다. # void makeHeap(int arr[], int i, int size) 1. arr[i]의 left child는 arr의 2*i + 1번째 index, right child는 arr의2*i + 2번째 index로 선언한다. 2. arr[i]와 arr[i]의 left child, right child 중 가장 큰 값의 index를 largest라고 선언한다. 3. arr[i]가 가장 .. Project 1 : LinkedList / Stack Implementation #코드 설명 # struct linked_list* create_list(int number_of_nodes, int list_type) 1-1. input value인 number_of_nodes가 1보다 작으면 에러 메시지를 출력한다. 1-2. 전역 변수 list_exist가 1이라면 이미 리스트가 존재한다는 뜻이기 때문에, 에러 메시지를 출력한다. 1-3. input value인 list_type이 0 또는 1이 아니라면, list의 type을 정할 수 없기 때문에, 에러 메시지를 출력한다. 2. new_list라는 포인터 변수에 메모리를 할당하고 new_list의 ADT value들을 초기화한다. 3. new_list에 list_type value에 따라서 1부터 number_of_nodes까지의.. 이전 1 다음