Algorithem

실시간으로 변하는 경우 heap으로 중앙값 찾기

jamong5 2023. 1. 6. 07:42

중앙값은 기본적으로 정렬된 배열에서 찾는게 정답이긴한데,

실시간으로 원소가 하나씩 추가되는 경우라면?

https://o-tantk.github.io/posts/finding-median/

minheap, maxheap 두개를 동시에 돌리면서 찾을 수 있다. 자세한 알고리즘은 링크의 블로그로,,