23.05.31
오늘 한 일
- 알고리즘 문제 풀이
- 블로그 글 업로드
- GDG 컨퍼런스
2023프론트엔드 트렌드 따라잡기
참여 - 알고리즘 시험 공부
블로그 글 업로드
드디어 블로그 글을 업로드 했다. 크롬 익스텐션 개발하면서 겪었던 트러블슈팅 경험과 회고를 작성했다. 블로그
알고리즘 시험 공부
원형큐 동적 배열
#include <stdio.h>
#include <stdlib.h>
#define QUEUE_SIZE 10
int *queue;
int front; // 전단
int rear; // 후단
int size = 1;
int isEmpty() {
if (front == rear) return 1;
else return 0;
}
// 큐가 포화 상태인지 확인하는 연산
int isFull() {
if (front == (rear + 1) % (QUEUE_SIZE * size)) return 1;
else return 0;
}
int queueSize() {
return(rear - front + (QUEUE_SIZE * size)) % (QUEUE_SIZE * size);
}
void enqueue(int item) {
if (isFull()) {
printf(" QUEUE\n");
int *temp = (int*)malloc((QUEUE_SIZE * size) * sizeof(int));
if (rear > front)
for (int i = 0; i < (rear + 1); i++) temp[i] = queue[i];
else {
for (int i = front; i < (QUEUE_SIZE * size); i++) temp[i - front] = queue[i];
for (int i = 0; i < (rear + 1); i++) temp[QUEUE_SIZE * size - (rear + 1) + i] = queue[i];
front = 0;
rear = QUEUE_SIZE * size - 1;
}
free(queue);
queue = (int*)malloc((QUEUE_SIZE * (size + 1)) * sizeof(int));
for (int i = 0; i < (rear + 1); i++) queue[i] = temp[i];
rear = (rear + 1) % (QUEUE_SIZE * (size + 1));
queue[rear] = item;
size++;
free(temp);
}
else {
rear = (rear + 1) % (QUEUE_SIZE * size);
queue[rear] = item;
}
}
int dequeue() {
if (isEmpty()) { // 큐가 공백 상태인 경우
printf("\n\n Queue is Empty!!\n");
return 0;
}
else
{
if (queueSize() % QUEUE_SIZE == 0)
{
printf(" DEQUEUE\n");
int re;
int *temp = (int*)malloc((QUEUE_SIZE * (size - 1)) * sizeof(int));
re = queue[front + 1];
if (rear > front)
for (int i = front + 1; i < rear; i++) temp[i - front] = queue[i + 1];
else {
for (int i = front; i < QUEUE_SIZE * size; i++) temp[i - front] = queue[i + 1];
for (int i = 0; i < (rear + 1); i++) temp[QUEUE_SIZE * (size - 1) - (rear + 1) + i] = queue[i];
}
free(queue);
queue = (int*)malloc((QUEUE_SIZE * (size - 1)) * sizeof(int));
for (int i = 0; i < QUEUE_SIZE * (size - 1); i++) queue[i] = temp[i];
front = 0;
rear = QUEUE_SIZE * (size - 1) - 1;
size--;
free(temp);
return re;
}
else {
front = (front + 1) % (QUEUE_SIZE * size);
return queue[front];
}
}
return 0;
}
// 큐의 원소를 출력하는 연산
void printQueue() {
int i, maxi = rear;
if (front >= rear) maxi += (QUEUE_SIZE * size);
printf("Queue size is [%2d]= ", queueSize());
for (i = front + 1; i <= maxi; i++)
printf("%2d ", queue[i % (QUEUE_SIZE * size)]);
printf("\n");
}
void main(void) {
int i;
queue = (int*)malloc(QUEUE_SIZE * sizeof(int));
for (i = 11; i < 30; i++) enqueue(i);
//printf("%d\n", queueSize());
printQueue();
for (i = 1; i < 4; i++) dequeue();
printQueue();
for (i = 1; i < 4; i++) enqueue(i);
printQueue();
for (i = 1; i < 11; i++) dequeue();
printQueue();
enqueue(90);
printQueue();
free(queue);
getchar();
}
트리
- AVL 트리
- 레드 블랙 트리
- 허프만 트리
그래프
- 프림 알고리즘
- 다익스트라 알고리즘
- A* 알고리즘
해시
- 더블 해싱
문자열 매칭
- 보이어 무어
내일 할 일
- 알고리즘 문제 풀이
- 바닐라 JS 리액트 스터디 내용 정리 및 참여
- 카공실록 작성 페이지 마무리 작업(react-hook-form 고려)
- 카공실록 회의