일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- OS
- 북리뷰
- 너비우선탐색
- 그래프
- 코딩
- 백준
- 정석학술정보관
- 브루트포스
- Operating System
- 스택
- 컴공
- 구현
- 정석
- 코테
- 문제풀이
- cs
- Stack
- 오퍼레이팅시스템
- 오에스
- DP
- vector
- 알고리즘
- bfs
- 컴공과
- Computer science
- 자료구조
- 컴퓨터공학과
- coding
- c++
- 개발
- Today
- Total
목록알고리즘/DataStructure (6)
Little Jay
사실상 내가 쓰려고 만든 sort #include #define endl '\n' using namespace std; int arr[1000001]; void merge(int* data, int start, int mid, int end) { int n1 = mid - start + 1; int n2 = end - mid; int* left = new int[n1]; int* right = new int[n2]; //left와 right작업을 통해서 지정된 인덱스까지 배열 복사 for (int i = 0; i < n1; i++) { left[i] = data[start + i]; } for (int i = 0; i < n2; i++) { right[i] = data[mid + i + 1]; } int..
#include #include using namespace std; class Node { public: int data; Node* next; Node(int data) { this->data = data; this->next = NULL; } }; class LinkedList { public: Node* f; Node* r; LinkedList() { f = NULL; r = NULL; } ~LinkedList() { } int front() { return f->data; } int end() { return r->data; } void addBack(int data) { Node* n = new Node(data); if (f == NULL) { f = r = n; } else { r->nex..
처음 파트는 Linked List로 구현했다 남들은 array로 구현하는게 쉽다고 하는데 본인은 Linked List로 구현하는게 훨씬 쉽다고 느껴졌다 #include #include using namespace std; class Node { public: int data; Node* next; Node(int e) { this->data = e; this->next = NULL; } }; class LinkedList { public: Node* head; Node* tail; LinkedList() { head = NULL; tail = NULL; } ~LinkedList() { } int front() { return head->data; } void addFront(int e) { Node* n..
1. Circular Linked List 에서 임의의 Node 하나가 주어졌을 때, 이 List의 길이를 구하는 가장 효율적인 방법? 환영 링크드 리스트는 일반 링크드 리스트와 다르게 마지막에 있는 데이터의 next 주소값이 list의 front에 연결되어 있는 환영적인 구조이다. 따라서 임의의 노드가 주어졌을 때, 노드를 돌면서 같은 Node가 나올 때까지 list를 돌면 O(N)만에 구할 수 있을 것이다. 이때 값만 비교하는게 아니라 prev, next 주소값도 동일한 경우를 찾아야 할 것이다. 2. 중간에 만나는 두 LinkedList의 시작점이 주어졌을 때, 만나는 지점을 구하는 방법? 우선 두 list의 길이를 각각 구한다. 그 후 짧은 리스트를 두 리스트의 차이만큼 뒤로 밀고 길이를 맞춘다.
int형 LinkedList 데이터 타입은 바꾸거나 typedef로 지정을 해주거나 할 수 있다. 중간에 데이터를 넣는 것은 구현하지 않았다. #include #include using namespace std; class intNode { private: int dat; intNode* next; intNode(int x) { this->dat = x; this->next = NULL; } friend class intLinkedList; }; class intLinkedList { private: intNode* head; intNode* tail; public: intLinkedList() :head(NULL), tail(NULL) { } ~intLinkedList() {} void addFront..
#include #include using namespace std; class Array { public: int n; int* arr; Array(int size) { this->n = 0; this->arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = 0; } } void at(int i) { // return arr[i] if (arr[i] == 0) { // if arr[i] is null cout