본문 바로가기

분류 전체보기

(274)
연결리스트를 이용한 다항식을 계산하고 사용자가 입력한 문자열을 파싱하는 Polynominal 코드 만들기 자료구조 수업에서 연결리스트를 이용한 다항식 계산 프로그램을 작성하라는 과제를 받았다. https://youtu.be/UviSUv21iB8 여기 유튜브에서 하는것과 비슷하게 만들면 될듯하다 기능 1. f = 5x 같은 문자열을 입력하면 f라는 Poly 클래스를 만들고 5x Term 클래스를 만들어 Poly에 연결한다. 2. f = 6x + 7x^2 같은 문자열을 한번 더입력하면 f 자리에 6x + 7x^2을 넣는다. 3. print f를 입력하면 f 함수를 출력한다. 4. calc f 2를 입력하면 f함수에 따른 2를 계산한 결과를 출력한다. 5. f = f + g를 입력하면 함수 f와 g를 계산한 함수를 저장한다. 연결리스트를 이용하여 메모리가 가능한 한도내에 무제한으로 저장할 수 있도록 만든다. 자바..
선형덱 #include #include #define MAX_QUEUE_SIZE 100 int data[MAX_QUEUE_SIZE]; int front; int rear; void init_queue() { front = rear = 0; } void add_rear(int val) { enqueue(val); } int delete_front() { return dequeue(); } int get_front() { return peek(); } int is_empty() { return front == rear; } int is_full() { return front == (rear + 1) % MAX_QUEUE_SIZE; } int size() { return (rear - front + MAX_QUEUE..
선형큐 #include #include #define MAX_QUEUE_SIZE 100 int data[MAX_QUEUE_SIZE]; int front; int rear; void init_queue() { front = rear = 0; } int is_empty() { return front == rear; } int is_full() { return front == (rear + 1) % MAX_QUEUE_SIZE; } int size() { return (rear - front + MAX_QUEUE_SIZE) % MAX_QUEUE_SIZE; } void enqueue(int val) { if (!is_full()) { rear = (rear + 1) % MAX_QUEUE_SIZE; data[rear] =..
연결된큐 #include #include #define MAX_QUEUE_SIZE 100 typedef struct LinkedNode { int data; struct LinkedNode* link; } Node; Node* front = NULL; Node* rear = NULL; void init_queue() { front = rear = NULL; } int is_empty() { return front == NULL; } int size() { Node* p; int count = 0; for (p = front; p != NULL; p = p->link) count++; return count; } void enqueue(int val) { Node* p = (Node*)malloc(sizeof(No..
이것이 자바다 11장 확인 문제 답 - 신용권의 Java 프로그래밍 정복 Object 클래스에 대한 설명 중 틀린 것은 무엇입니까? 4번 괄호 안을 채워보세요 hashCode(), equals() 해시코드를 리턴하세요 public class Student { private String studentNum; public Student(String studentNum) { this.studentNum = studentNum; } public String getStudentNum() { return studentNum; } @Override public boolean equals(Object obj) { if(obj instanceof Student) { Student student = (Student) obj; if(studentNum.equals(student.getStuden..
연결리스트 스택 #define _CRT_SECURE_NO_WARNINGS #include #include typedef int Element; typedef struct { Element data; Node* link; }Node; Node* top = NULL; void error(const char str[]) { printf("%s\n", str); exit(1); } void init_stak() { top = NULL; } int is_empty() { return top == NULL; } int size() { Node* p; int count = 0; for (p = top; p != NULL; p = p->link) { count++; } return count; } void push(Element e)..
두근두근 자료구조 3장 (스택) 연습문제 문자 A, B, C, D, E를 스택에 넣었다가 다시 꺼내어 출력하면 어떻게 되는가? 2. E, D, C, B, A 10, 20, 30, 40, 50을 스택에 넣었다가 3개의 항목을 삭제하였다. 남아 있는 항목은? 10, 20 스택에서 사용되는 정보의 입출력 방법은 무엇인가? 1. LIFO 다음 중 스택에 대한 올바른 설명을 모두 골라라. 3. 함수 호출시 복귀 주소를 저장하는데 사용된다. 4. 배열을 사용하여 구현할 수 있다. 다음 중 배열로 구현된 스택에서 공백상태에 해당하는 조건은? 또 포화상태에 해당되는 조건은? 1. top == -1 3. top == MAX_STACK_SIZE - 1 배열로 구현된 스택에 항목들을 삽입하고 삭제하는 연산은 시간 복잡도가 어떻게 되는가? o(1) 순서가 A, B,..
배열 스택 #include #include #define MAX_STACK_SIZE 100 typedef int Element; Element data[MAX_STACK_SIZE]; int top; void error(const char str[]) { printf("%s\n", str); exit(1); } void init_stak() { top = -1; } int is_empty() { return top == -1; } int is_full() { return top == MAX_STACK_SIZE - 1; } int size() { return top + 1; } void push(Element e) { if (is_full) error("스택 포화 에러"); data[++top] = e; } Eleme..