C - 부분집합 비트마스크 이용
2018.03.12 by 노아론
큐를 통한 미로찾기(최단거리)
2018.01.17 by 노아론
큐 연결리스트. 배열구현
2018.01.16 by 노아론
여러개의 스택 구현
2018.01.15 by 노아론
스택, 배열|링크드리스트 구현과 문제점
2018.01.14 by 노아론
부분집합 생성 #include void main(void) { int i,j; int arr[] = {3,6,7,1,5,4}; int n = sizeof(arr)/sizeof(arr[0]); // n: 원소 갯수 for(int i=0;i
PS/자료구조 2018. 3. 12. 14:34
큐 구현 큐를 통한 미로찾기(최단거리) 하나의 큐를 만든다. 위치 (0,0)은 이미 방문한 위치임을 표시 큐가 빌 때까지 4를 반복한다. 1. 큐에서 하나의 위치p를 꺼낸다. 2. p에서 한 칸 떨어진 위치들 중에서 이동 가능하면서 아직 방문하지 않은 모든 위치들을 방문된 위치임을 표시하고 큐에 넣는다. 3. 만약 그 위치가 출구라면 종료한다. Queue queue = create(); Position cur; cur.x=0; cur.y=0; enqueue(queue,cur); maze[0][0]=-1; bool found=false; while(!is_empty(queue)) { Position cur=dequeue(queue); for(int dir=0;dir
PS/자료구조 2018. 1. 17. 12:21
큐 구현 큐 연결리스트 구현 Front(삭제) 가 오른쪽에 위치하면 삭제를 할때의 이전노드를 매번 알고있어야하므로 불편함. 삽입을 위해선 마지막노드(Rear)의 주소를 알아야 함. 큐 공간에서 front rear size 를 저장해둠 연결리스트를 통한 큐 구현 #include #include #include typedef int Item; typedef struct queue_type *Queue; Queue create(); void destory(Queue q); void make_empty(Queue q); bool is_empty(Queue q); void enqueue(Queue q,Item i); Item dequeue(Queue q); Item peek(Queue q); int get_siz..
PS/자료구조 2018. 1. 16. 15:06
스택 구현 스택, 배열로 구현 #include #include #include #include #define INIT_CAPACITY 100 typedef int Item; typedef struct stack_type *Stack; Stack create(); void destroy(Stack s); void make_empty(Stack s); bool is_empty(Stack s); bool is_full(Stack s); void push(Stack s,Item i); Item pop(Stack s); Item peek(Stack s); struct stack_type{ Item *contents; int top; int size; }; static void terminate(const char..
PS/자료구조 2018. 1. 15. 14:19
스택, 배열로 구현 #include #define MAX_CAPACITY 100 void push(char); char pop(); char peek(); int is_empty(); int is_full(); char stack[MAX_CAPACITY]; int top=-1; void push(char ch) { if(is_full()) //스택이 가득차면 push 불가, 이때의 경우를 알수있게 해야함 { return; } top++; stack[top]=ch; } char pop() //스택이 비어있는지 검사할것 { if(top==-1) { return NULL; } char tmp=stack[top]; top--; return tmp; } char peek() //pop과는 다르다. 비우지않고 반환..
PS/자료구조 2018. 1. 14. 23:24
2020.05.08 11:17
2020.09.07 16:53
2020.02.13 20:18
2020.06.25 23:48
Back-end
카테고리 없음