본문 바로가기

C++197

[Linear Data] Chapter 05. 오른손 법칙 개선 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/32793def2975e48222abcbbe66d53fed33f5b49d 오른손 법칙 개선 · developeSHG/Data_Structure-Algorithm@32793de developeSHG committed Aug 8, 2023 github.com 이전 카테고리인 Maze(미로)를 만들었을 때, 길찾기 알고리즘으로 오른손 법칙을 이용했다. 하지만 아쉬운 점은 막힌 길을 굳이 갈 필요가 없음에도 불구하고, 우수법 특성상 막힌 길에 들어갔다 다시 나온다는 것이 비효율적이다. 최단 거리까진 아니라도 불필요하게 이동하는 현상을 예방할 수 없을까 생각이 드는데, 이전에 학습한 s.. 2023. 8. 7.
[Linear Data] Chapter 04. 큐 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/c944c3b8377426e722f4c3cf296d00c6b62db56c 큐(Array, List) 구현 · developeSHG/Data_Structure-Algorithm@c944c3b developeSHG committed Aug 7, 2023 github.com Queue는 선입선출 구조다. 큐를 구현할 때, 데이터의 삽입은 뒤에서 추가되고, 삭제는 맨 앞에서 일어난다. 이럴 때, 데이터 복사로 인해 삽입/삭제 속도가 느린 vector보다 단순 node 끼리 연결된 list가 유용하다. 하지만, vector로 구현할 수 있는 방법이 아예 없는 건 아니다. 생각을 바꿔서,.. 2023. 8. 7.
[Linear Data] Chapter 03. 스택 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/a95915725879968c437ae898c1458fe69dca2927 스택 구현 · developeSHG/Data_Structure-Algorithm@a959157 developeSHG committed Aug 7, 2023 github.com stack은 맨 뒤에다가 데이터를 밀어넣고 꺼내오는 방식이기 때문에, vector를 이용해서 만들 수 있겠다 생각이 든다. 즉, stack도 동적 배열로 만드는 방식과 연결 리스트로 만드는 방식 둘 다 공존한다. 중요한 부분은 맨 뒤 데이터의 작업을 지원하면 되기 떄문에 어떤 자료구조든 stack으로 활용할 수 있다. C# 방식 데이.. 2023. 8. 7.
[Linear Data] Chapter 02. 연결 리스트 구현 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/9590b4df8605e6f46bf862345586cc7b1b701779 연결 리스트 구현 · developeSHG/Data_Structure-Algorithm@9590b4d developeSHG committed Aug 7, 2023 github.com 연결 리스트 : - 연속되지 않은 메모리를 사용 장점 : 중간 삽입/삭제 이점 단점 : N번째 데이터를 바로 찾을 수 없음 (임의 접근 Random Access 불가) list는 노드로 이루어져 중간 삽입/삭제가 빠르기 때문에 push_front도 존재하지만, vector의 경우는 push_front가 없고, push_back.. 2023. 8. 7.
[Linear Data] Chapter 01. 동적 배열 구현 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/2e1fffb765ff77ea1e260e027e2d0a23d81f7f73 동적배열(Vector) 구현 · developeSHG/Data_Structure-Algorithm@2e1fffb developeSHG committed Aug 7, 2023 github.com 선형 구조는 자료를 순차적으로 나열한 형태 - 배열 - 연결 리스트 - 스택 / 큐 비선형 구조는 하나의 자료 뒤에 다수의 자료가 올 수 있는 형태 - 트리 - 그래프 배열 VS 동적 배열 VS 연결 리스트 { 배열 : - 사용할 데이터를 고정해서 할당하고 (절대 변경 불가) - 연속된 메모리를 배정받아 사용 장점 .. 2023. 8. 7.
[Programmers] (2020 KAKAO BLIND RECRUITMENT) Lv 2. 괄호 변환 https://school.programmers.co.kr/learn/courses/30/lessons/60058 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; // 문자열을 분리해서 u를 균형잡힌 문자열로, 나머지를 v로 뱉어주는 함수 void Balance(const string& p, string& outputU, string& outputV) { size_t open{ 0 }, close{ 0 }; for (size_t i = 0; i < p.length(); ++i) { p[i.. 2023. 8. 7.
[Programmers] (2018 KAKAO BLIND RECRUITMENT) Lv 2. [3차] 방금그곡 https://school.programmers.co.kr/learn/courses/30/lessons/17683 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include #include using namespace std; enum MusicInfo { S, E, TITLE, MELODY, }; void revertM(string& m) { // # 먼저 체크하기 위해 역으로 체크 for (auto rit = m.rbegin(); rit != m.rend(); rit++) { if (*rit == '.. 2023. 8. 7.
[Maze] Chapter 02. 오른손 법칙 (우수법) GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commits/01.Maze GitHub - developeSHG/Data_Structure-Algorithm: Data Structure & Algorithm Data Structure & Algorithm. Contribute to developeSHG/Data_Structure-Algorithm development by creating an account on GitHub. github.com 만약 미로에 갇혔을 때, 탈출하려면 무식하면서도 직관적인 방법이 하나 있다. 바로 오른손 법칙. 오른손으로 벽을 만지면서 가는 것을 얘기한다. 우수법이라고도 한다. 하지만 100% 확률로 모든.. 2023. 8. 6.
[Maze] Chapter 01. 맵 만들기 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commits/01.Maze GitHub - developeSHG/Data_Structure-Algorithm: Data Structure & Algorithm Data Structure & Algorithm. Contribute to developeSHG/Data_Structure-Algorithm development by creating an account on GitHub. github.com Board.cpp - Render : 좌표 0으로 매번 초기화하고, 각 좌표에 해당하는 타일을 갖고와 타입에 맞는 컬러로 렌더 - GenerateMap : 맵을 만들어주는 곳. (테두리와 랜덤.. 2023. 8. 6.
[Programmers] Lv 2. 무인도 여행 https://school.programmers.co.kr/learn/courses/30/lessons/154540 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int dfs(int x, int y, vector& visited, const vector& dir, const vector& maps) { int value = maps[x][y] - '0'; visited[x][y] = true; for (const auto& d : dir) { int tx = x + d.. 2023. 8. 5.