본문 바로가기

개발31

[C++] 우선순위 큐(Priority Queue) 우선순위 큐(Priority Queue) 먼저 큐(Queue)는 먼저 들어오는 데이터가 먼저 나가는 선입선출(FIFO) 형식의 자료구조입니다. 우선순위 큐(Priority Queue)는 이와 다르게 항상 우선순위가 가장 높은 데이터에만 관심이 있고, 이 데이터만 먼저 나갈 수 있는 형태의 자료구조입니다. 이는 배열, 연결 리스트를 통해서도 구현이 가능하지만, 힙을 이용해야지만이 삽입, 삭제 시간을 O(logN)으로 맞출 수가 있기 때문에 보통 힙을 이용하여 우선순위 큐를 구현하고는 합니다. 숫자가 주어질 때마다 앞에 있는 숫자들을 전부 탐색해 그 중 최댓값을 골라야 할때 사용하면 됩니다. C++에서는 이를 표현하기 위해 priority_queue라는 STL을 이용할 수 있습니다. queue STL에 포함.. 2022. 12. 2.
google의 새로운 프로그래밍 언어 Carbon Google’s New Programming Language is Called Carbon Google Introduced Carbon to be a Successor of C++ medium.com Google's Chandler Karruth Announces New Programming Language "Carbon" at 2022 CPP North event (2022 CPP North event에서 구글의 Chandler Carruth가 'Carbon'이라는 새로운 프로그래밍 언어를 발표) Carbon is the successor to C++ and is currently in the experimental phase, centered around the C++ community, and wi.. 2022. 10. 12.
프론트엔드 로드맵 프론트엔드 개발자를 위한 FE 로드맵 https://roadmap.sh/frontend Developer Roadmaps Community driven roadmaps, articles, guides, quizzes, tips and resources for developers to learn from, identify their career paths, know what they don't know, find out the knowledge gaps, learn and improve. roadmap.sh 2022. 9. 27.
[python] 할당 전에 참조되는 지역 변수 파이썬에서 UnboundLocalError:local variable '변수명' referenced before assignment 오류가 발생할 때 이유와 해결방법에 대해 알아봅니다. a = 0 def myfunc(): a += 1 print(a) myfunc() print(a) 위 예제코드를 실행하면 다음과 같은 에러가 발생합니다. UnboundLocalError:local variable 'a' referenced before assignment 파이썬에서는 변수를 사용하기 전에 선언하거나 초기화 할 필요가 없고, 변수는 기본적으로 항상 로컬로 간주됩니다. 따라서 프로그램이 전역 변수를 지정하지 않고 함수 내의 전역 변수에 액세스하려고 하면 참조되는 변수가 지역 변수로 간주되므로 위와 같은 에러를 .. 2022. 5. 22.