Code Monkey home page Code Monkey logo

2020.spring.datastructure's Introduction

2020학년도 자료구조

  • 2020-1학기 지능기전공학부 자료구조

공지사항

  • 아래 정리된 동영상 및 파일에 문제가 있다면 [email protected] 로 신고해주세요.

강의계획서

주차 수업내용 수업구분 강의노트 수업영상 과제마감
1 수업소개 이론 PDF Youtube
1 VS사용법
(디버깅/메모리누수)
실습 X Youtube
2 C언어복습-포인터 이론 PDF Youtube
Youtube
2 C언어복습-문자열 이론 PDF Youtube
Youtube
2 C언어복습-구조체 이론 PDF Youtube
Youtube
2 C언어복습-동적할당 이론 PDF Youtube
2 C언어복습-문제풀이 실습 PDF OJ 03/22
3 알고리즘 분석 이론 PDF Youtube
Youtube
3 알고리즘 분석 실습 PDF OJ 04/05
4 재귀 이론 PDF Youtube
4 재귀 실습 PDF OJ 04/14
5 기초 데이터 구조 이론 PDF Youtube
5 기초 데이터 구조 실습 PDF OJ 04/14
6 리스트(1) 이론 PDF Youtube
Youtube
6 리스트(1) 구현 집합(구현) 비디오 참고
6 리스트(1) 실습 PDF OJ 04/19
7 리스트(2) 이론 PDF Youtube
Youtube
Youtube
Youtube
Youtube
7 리스트(2) 실습 PDF OJ 04/26
8 퀴즈 실습 PDF OJ
9 중간고사 이론/실습 PDF 05/06
10 집합 이론 PDF Youtube
Youtube
10 집합 구현 Youtube
Youtube
10 집합 실습 PDF OJ 05/16
11 스택(1) 이론 PDF Youtube
11 스택(1) 구현 Youtube
11 스택(1) 실습 PDF OJ 05/31
12 스택(2) 이론 PDF Youtube
12 스택(2) 구현 Youtube
Youtube
12 스택(2) 실습 PDF OJ 05/31
13 큐(1) 이론 PDF Youtube
13 큐(1) 구현 Youtube
13 큐(1) 실습 PDF OJ 06/07
14 큐(2) 이론 PDF Youtube
Youtube
14 큐(2) 구현 Youtube
15 트리 이론 PDF Youtube
Youtube
15 트리 구현 PDF Youtube
Youtube
Youtube
Youtube
Youtube
15 트리 실습 PDF
PDF
PDF
OJ 06/21
16 기말고사 이론/실습 PDF 06/24

2020.spring.datastructure's People

Contributors

jo-won avatar unizard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2020.spring.datastructure's Issues

[참고] 4주차 실습(배열) 문제 2

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main()
{
    int x[100], N, n, y[100];
    int tmp1,tmp2, a, b, k;    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &x[i]);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &y[i]);
    tmp1 = x[y[0]];
    for (int i = 1; i < n - 1; i++)
    {
        tmp2 = x[y[i]];
        x[y[i]] = tmp1;
        tmp1 = tmp2;
    }
    x[y[0]] = tmp1;
    for (int i = 0; i < N; i++) printf(" %d", x[i]);

    return 0;
}

// 19011851 

[강의수강] 강의를 다 들었는데도 출석 인정이 안돼요

문의 내용

  • Q: 일부 영상에서 출석인정이 되지 않습니다. 블랙보드에 올라온 해결 방법으로 여러 번 들어보았지만 출석 인정이 되지 않습니다.
  • A: 해당 문제는 수업 관리자가 해결할 수 없는 문제입니다.

(추가 2020.03.23)

  • 온라인 수업 관리 안내 사항 중 출석 인정을 위한 수동 조작은 금지하고 있으므로 현재 상태에서 도와드릴 수 있는 방법이 없습니다.

[참고] 3주차 실습(재귀) 문제 7

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int check(char str[], char c)
{
    if (*str == '\0') return 0;

    if (*str == c) return check(str + 1, c) + 1;
    else return check(str + 1, c);
}

int main(void)
{
    char str[101];
    char c;

    scanf("%s", str);
    getchar();
    scanf("%c", &c);

    printf("%d",check(str, c));
}

// 14011615 

[참고] 3주차 실습(재귀) 문제 1

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int sum(int N)
{
    if (N == 1) return 1;
	
    return N + sum(N - 1);
}

int main(void)
{
    int N = 0; 
    scanf("%d", &N);

    printf("%d", sum(N));
}

// 14011615

[참고] 2주차 실습(분석) 문제 1

#include<stdio.h>
int modulo(int a, int b);

int main() {
	int a, b;
	scanf("%d%d",&a,&b);
	printf("%d",modulo(a,b));
	return 0;
}

int modulo(int a, int b) {
	while (a >= b) a = a - b;
	return a;
}

// 18011499

[참고] 2주차 실습(분석) 문제 3

#include <stdio.h>
#include <string.h>
#pragma warning (disable:4996)

int* prefixAverages1(int* x, int N)
{
    int* a = NULL;
    double sum = 0; int i;
    a = (int*)calloc(N, sizeof(int));
    for (i = 0; i < N; i++)
    {
        sum = 0;
        for (int j = 0; j <= i; j++) sum += x[j];
        a[i] = sum / (i + 1) + 0.5;
    }
    return a;
}

int* prefixAverages2(int* x, int N)
{
    int* a = NULL;
    double sum = 0; int i;
    a = (int*)calloc(N, sizeof(int));
    for (int i = 0; i < N; i++)
    {
        sum += x[i];
        a[i] = sum / (i + 1) + 0.5;
    }
    return a;
}

int main()
{
    int N;
    int* x = NULL;
    scanf("%d", &N);
    x = (int*)calloc(N, sizeof(int));
    for (int i = 0; i < N; i++) scanf("%d", x + i);

    for (int i = 0; i < N; i++) printf("%d ", prefixAverages1(x, N)[i]);
    printf("\n");
    for (int i = 0; i < N; i++) printf("%d ", prefixAverages2(x, N)[i]);

    return 0;
}

// 19011851

[참고] 6주차 실습(연결리스트) 문제 2

#pragma warning(disable:4996)
#include <stdio.h>
#include<stdlib.h>

typedef struct poly {
    int coef, exp; 
    struct poly* next;
}poly;

void appendTerm(poly *k, int c, int e) {
    poly *t = (poly*)malloc(sizeof(poly));
    t->coef = c;
    t->exp = e;
    t->next = k->next;
    k->next = t;
}

void deletion(poly* k) {
    poly *t, *temp;
    t = k;
    temp = t;
    while (t != NULL) {
        temp = temp->next;
        free(t);
        t = temp;
    }
}

poly* addPoly(poly *x, poly *y) {
    poly *result, *i, *j, *k;
    int sum;

    result = (poly*)malloc(sizeof(poly));
    result->next = NULL;

    i = x->next;
    j = y->next;
    k = result;
    while (i != NULL && j != NULL) {
        if (i->exp < j->exp) {
            appendTerm(k, i->coef, i->exp);
            i = i->next;
        }
        else {
            if (i->exp > j->exp) {
                appendTerm(k, j->coef, j->exp);
                j = j->next;
            }
            else {
                sum = i->coef + j->coef;
                if (sum != 0) {
                    appendTerm(k, sum, i->exp);
                }
                i = i->next;
                j = j->next;

            }
        }
    }

    while (i != NULL) {
        appendTerm(k, i->coef, i->exp);
        i = i->next;
    }
    while (j != NULL) {
        appendTerm(k, j->coef, j->exp);
        j = j->next;
    }

    return result;
}

int main() {
    poly *x=NULL, *y=NULL, *result, *j, *k;
    x = (poly*)malloc(sizeof(poly));
    y = (poly*)malloc(sizeof(poly));
    x->next = NULL;
    y->next = NULL;

    int i, n,c,e;

    scanf("%d", &n);
    for (i = 0;i < n;i++) {
        scanf("%d %d", &c, &e);
        appendTerm(x, c, e);
    }

    scanf("%d", &n);
    for (i = 0;i < n;i++) {
        scanf("%d %d", &c, &e);
        appendTerm(y, c, e);
    }
    result = addPoly(x, y);
    k = result->next;
    while (k != NULL) {
        printf("%d %d\n", k->coef, k->exp);
        k = k->next;
    }

    k = result->next;
    deletion(k);
    k = x->next;
    deletion(k);
    k = y->next;
    deletion(k);
}

// 19011845 

[참고] 3주차 실습(재귀) 문제 2

#include <stdio.h>

void rprint(int n){
    if (n < 10) printf("%d\n", n%10);
    else {
        rprint(n/10);
        printf("%d\n", n%10);
    }
}

int main(void) {

    int N;
    scanf("%d", &N);

    rprint(N);

}

// 17011836

[참고] 4주차 실습(배열) 문제 5

#include <stdio.h>

int main (void) {
    int N, M, X[100][100]={0}, cnt=1;

    scanf("%d %d", &N, &M);

    for(int i = 0 ; i < M ; i++){
        for(int j = 0, k = i ; j < i+1 && j < N ; j++, k--){
            if (X[j][k] != 0) cnt+=0;
            else {
                X[j][k] = cnt ; cnt++;
            }
        }
    }

    for(int i = 1 ; i < N+1 ; i++){
        for(int j = i, k = M-1 ; j < N && k >= 0 ; j++, k--){
            if (X[j][k] != 0) cnt+=0;
            else {
                X[j][k] = cnt ; cnt++;
            }
        }
    }


    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            printf(" %d", X[i][j]);
        }
        printf("\n");
    }

}

// 17011836 

[참고] 3주차 실습(재귀) 문제 3

#include <stdio.h>

void rprint(int n){
    if (n < 10) printf("%d\n", n%10);
    else {
        printf("%d\n", n%10);
        rprint(n/10);
		
	}
}

int main(void) {

    int N;
    scanf("%d", &N);

    rprint(N);

}

// 17011836 

[참고] 3주차 실습(재귀) 문제 4

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int total_max(int IN[], int n)
{

    if (n > 0)
    {
        int max = 0;
        int max_index = 0;
        int tmp = 0;

        for (int i = 0; i < n; i++)
        {
            if (max < IN[i])
            {
                max = IN[i];
                max_index = i;
            }
        }

        tmp = IN[n - 1];
        IN[n - 1] = max;
        IN[max_index] = tmp;

        if (total_max(IN, n - 1) < max) return max;
        else return total_max(IN, n - 1);
    }
    else
    {
        return IN[n];
}


}

int main(void)
{
    int N = 0;
    int IN[20] = { 0 };
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &IN[i]);
    }
    printf("%d", total_max(IN, N));
}

// 14011615 

OJ 시스템 문제 및 해결방법

개요

Online Judge 시스템은 중앙 관리자가 일괄적으로 관리하고, 지속적으로 피드백을 받으므로 정답이 틀릴 가능성은 거의 없습니다.

문의 들어온 이슈

  • Q: 정답을 제출했는데 엉뚱한 답이 나오면서(ex. 이전 문제의 정답 등) 답이 틀렸다고 나옵니다.
  • A: Sample Submit 으로 제출했는지 확인 해주세요.

[참고] 4주차 실습(배열) 문제 1

#pragma warning(disable:4996)
#include <stdio.h>
void swap(int X[], int a, int b) {
    int tmp, i;

    for (i = 0;i < (b - a) / 2 + 1;i++) {
        tmp = X[a + i];
        X[a + i] = X[b - i];
        X[b - i] = tmp;
    }
}
	

int main() {
    int N, X[100], M, a, b, i;

    scanf("%d", &N);

    for (i = 0;i < N;i++)scanf("%d", X + i);
    scanf("%d", &M);

    for (i = 0;i < M;i++) {
        scanf("%d %d", &a, &b);
        swap(X, a, b);
    }

    for (i = 0;i < N;i++)printf(" %d", *(X + i));
}

// 19011845 

[참고] 4주차 실습(배열) 문제 4

#include <stdio.h>

int main (void) {
    int N, M, X[100][100]={0}, cnt=1;

    scanf("%d %d", &N, &M);

    for(int i = 0 ; i < N ; i++){

        for(int j = i ; j < M-i ; j++){
            if (X[i][j] != 0) cnt+=0;
            else {
                X[i][j] = cnt ; cnt++;
            }
        }

        for(int j = 1+i ; j < N-i ; j++){
            if (X[j][M-i-1] != 0) cnt+=0;
            else {
                X[j][M-i-1] = cnt ; cnt++;
            }
        }

        for(int j = M-i-1 ; j > i-1 ; j--){
            if(X[N-i-1][j] != 0) cnt+=0;
            else {
                X[N-i-1][j] = cnt ; cnt++;
            }
        }

        for(int j = N-i-1 ; j > i-1 ; j--){
            if(X[j][i] != 0) cnt+=0;
            else {
                X[j][i] = cnt ; cnt++;
            }
        }
        
    }

    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            printf(" %d", X[i][j]);
        }
        printf("\n");
    }

}

// 17011836 

[참고] 5주차 실습(연결리스트) 문제 1

#pragma warning(disable:4996)
#include <stdio.h>
#include<stdlib.h>
typedef struct Node {
    char elem;
    struct Node *prev, *next;
}Node;

void Clear(Node *H) {
    Node *t, *temp;
    t = H;
    temp = t;
    while (t != NULL) {
        temp = temp->next;
        free(t);
        t = temp;
    }
}

void add(Node *H, int r, char e, int *n) {
    if (r<1 || r>*n)printf("invalid position\n");
    else {
        int i;
        Node *p,*q, *newNode=(Node*)malloc(sizeof(Node));
        newNode->elem = e;
        p = H;

        for (i = 1;i <= r;i++) {
            p = p->next;
        }
        q = p->prev;
        q->next = newNode;
        
        newNode->prev = p->prev;
        p->prev = newNode;
        newNode->next = p;

        *n= *n +1;
    }
}

void print(Node *H) {
    Node *p;
    p = H->next;
    while(p->next!=NULL) {
        printf("%c", p->elem);
        p = p->next;
    }
    printf("\n");
}

void deletion(Node *H, int r, int *n) {
    if (r < 1 || r>*n - 1)printf("invalid position\n");
    else {
        Node *p, *q;
        int i;

        p = H;
        for (i = 1;i <= r;i++) {
            p = p->next;
        }
        q = p->prev;
        q->next = p->next;
        q = p->next;
        q->prev = p->prev;

        free(p);

        *n = *n - 1;
    }
}

void get(Node *H, int r, int n) {
    if (r < 1||r>n-1)printf("invalid position\n");
    else {
        Node *p;
        int i;
        p = H;

        for (i = 0;i < r;i++) {
            p = p->next;
        }
        printf("%c\n", p->elem);
    }
}

int main() {
    Node *H, *T;
    char e, p;
    int n = 1, i, m, r;
    H = (Node*)malloc(sizeof(Node));
    T = (Node*)malloc(sizeof(Node));
    H->next = T;
    T->prev = H;
    H->prev = NULL;
    T->next = NULL;
    scanf("%d", &m);getchar();

    for (i = 0;i < m;i++) {
        scanf("%c", &p); getchar();
        if (p == 'A') {
            scanf("%d %c", &r, &e); getchar();
            add(H, r, e, &n);
        }
        if (p == 'D') {
            scanf("%d", &r); getchar();
            deletion(H, r, &n);
        }
        if (p == 'G') {
            scanf("%d", &r); getchar();
            get(H, r, n);
        }
        if (p == 'P')print(H);
    }
    Clear(H);
}

// 19011845 

[참고] 3주차 실습(재귀) 문제 5

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int rHanoi(int n, char from, char aux, char to)
{
    if (n == 1)
    {
        printf("%c %c\n", from, to);
        return 0;
    }

    rHanoi(n - 1, from, to, aux);

    printf("%c %c\n", from, to);

    rHanoi(n - 1, aux, from, to);

    return 0;
}


int main(void)
{
    int n = 0;
    scanf("%d", &n);
    rHanoi(n, 'A', 'B', 'C');

    return 0;
}

// 14011615 

[참고] 4주차 실습(배열) 문제 3

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main()
{
    int x[100][100];
    int N, i, a = 0, b = 0;
    scanf("%d", &N);
    for (i = 1; i <= N * N; i++)
    {
        x[a][b] = i;
        if (i % N == 0) a++;
        else
        {
            if (a % 2 == 0) b++;
            else b--;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++) printf(" %d", x[i][j]);
        printf("\n");
    }
    return 0;
}

// 19011851 

강의 동영상 재생 위치

문의 내용

  • Q: 동영상 강의는 어디서 볼 수 있나요?
  • A: 동영상의 경우 블랙보드 (수업 -> 강의자료 및 학습 -> 1주차)에서 확인하시면 됩니다. 기본적으로 동영상은 수업일을 기준 으로 업로드가 됩니다. GitHub의 경우 강의 자료 등이 업로드 될 예정이며, 질문 사항도 issues 탭을 활용해서 물어보시면 됩니다.

[참고] 2주차 실습(분석) 문제 2

#include<stdio.h>
#include<stdlib.h>

int mostOnes(int **p, int n);

int main() {
	int n, **p=NULL;
	int i, j;
	scanf("%d",&n);
	p = (int **)malloc(sizeof(int *)*n);
	for (i = 0; i < n; i++) {
		p[i] = (int *)malloc(sizeof(int)*n);
		for (j = 0; j < n; j++) scanf("%d",&p[i][j]);
	}
	printf("%d", mostOnes(p, n));
	for (i = 0; i < n; i++) free(p[i]);
	free(p);
	return 0;
}

int mostOnes(int **p, int n) {
	int i = 0, j = 0, max = 0;
	while (i < n && j < n) {
		if (p[i][j] == 1) {
			max = i;
			j++;
		}
		else i++;
	}
	return max;
}

// 18011499

[참고] 3주차 실습(재귀) 문제 6

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int ab(int a, int b)
{
    if (a == 0) return b;
    else if (b == 0) return a;

    return ab(b, a % b);
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    if (n > m) printf("%d", ab(n, m));
    else printf("%d", ab(m, n));
    
    return 0;
}

// 19011851 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.