<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://dasolu.github.io//feed.xml" rel="self" type="application/atom+xml" /><link href="https://dasolu.github.io//" rel="alternate" type="text/html" /><updated>2021-09-25T15:45:07+00:00</updated><id>https://dasolu.github.io//feed.xml</id><title type="html">Dasol Yoo</title><subtitle>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.</subtitle><author><name>Dasol Yoo</name></author><entry><title type="html">Pandas pd.read_csv의 engine과 encoding</title><link href="https://dasolu.github.io//codingtest/2021/08/23/pandas-read-csv-encoding.html" rel="alternate" type="text/html" title="Pandas pd.read_csv의 engine과 encoding" /><published>2021-08-23T00:00:00+00:00</published><updated>2021-08-23T00:00:00+00:00</updated><id>https://dasolu.github.io//codingtest/2021/08/23/pandas-read-csv-encoding</id><content type="html" xml:base="https://dasolu.github.io//codingtest/2021/08/23/pandas-read-csv-encoding.html">&lt;p&gt;데이터 분석가 사전 테스트를 보면 csv파일을 읽어서 데이터 분석을 진행하는 경우가 있습니다.&lt;/p&gt;

&lt;p&gt;이럴 때 한글이 깨져서 보이면 당황스럽죠,,&lt;/p&gt;

&lt;p&gt;mac에서 jupyter notebook으로 pandas.read_csv()로 파일을 읽어올 때 다음과 같이 하시면 됩니다!&lt;/p&gt;

&lt;p&gt;간단하게 해결하세요!&lt;/p&gt;

&lt;h2 id=&quot;입력-예시&quot;&gt;입력 예시&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'test.csv'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;python&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cp949'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Dasol Yoo</name></author><category term="CodingTest" /><category term="CodingTest" /><summary type="html">데이터 분석가 사전 테스트를 보면 csv파일을 읽어서 데이터 분석을 진행하는 경우가 있습니다.</summary></entry><entry><title type="html">포스코 청년 AI·BigData아카데미 15기 과정 시작</title><link href="https://dasolu.github.io//ai/2021/08/13/POSCO-bigdata-ai-academy.html" rel="alternate" type="text/html" title="포스코 청년 AI·BigData아카데미 15기 과정 시작" /><published>2021-08-13T00:00:00+00:00</published><updated>2021-08-13T00:00:00+00:00</updated><id>https://dasolu.github.io//ai/2021/08/13/POSCO-bigdata-ai-academy</id><content type="html" xml:base="https://dasolu.github.io//ai/2021/08/13/POSCO-bigdata-ai-academy.html">&lt;h2 id=&quot;최종합격&quot;&gt;최종합격&lt;/h2&gt;

&lt;p&gt;지난 7/1일 떨리는 면접을 마치고, 7/6일에 최종 합격 메일을 받았습니다! 🤩&lt;/p&gt;

&lt;p&gt;이후 사전 교육에 대한 시험을 치르고 기대했던 통계 수업을 들었습니다.&lt;/p&gt;

&lt;h2 id=&quot;지원-동기&quot;&gt;지원 동기&lt;/h2&gt;

&lt;p&gt;🌟&lt;strong&gt;포스코 청년 AI·BigData아카데미에서 빅데이터 분석 직무 유사 경험&amp;amp;AI를 사용한 심화 프로젝트 경험을 쌓을 수 있기 때문에!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;저는 이공계에서도 비즈니스와는 가장 멀리 있는 천문학을 전공하고 심지어 석사까지 마쳤기 때문에,&lt;/p&gt;

&lt;p&gt;첫 면접에서 “왜 전공을 그만두고 바꾸려고 하는가?” 라는 질문을 가장 먼저 받았습니다.&lt;/p&gt;

&lt;p&gt;이러한 질문에 대한 대답의 근거를 만들기 위해 &lt;strong&gt;비즈니스 데이터 분석 경험&lt;/strong&gt;이 필요하다고 느꼈습니다.&lt;/p&gt;

&lt;p&gt;또한 빅데이터 분석가 취업 공고들에서 요구하는 필요 경험과 역량을 분석하면서,&lt;/p&gt;

&lt;p&gt;저에게 가장 필요한 것이 &lt;strong&gt;비즈니스 데이터 분석 경험&lt;/strong&gt;인 것을 다시 한 번 깨달았습니다.&lt;/p&gt;

&lt;p&gt;포스코에서는 실제 비즈니스 데이터에서 발생하는 문제를 정의하고, 분석하고, 인사이트를 도출하는 경험을 쌓을 수 있기 때문에 저에게 절실하게 필요한 교육이라는 생각이 들었습니다.&lt;/p&gt;

&lt;h2 id=&quot;1주차-후기&quot;&gt;1주차 후기&lt;/h2&gt;

&lt;p&gt;통계 수업을 통해 기술통계, 확률분포, 통계적 추정과 검정, 상관분석, 회귀분석을 배웠습니다.&lt;/p&gt;

&lt;p&gt;제가 혼자 공부하면서 이해하기 어려웠던 개념을 이해할 수 있게 되었을 뿐만 아니라,&lt;/p&gt;

&lt;p&gt;기업의 의사결정에 필요한 경우들에 어떤 개념을 적용하는지 예시들을 배우며 해석하는 경험을 했습니다.&lt;/p&gt;

&lt;p&gt;자연 과학 연구원에서 일반 기업 취업으로 넘어가기 위해 필요한 핵심 내용들을 배울 수 있어서 감사하고 즐거웠습니다!&lt;/p&gt;

&lt;p&gt;이후 진행될 빅데이터 프로젝트에서 배운 개념을 모조리 적용해서 깊이있는 해석을 해볼 것을 기대중입니다!!&lt;/p&gt;</content><author><name>Dasol Yoo</name></author><category term="AI" /><category term="BigdataAnalysis" /><category term="AI" /><category term="Career" /><summary type="html">최종합격</summary></entry><entry><title type="html">선형대수 기초 개념 정리</title><link href="https://dasolu.github.io//%EC%84%A0%ED%98%95%EB%8C%80%EC%88%98/2021/07/08/linear-algebra.html" rel="alternate" type="text/html" title="선형대수 기초 개념 정리" /><published>2021-07-08T00:00:00+00:00</published><updated>2021-07-08T00:00:00+00:00</updated><id>https://dasolu.github.io//%EC%84%A0%ED%98%95%EB%8C%80%EC%88%98/2021/07/08/linear-algebra</id><content type="html" xml:base="https://dasolu.github.io//%EC%84%A0%ED%98%95%EB%8C%80%EC%88%98/2021/07/08/linear-algebra.html">&lt;p&gt;이 글은 포스코 AI・BigData 아카데미 교육과정에서 추천하는 &lt;a href=&quot;https://www.youtube.com/playlist?list=PLxMkK1K0XECOj2sZG-gCk-CjvZhJ_75I4&quot;&gt;선형대수 온라인 강의&lt;/a&gt;를 요약한 것입니다.&lt;/p&gt;

&lt;p&gt;향후 내용이 추가될 예정입니다.&lt;/p&gt;

&lt;h2 id=&quot;2-일차종속-및-독립&quot;&gt;&lt;strong&gt;[2. 일차종속 및 독립]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;일차-결합&quot;&gt;&lt;strong&gt;일차 결합&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;벡터와 상수의 곱의 결합&lt;/p&gt;

&lt;p&gt;예시) $a1&lt;em&gt;v1+a2&lt;/em&gt;v2+…$&lt;/p&gt;

&lt;h3 id=&quot;생성&quot;&gt;&lt;strong&gt;생성&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;일차 결합 계산 결과를 말한다.&lt;/p&gt;

&lt;h3 id=&quot;일차종속-및-독립&quot;&gt;일차종속 및 독립&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;일차(선형)독립?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;한 백터에 실수배 해서 다른 벡터를 하나라도 만들어 낼 수 없다.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;일차(선형)종속?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;한 백터에 실수배 해서 다른 벡터를 하나라도 만들어 낼 수 있다.&lt;/p&gt;

&lt;p&gt;예시)&lt;/p&gt;

&lt;p&gt;(1,1)과 (2,2)&lt;/p&gt;

&lt;h3 id=&quot;독립-vs-종속-판별-방법&quot;&gt;&lt;strong&gt;독립 VS. 종속 판별 방법&lt;/strong&gt;&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;정방행렬인 경우&amp;gt;&lt;/strong&gt; 행렬식으로 판별&lt;/p&gt;

    &lt;p&gt;행렬식이 0이면 종속/ 0이 아니면 독립&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;정방행렬이&lt;/strong&gt; &lt;strong&gt;아닌 경우&amp;gt;&lt;/strong&gt; 랭크로 독립과 선형을 구분하는 방법&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;&lt;strong&gt;랭크 A?&lt;/strong&gt;&lt;/p&gt;

        &lt;p&gt;&lt;strong&gt;A행렬의 열들 중에서 일차 독립인 열들의 최대 개수&lt;/strong&gt;&lt;/p&gt;

        &lt;p&gt;=행렬의 열들로 생성될 수 있는 백터 공간의 차원&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;&lt;strong&gt;랭크로 독립과 선형을 구분하는 방법?&lt;/strong&gt;&lt;/p&gt;

        &lt;p&gt;각 열에 실수배를 하고 더하는 과정을 거쳤을 때,&lt;/p&gt;

        &lt;p&gt;맨 마지막 열이 0으로 구성될 경우 실수배해서 생성할 수 있으므로 종속이다.&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;3-기저-및-차원&quot;&gt;&lt;strong&gt;[3. 기저 및 차원]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;기저basis&quot;&gt;&lt;strong&gt;기저(basis)&lt;/strong&gt;&lt;/h3&gt;

&lt;h4 id=&quot;정의&quot;&gt;정의&lt;/h4&gt;

&lt;p&gt;백터 공간 v에 대해 s가 부분집합일 때,&lt;/p&gt;

&lt;p&gt;집합 s가&lt;/p&gt;

&lt;p&gt;1.v를 생성하고&lt;/p&gt;

&lt;p&gt;2.선형독립이라면&lt;/p&gt;

&lt;p&gt;s를 v의 기저(basis)라고 한다.&lt;/p&gt;

&lt;p&gt;예시) 음악이라는 벡터 공간의 기저는 “도레미파솔라시도”음계이다.&lt;/p&gt;

&lt;p&gt;흑백 공간이라는 벡터 공간의 기저는 “종이, 연필, 지우개”이다.&lt;/p&gt;

&lt;p&gt;즉 흑백 &lt;strong&gt;공간을 만들기 위한 최소의 엑기스&lt;/strong&gt;는 “종이, 연필, 지우개”이다.&lt;/p&gt;

&lt;h4 id=&quot;특징&quot;&gt;특징&lt;/h4&gt;

&lt;p&gt;“&lt;strong&gt;기저는 여러개일 수 있다. 하지만 차원(기저의 개수)는 변하지 않는다.&lt;/strong&gt;”&lt;/p&gt;

&lt;h3 id=&quot;표준-기저&quot;&gt;&lt;strong&gt;표준 기저&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;기저 중에 표준인 것을 의미한다.&lt;/p&gt;

&lt;p&gt;예시)&lt;/p&gt;

&lt;p&gt;R^2: {(1,0), (0,1)} , R2의 기저의 개수, 즉 차원은 2이다.&lt;/p&gt;

&lt;h3 id=&quot;기저의-좌표&quot;&gt;&lt;strong&gt;기저의 좌표&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;(3,4) = &lt;strong&gt;3&lt;/strong&gt;&lt;em&gt;(1,0)+&lt;strong&gt;4&lt;/strong&gt;&lt;/em&gt;(0,1)이므로&lt;/p&gt;

&lt;p&gt;이때 &lt;strong&gt;좌표 벡터(상대좌표, 좌표행렬)&lt;/strong&gt;은 &lt;strong&gt;[3,4]&lt;/strong&gt;이다.&lt;/p&gt;

&lt;h2 id=&quot;4-고유치-및-고유벡터&quot;&gt;&lt;strong&gt;[4. 고유치 및 고유벡터]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;-정의&quot;&gt;📌 정의&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-1.tiff&quot; alt=&quot;linearalgebra-1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A행렬에 어떤 백터 v를 곱한 결과가&lt;/strong&gt;
&lt;strong&gt;v에 어떤 실수 λ배 한 것과 같을 때,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;v를 고유 벡터,λ를 고유치라 한다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;고유벡터는 0이 아닌 벡터이기 때문에, A-λI의 역행렬이 존재하면 안된다.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;따라서 A-λI의 행렬식이 0이어야 한다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(즉, 고유 방정식이 0이어야 한다.)&lt;/p&gt;

&lt;h3 id=&quot;고유치-계산-방법&quot;&gt;&lt;strong&gt;고유치 계산 방법&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;고유 방정식을 계산한다.&lt;/p&gt;

&lt;p&gt;즉, 대각 성분에 λ를 빼준 뒤 행렬식 값을 구한다.&lt;/p&gt;

&lt;p&gt;# 3X3이상 큰 행렬의 행렬식을 구할 때,&lt;/p&gt;

&lt;p&gt;어떤 행 또는 열에 0을 포함하고 있다면,&lt;/p&gt;

&lt;p&gt;0을 포함하는 행 또는 열의 다른 원소를 0으로 만들어준다.&lt;/p&gt;

&lt;p&gt;이때 방법은 행 또는 열에 실수배를 하여 더하거나 빼준다.&lt;/p&gt;

&lt;p&gt;이러한 방법으로 행렬식 원소를 0으로 만들어서 계산을 간소화 할 수 있다.&lt;/p&gt;

&lt;h3 id=&quot;고유벡터-계산-방법&quot;&gt;&lt;strong&gt;고유벡터 계산 방법&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;구한 고유치 값을 대각성분에서 빼준다.&lt;/p&gt;

&lt;p&gt;(A-λI)v=0을 만족하는 x,y를 아무거나 찾아준다.&lt;/p&gt;

&lt;h2 id=&quot;5-고유치-및-고유벡터의-성질&quot;&gt;&lt;strong&gt;[5. 고유치 및 고유벡터의 성질]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;trace&quot;&gt;📌&lt;strong&gt;Trace&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tr(A)=A행렬의 대각 행렬들을 모두 더한 것&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;-성질-1&quot;&gt;&lt;strong&gt;📌 [성질 1]&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A행렬의&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.고유치의 합은 trace(A)와 같다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.고유치의 곱은 A의 행렬식 값과 같다.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;성질-2&quot;&gt;&lt;strong&gt;📌[성질 2]&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1.A^T와 A의 고유치는 같다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;​	&lt;strong&gt;(단, 고유벡터는 같다고 보장할 수 없다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.A의 고유치가 lambda이면,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;​	A^n의 고유치는 lambda^n이다.&lt;/p&gt;

&lt;p&gt;​	A^(-1)의 고유치는 lambda^(-1)이다.&lt;/p&gt;

&lt;p&gt;​	a&lt;em&gt;A의 고유치는 a&lt;/em&gt;lambda이다.&lt;/p&gt;

&lt;p&gt;​	A+a*I의 고유치는 lambda+a이다.&lt;/p&gt;

&lt;h3 id=&quot;성질-3&quot;&gt;&lt;strong&gt;📌[성질 3]&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1.대칭행렬의 고유치는 항상 실수이며,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;서로 다른 고유치에 해당하는 각각의 고유벡터는 수직관계를 갖는다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(즉, 두 벡터를 내적하면 0이다.)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-2.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;# 팁: 내적계산은 전치와 같다.&lt;/p&gt;

&lt;p&gt;# 이유: 원래 벡터는 세워서 쓴느게 원칙이기 때문에, 전치를 하면 눕혀진다. 그 결과 내적 계산과 같아진다.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.교대행렬의 고유치는 0 또는 순허수이다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.직교 행렬의 고유치는 1 또는 -1 및 켤례복소수이며, 그 절댓값은 항상 1이다.( 즉 $a^{2}+b^{2}=1$)&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;6-닮은-행렬과-대각화-행렬&quot;&gt;&lt;strong&gt;[6. 닮은 행렬과 대각화 행렬]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;닮은-행렬&quot;&gt;닮은 행렬&lt;/h3&gt;

&lt;h3 id=&quot;정의-1&quot;&gt;📌정의&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;$Q^{-1}AQ = B$ 일 때, (단,&lt;/strong&gt; &lt;strong&gt;Q가 역행렬이 존재할 때)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A와 B는 닮은 행렬이다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;이는 &lt;strong&gt;“행렬의 성질이 같음을 의미한다.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1)행렬식 값이 같다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2)Rank값이 같다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3)Tr(A)=Tr(B)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4)고유치가 서로 같다.(고유 벡터가 같다고 보장할 수는 없다.)&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;대각화-행렬&quot;&gt;&lt;strong&gt;대각화 행렬&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;$P^{-1}AP = D$&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P: 대각화 시키는 행렬 (이때, P는 A의 고유벡터로 이루어진 행렬)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D: 대각화 행렬 (A의 고유치로 이루어진 행렬)&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;대각화-시키는-행렬과-대각화-행렬을-구하는-방법&quot;&gt;&lt;strong&gt;대각화 시키는 행렬과 대각화 행렬을 구하는 방법&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;먼저 A행렬의 고유치와 그에 해당하는 고유 벡터를 구한다.&lt;/p&gt;

&lt;p&gt;이때 P는 고유벡터를 세로로 놓으면 되며,&lt;/p&gt;

&lt;p&gt;D는 대각 부분에 고유 고유벡터에 해당하는 고유치를 순서대로 넣어주면 된다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;D는 항상 존재하는가? =A 행렬은 대각화 가능한가?&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;무조건 존재하지는 않는다. P의 역행렬이 존재할 때만 존재한댜.&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;P의 역행렬이 존재하면 P의 행렬식 값이 0이 아니다.&lt;/p&gt;

    &lt;p&gt;이는 P를 이루는 고유벡터 열들이 일차독립이어야 함을 의미한다.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;방법&amp;gt;&lt;/p&gt;

        &lt;p&gt;&lt;strong&gt;1.서로 다른 고유치가 N개 존재해야한다.&lt;/strong&gt;&lt;/p&gt;

        &lt;p&gt;​	만약 &lt;strong&gt;중근&lt;/strong&gt;을 갖는 경우, 대각화는 가능할 수도 불가능 할 수도 있다.&lt;/p&gt;

        &lt;p&gt;​	따라서 2번째 조건을 추가로 확인한다.&lt;/p&gt;

        &lt;p&gt;2.&lt;strong&gt;대각화가 가능하려면 일차독립인 고유벡터의 개수가 N개 존재해야한다.&lt;/strong&gt;&lt;/p&gt;

        &lt;p&gt;​	중근인 고유치에 해당하는 고유 벡터가 서로 다른지 확인한다.&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;7-벡터&quot;&gt;&lt;strong&gt;[7. 벡터]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;벡터-표현&quot;&gt;&lt;strong&gt;벡터 표현&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;시점에서 종점으로 방향과 힘이 제시된 수학적 연산이다.&lt;/p&gt;

&lt;h3 id=&quot;벡터의-상등&quot;&gt;벡터의 상등&lt;/h3&gt;

&lt;p&gt;크키와 방향이 같은 벡터.&lt;/p&gt;

&lt;p&gt;이러한 벡터는 이동이 가능하다.&lt;/p&gt;

&lt;h3 id=&quot;벡터의-실수배&quot;&gt;&lt;strong&gt;벡터의 실수배&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;방향은 그대로이지만 크기가 실수배 된다.&lt;/p&gt;

&lt;p&gt;음수를 곱할 경우 방향이 반대가 된다.&lt;/p&gt;

&lt;h3 id=&quot;단위벡터&quot;&gt;단위벡터&lt;/h3&gt;

&lt;p&gt;크기가 1인 벡터.&lt;/p&gt;

&lt;p&gt;단위 벡터 만드는 방법:벡터 자기 자신의 크기로 나눈다.&lt;/p&gt;

&lt;h3 id=&quot;벡터의-사칙연산&quot;&gt;&lt;strong&gt;벡터의 사칙연산&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;덧셈, 뺄셈, 곱셈만 존재한다.&lt;/p&gt;

&lt;h2 id=&quot;8-벡터의-내적&quot;&gt;&lt;strong&gt;[8. 벡터의 내적]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;내적의-성질&quot;&gt;&lt;strong&gt;내적의 성질&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-4.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;#중요: 수직인 두 벡터의 내적은 0이다.&lt;/p&gt;

&lt;h2 id=&quot;9-랭크-1&quot;&gt;&lt;strong&gt;[9. 랭크 1]&lt;/strong&gt;&lt;/h2&gt;

&lt;h3 id=&quot;랭크-연산법&quot;&gt;&lt;strong&gt;랭크 연산법&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;=연립방정식을 푸는 방법과 완전히 동일하다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-5.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;행 작업만 가능하다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;행과 행을 바꿔도 된다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;행에 실수배를 해도 된다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;[가우스 소거법]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;첫번째 행의 선두(0이 아닌 숫자) 밑에를 0으로 만든다.&lt;/p&gt;

&lt;p&gt;두번째 행의 선두 밑을 0으로 만든다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-6.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;이때 랭크는 행이 0으로 이루어지지 않은 행의 개수이다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-7.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;10-랭크의-활용&quot;&gt;&lt;strong&gt;[10. 랭크의 활용]&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-8.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-9.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/linearalgebra/linearalgebra-10.tiff&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;

&lt;p&gt;포스코 AI・BigData 아카데미 교육과정에서 추천하는 선형대수 온라인 강의와,&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;https://www.youtube.com/playlist?list=PLxMkK1K0XECOj2sZG-gCk-CjvZhJ_75I4&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;추가적인 개념 이해에 도움 받은 블로그들입니다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&amp;amp;blogId=sw4r&amp;amp;logNo=221921810588&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;https://angeloyeo.github.io/2019/07/17/eigen_vector.html&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>Dasol Yoo</name></author><category term="선형대수" /><category term="Linear Algebra" /><summary type="html">이 글은 포스코 AI・BigData 아카데미 교육과정에서 추천하는 선형대수 온라인 강의를 요약한 것입니다.</summary></entry><entry><title type="html">Summary for BFS Algorithm</title><link href="https://dasolu.github.io//codingtest/2021/06/08/summary-bfs.html" rel="alternate" type="text/html" title="Summary for BFS Algorithm" /><published>2021-06-08T00:00:00+00:00</published><updated>2021-06-08T00:00:00+00:00</updated><id>https://dasolu.github.io//codingtest/2021/06/08/summary-bfs</id><content type="html" xml:base="https://dasolu.github.io//codingtest/2021/06/08/summary-bfs.html">&lt;p&gt;🌟코딩테스트에서 &lt;strong&gt;BFS&lt;/strong&gt; 문제를 풀기 위해 꼭 필요한 함수 총 정리!!!!!🌟&lt;/p&gt;

&lt;p&gt;코테 전에 &lt;strong&gt;BFS 알고리즘 필수 요약&lt;/strong&gt; 보고 들어가세요!&lt;/p&gt;

&lt;p&gt;계속 업데이트 합니다.&lt;/p&gt;

&lt;h2 id=&quot;queue-만드는-방법&quot;&gt;Queue 만드는 방법&lt;/h2&gt;

&lt;p&gt;queue에 2D node를 추가할 때 시공간 복잡도가 가장 낮은 방법.&lt;/p&gt;

&lt;p&gt;(현재까지 진행한 여러가지 테스트롤 통해 내린 결론이며, 향후 변경될 수 있다.)&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;from&lt;/strong&gt; collections &lt;strong&gt;import&lt;/strong&gt; deque&lt;/p&gt;

    &lt;p&gt;q = deque()&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;q.append((sy, sx))&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;(y, x) = q.popleft()&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;q.append((ny, nx))&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;graph-만드는-방법&quot;&gt;Graph 만드는 방법&lt;/h2&gt;

&lt;h3 id=&quot;node와-edge가-주어질-때&quot;&gt;node와 edge가 주어질 때&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/13023&quot;&gt;13023번 - ABCDE&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1260&quot;&gt;1260번 - DFS와 BFS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/11724&quot;&gt;11724번 - 연결 요소의 개수&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1707&quot;&gt;1707번 - 이분 그래프&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Make Graph
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;edge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;node1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;node2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;n-x-m-인접-행렬adjacency-matrix이-주어질-때&quot;&gt;N X M 인접 행렬(adjacency matrix)이 주어질 때&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2667&quot;&gt;2667번 - 단지번호붙이기&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2178&quot;&gt;2178번 - 미로 탐색&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7576&quot;&gt;7576번 - 토마토&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7562&quot;&gt;7562번 - 나이트의 이동&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readline&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# returns list ex&amp;gt;['0110100']
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([])&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;문제-유형&quot;&gt;문제 유형&lt;/h2&gt;

&lt;h3 id=&quot;모든-노드-방문할-때&quot;&gt;모든 노드 방문할 때&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;노드 n개가 연결된 경로가 존재하는지 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/13023&quot;&gt;13023번 - ABCDE&lt;/a&gt;&lt;/p&gt;

 	1. for문 사용하여 모든 노드 방문
 	  	1. DFS: level == n-1일 때 return

&lt;ul&gt;
  &lt;li&gt;모든 노드 방문하며 그 순서 출력하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1260&quot;&gt;1260번 - DFS와 BFS&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;visited = []에 pop한 node를 추가한다&lt;/li&gt;
  &lt;li&gt;visited를 return한다&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;연결 요소(connected component)의 개수 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/11724&quot;&gt;11724번 - 연결 요소의 개수&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;for문 사용하여 모든 노드 방문
    &lt;ol&gt;
      &lt;li&gt;방문하지 않은 노드만 방문한다
        &lt;ol&gt;
          &lt;li&gt;BFS&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;일부-노드만-선택적으로-방문할-때-2d&quot;&gt;일부 노드만 선택적으로 방문할 때: 2D&lt;/h3&gt;

&lt;p&gt;📌 1. 먼저 자식 노드의 위치가 2D array index 범위 안에 위치하는지 조사하기&lt;/p&gt;

&lt;p&gt;​	✔️ 가능한 &amp;lt; 또는 &amp;gt;을 사용하자‼️ &amp;lt;= 또는 &amp;gt;= 사용을 피하자‼️&lt;/p&gt;

&lt;p&gt;​		 예를들어 0&amp;lt;=ny &amp;lt;= n - 1 을 사용하지 말고, 예를들어 0&amp;lt;=ny &amp;lt; n 을 사용하자.&lt;/p&gt;

&lt;p&gt;​		 이유)  &amp;lt;=을 사용하는 경우 -1 연산을 추가로 하게 되므로 ~ 효율성이 낮아진다.&lt;/p&gt;

&lt;p&gt;​	✔️이 과정이 선행되어야 방문 여부를 확인할 때 2D array index 범위를 벗어나는 error가 발생하지 않는다.&lt;/p&gt;

&lt;p&gt;📌 2. 이후 자식 노드의 방문 여부를 조사하고, 동시에 방문 여부 리스트에 탐색 비용을 저장하자‼️&lt;/p&gt;

&lt;h4 id=&quot;자식-노드의-탐색-비용이-동일할-때&quot;&gt;자식 노드의 탐색 비용이 동일할 때&lt;/h4&gt;

&lt;p&gt;📌 목표 node까지 도달하는데 필요한 최소한의 edge개수/시간/이동/거리를 구하는 방법은?&lt;/p&gt;

&lt;p&gt;즉, 탐색 깊이를 count할 때&lt;/p&gt;

&lt;p&gt;➡️ 동일한 부모 노드와 연결된 자식 노드라면 같은 level을 가지도록 한다.&lt;/p&gt;

&lt;p&gt;즉, 모든 자식 노드의 visited 값에 부모 노드의 visited 값에 1을 추가한다.&lt;/p&gt;

&lt;p&gt;이 방법을 사용하면 목표 node에 도달했을 때 visitied에 저장된 level이 자연스럽게 최소 edge개수/시간/이동/거리가 된다.&lt;/p&gt;

&lt;h5 id=&quot;1d-다양한-방향&quot;&gt;1D: 다양한 방향&lt;/h5&gt;

&lt;ul&gt;
  &lt;li&gt;최단 경로로 이동할 때 지나가는 노드를 print 하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/13913&quot;&gt;13913번 - 숨바꼭질 4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BFS 방법을 사용하면 같은 level의 자식 노드를 node를 방문한다.&lt;/p&gt;

&lt;p&gt;따라서 node를 pop하여 모두 저장하는 방법으로는 최단 경로를 print 할 수 없다.&lt;/p&gt;

&lt;p&gt;➡️ parent list를 만들어서, 자식 노드 방문시 부모 노드를 저장한다.&lt;/p&gt;

&lt;p&gt;BFS를 마치고 도착한 노드의 parent list 값을 확인하여 이전에 방문한 노드를 알아내는 것을 반복한다.&lt;/p&gt;

&lt;h5 id=&quot;2d-좌-우-상-하&quot;&gt;2D: 좌 우 상 하&lt;/h5&gt;

&lt;p&gt;목적지에 도달하기 위한 최소의 칸 수 구하기&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;목적지에 도달하는 최소 이동 거리 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2178&quot;&gt;2178번 - 미로 탐색&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;visited = [[0]*node for _ in range(node)]&lt;/li&gt;
  &lt;li&gt;for 문으로 가능한 모든 자식 노드 조사 (if 문으로 각 경우를 조사하는 것이 더 빠르지만 코드가 길어져서 작성 시간이 더 오래 걸린다.)
    &lt;ol&gt;
      &lt;li&gt;자식 노드의 row와 column이 2D array의 Index 범위를 벗어나지 않는지 조사
        &lt;ol&gt;
          &lt;li&gt;방문하지 않은 자식 노드만 방문
            &lt;ol&gt;
              &lt;li&gt;visited[child_y][child_x] = visited[parent_y][parent_x] + 1&lt;/li&gt;
              &lt;li&gt;&lt;/li&gt;
            &lt;/ol&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;연결 요소(connected component)의 개수 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/2667&quot;&gt;2667번 - 단지번호붙이기&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;시작 노드가 여러 개인 경우, 가능한 모든 시작 노드에서 동시에 BFS 탐색하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;➡️ Queue안에 모든 시작 노드를 추가한다. 이 방법으로 차례로 BFS를 진행하게 된다.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7576&quot;&gt;7576번 - 토마토&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;예를 들어 이 문제에선 [0,0]과 [3,5]에 토마토가 존재하므로, 탐색 시작 노드가 2개가 된다.&lt;/p&gt;

&lt;p&gt;따라서 두 노드를 queue에 올려서 BFS를 진행하면서, 자식 토마토가 익는데 걸리는 시간을 채워준다.&lt;/p&gt;

&lt;p&gt;그 결과는 다음과 같다.&lt;/p&gt;

&lt;p&gt;[[ 1 -1  7  6  5  4]
 [ 2 -1  6  5  4  3]
 [ 3  4  5  6 -1  2]
 [ 4  5  6  7 -1  1]]&lt;/p&gt;

&lt;h5 id=&quot;2d-다양한-방향&quot;&gt;2D: 다양한 방향&lt;/h5&gt;

&lt;ul&gt;
  &lt;li&gt;목적지에 도달하는 최소 이동 거리 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7562&quot;&gt;7562번 - 나이트의 이동&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;dx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;자식-노드의-탐색-비용이-서로-다를-때&quot;&gt;자식 노드의 탐색 비용이 서로 다를 때&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;최단 경로이면서 탐색 비용이 최소인 경로 구하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1261&quot;&gt;1261 알고스팟&lt;/a&gt;, &lt;a href=&quot;https://www.acmicpc.net/problem/13549&quot;&gt;13549 숨바꼭질 3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ 탐색 비용이 작은 자식 노드를 queue의 앞에 추가하고, 탐색 비용이 큰 자식 노드는 뒤에 추가한다.&lt;/p&gt;

&lt;p&gt;​	✔️ q.appendleft(), q.append() 를 사용한다.&lt;/p&gt;

&lt;p&gt;이 방법은 비용이 적은 경로부터 우선적으로 탐색하고, 가장 적은 비용에 대한 탐색이 끝나고 나서야 비로소 더 큰 비용의 경로를 탐색하기 시작한다.&lt;/p&gt;

&lt;p&gt;따라서 이 방법을 통해 탐색 비용과 길이가 이 최소인 경로를 찾을 수 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;이분 그래프 (Bipartite Graph) 판별하기&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;이분 그래프란? 그래프의 정점의 집합을 둘로 분할하여, 각 집합에 속한 정점끼리는 서로 인접하지 않는 그래프이다.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1707&quot;&gt;1707번 - 이분 그래프&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ 방문하지 않은 자식 노드의 탐색 비용 저장시, 부모 노드의 값에 -1을 곱하여 서로 다른 집합임을 표시한다.&lt;/p&gt;

&lt;p&gt;만약 자식 노드를 이미 방문했으며, 부모 노드와 탐색 비용이 동일하다면 return false&lt;/p&gt;</content><author><name>Dasol Yoo</name></author><category term="CodingTest" /><category term="CodingTest" /><category term="Summary" /><summary type="html">🌟코딩테스트에서 BFS 문제를 풀기 위해 꼭 필요한 함수 총 정리!!!!!🌟</summary></entry><entry><title type="html">NAVER AI Now</title><link href="https://dasolu.github.io//ai/2021/05/25/naver-ai-now.html" rel="alternate" type="text/html" title="NAVER AI Now" /><published>2021-05-25T00:00:00+00:00</published><updated>2021-05-25T00:00:00+00:00</updated><id>https://dasolu.github.io//ai/2021/05/25/naver-ai-now</id><content type="html" xml:base="https://dasolu.github.io//ai/2021/05/25/naver-ai-now.html">&lt;h2 id=&quot;기존-ai-시대&quot;&gt;기존 AI 시대&lt;/h2&gt;

&lt;p&gt;각 문제별로 데이터 확보-&amp;gt;정제-&amp;gt;모델개발-&amp;gt;서비스&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;문제: 긴시간과 많은 리소스 필요, 결과물을 다른데 사용하는데 제한&lt;/li&gt;
  &lt;li&gt;한계: 한정적 자원에 의한 속도와 스케일 한계-&amp;gt;새로운 패러다임의 필요성&lt;/li&gt;
  &lt;li&gt;해결: Big model의 일반화와 확장을 통한 플랫폼화&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;big-ai-시대&quot;&gt;BIG AI 시대&lt;/h2&gt;

&lt;h3 id=&quot;정의&quot;&gt;정의&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;새로운 AI 시대: 파라메터 수 높이는 것
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;파라메터 수가 많아짐에 따라 해결 가능한 문제 수가 많아진다.&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;더 큰 모델, 더 빠른 학습이 경쟁 주제이다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;필요한-것&quot;&gt;필요한 것&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;슈퍼컴퓨팅 인프라: 필수, NAVER는 700pf이상 성능을 갖춘 슈퍼 컴퓨터 도입&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;데이터: 고품질 풍부한 데이터, 가장 많은 사용자가 있는 플랫폼에서 나오는 데이터, 한국어 모델&lt;/li&gt;
  &lt;li&gt;AI 전문가: 학회 발표 논문 (국내 기업중 최대), 글로벌 공동 연구&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;방법&quot;&gt;방법&lt;/h3&gt;

&lt;p&gt;비지도학습 방법이 가능하게 만들었다.&lt;/p&gt;

&lt;p&gt;모델 규모가 클수록 효율성이 늘어난다. (loss 줄어든다)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525141146627.png&quot; alt=&quot;image-20210525141146627&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;모델의-진화&quot;&gt;모델의 진화&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525155026371.png&quot; alt=&quot;image-20210525155026371&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;예시-hyperclova-특장점&quot;&gt;예시) HyperCLOVA 특장점&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;맥락을 이해하는 대화&lt;/li&gt;
  &lt;li&gt;창장을 도와주는 글쓰기
    &lt;ol&gt;
      &lt;li&gt;크리에이터의 창작
        &lt;ol&gt;
          &lt;li&gt;그렇다면 창작의 가치는 어떻게 되는가? 이전을 모방하는 창작은 AI도 가능해진다는 뜻이므로 가치가 낮아질 것이다.&lt;/li&gt;
          &lt;li&gt;가치있는 창작이란? 이전에 없던 것을 만드는 것이 될 것이다.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;정보 요약
    &lt;ol&gt;
      &lt;li&gt;여러 문서를 읽고 요약해준다.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;데이터 생성
    &lt;ol&gt;
      &lt;li&gt;데이터 구축 과정의 비용과 시간 단축&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;AI 개발자가 아니어도 누구나 필요한 서비스를 만고, 문제를 해결할 수 있다.&lt;/strong&gt;
    &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;그렇다면 AI 개발자로서 나아가야 할 방향은 무엇인가?&lt;/strong&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525143239311.png&quot; alt=&quot;image-20210525143239311&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525143334952.png&quot; alt=&quot;image-20210525143334952&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;인프라&quot;&gt;인프라&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;GPU 서버 병렬 학습&lt;/strong&gt;이 필수가 되었다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525143637310.png&quot; alt=&quot;image-20210525143637310&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;규모&quot;&gt;규모&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525143748986.png&quot; alt=&quot;image-20210525143748986&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525143854804.png&quot; alt=&quot;image-20210525143854804&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;nlp-big-data-수집&quot;&gt;NLP Big Data 수집&lt;/h2&gt;

&lt;p&gt;딥러닝에서 중요한 것은 좋은 데이터 확보하는 것&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;다양한 내용&lt;/li&gt;
  &lt;li&gt;범용의 구성 (대화, Q&amp;amp;A…등)&lt;/li&gt;
  &lt;li&gt;양질의 정보 (내용을 믿을 수 있는가)
    &lt;ol&gt;
      &lt;li&gt;영역 선별 모델 개발&lt;/li&gt;
      &lt;li&gt;저품질 문서 필터링: 비속어, 반복단어 등 제거&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;충분한 양&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;naver-ai-lab-rd&quot;&gt;NAVER AI Lab: R&amp;amp;D&lt;/h2&gt;

&lt;p&gt;공개된 기술 적용 VS 자체 기술 개발: 리더쉽 확보를 위해 자체 기술 개발.&lt;/p&gt;

&lt;p&gt;매출의 25%를 개발에 투자하며 그중 AI가 큰 비중을 차지한다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;AI 연구 동향 핵심
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;BIG (모델, 데이터, 개발인력): 연구 중심이 아카데미-&amp;gt;기업!!&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;AI 배우려면 이제 회사를 가야한다.&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;발표 논문의 상단수를 인턴과 함께 작성했다.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;연구 결과가 사용자에게 직접적으로 적용된다는 점이 의미있다.&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;서울대, 카이스트와 협업이 국내 최고&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;NAVER AI Lab 리더께서 &lt;strong&gt;선지원 노고민!&lt;/strong&gt; 을 부탁하셨다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;ai-윤리-준칙&quot;&gt;AI 윤리 준칙&lt;/h2&gt;

&lt;p&gt;사람을 위한 AI 개발&lt;/p&gt;

&lt;p&gt;다양항 존중 …등 5가지&lt;/p&gt;

&lt;h3 id=&quot;네이버의-관점&quot;&gt;네이버의 관점&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;누구나 쉽고 빠르게 활용할 수 있는 사람을 위한 일상의 도구&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;예시: Clove carecall (반복 업무 효율성 증가)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;hyperclova-기술&quot;&gt;HyperCLOVA 기술&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525153700154.png&quot; alt=&quot;image-20210525153700154&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/naverainow/image-20210525153813711.png&quot; alt=&quot;image-20210525153813711&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;현재 모델의 크키가 커지는 속도가 GPU 메모리가 증가하는 속도보다 더 크다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;따라서 큰 모델을 위해서 GPU에 나누어 연산을 수행하고 나중에 합치는 방법이 필수적이며, 3중 병렬화 방법이 현재 적용되고 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;모델의 크기가 클수록 후반 loss 감소가 크다.&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Dasol Yoo</name></author><category term="AI" /><category term="AI" /><category term="NLP" /><category term="Deep Learning" /><summary type="html">기존 AI 시대</summary></entry><entry><title type="html">Few-shot Learning 딥러닝 시 데이터 수가 매우 적을 때?</title><link href="https://dasolu.github.io//ai/2021/05/18/few-shot-learning.html" rel="alternate" type="text/html" title="Few-shot Learning 딥러닝 시 데이터 수가 매우 적을 때?" /><published>2021-05-18T00:00:00+00:00</published><updated>2021-05-18T00:00:00+00:00</updated><id>https://dasolu.github.io//ai/2021/05/18/few-shot-learning</id><content type="html" xml:base="https://dasolu.github.io//ai/2021/05/18/few-shot-learning.html">&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;

&lt;p&gt;이 글은 &lt;a href=&quot;https://www.kakaobrain.com/blog/106&quot;&gt;카카오브레인 AutoLearn 연구팀의 퓨샷 러닝 연구&lt;/a&gt;를 참고 요약한 것입니다.&lt;/p&gt;

&lt;h3 id=&quot;논문&quot;&gt;논문&lt;/h3&gt;

&lt;p&gt;https://arxiv.org/pdf/1905.01436.pdf @ CVPR 2019&lt;/p&gt;

&lt;h2 id=&quot;egnn&quot;&gt;EGNN&lt;/h2&gt;

&lt;p&gt;Edge-Labeling Graph Neural Network for Few-shot Learning&lt;/p&gt;

&lt;h3 id=&quot;필요성&quot;&gt;필요성&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;딥러닝 시 데이터 수가 매우 적을 때&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;{러시안블루, 페르시안, 먼치킨}처럼 고양이의 종류를 구분하는 태스크를 풀 때&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;같은 범주의 데이터를 더 가깝게, 다른 범주의 데이터를 더 멀게 할 정도로 충분히 복잡하지 않을 때&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;방법&quot;&gt;방법&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;데이터셋&lt;/strong&gt;을 &lt;strong&gt;훈련&lt;/strong&gt;에 사용하는 &lt;strong&gt;서포트 데이터(support data)&lt;/strong&gt;와 &lt;strong&gt;테스트&lt;/strong&gt;에 사용하는 &lt;strong&gt;쿼리 데이터(query data)&lt;/strong&gt;로 구성&lt;/p&gt;

&lt;h4 id=&quot;퓨샷-러닝-태스크-n-way-k-shot-문제&quot;&gt;퓨샷 러닝 태스크: ’&lt;strong&gt;N-way K-shot 문제&lt;/strong&gt;’&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;N은 범주의 수, K는 범주별 서포트 데이터의 수&lt;/li&gt;
  &lt;li&gt;퓨샷 러닝은 이 K가 매우 작은 상황에서의 모델 학습을 가리킵니다&lt;/li&gt;
  &lt;li&gt;퓨샷 러닝 모델의 성능은 N과 반비례하며 K와는 비례하는 관계
    &lt;ul&gt;
      &lt;li&gt;K가 많을수록 이 범주에 해당하는 데이터를 예측하는 모델의 성능(추론 정확도)은 높아진다&lt;/li&gt;
      &lt;li&gt;반면, N의 값이 커질수록 모델 성능은 낮아진다&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;특장점&quot;&gt;특장점&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;거리 학습과 그래프 신경망의 장점을 합쳤다.&lt;/p&gt;

    &lt;p&gt;EGNN은 퓨샷 러닝 문제가 주어졌을 때 쿼리 데이터와 서포트 데이터가 그래프 구조 상에서 상호 작용하며 데이터 간 거리를 계산&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;사이드-프로젝트-적용-포인트&quot;&gt;사이드 프로젝트 적용 포인트&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;benchmark 실험: 범주(N)가 10개 이하이며, 서포트 데이터(K)가 1 또는 5개, 쿼리 데이터는 범주당 15개&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;5-way 10-shot 모델의 정확도 80% 수준&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;관련-개념&quot;&gt;관련 개념&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Siamese network&lt;/li&gt;
  &lt;li&gt;DNN (딥뉴럴넷)
    &lt;ul&gt;
      &lt;li&gt;CNN(convolutional neural networks)은 대표적인 DNN 응용 알고리즘이다.
        &lt;ul&gt;
          &lt;li&gt;CNN은 검증 손실 함수(verification loss function) 값을 최소화할 때까지 훈련&lt;/li&gt;
          &lt;li&gt;두 입력 데이터의 범주가 같은 상황에서 특징 공간상 거리가 멀면 커집니다.&lt;/li&gt;
          &lt;li&gt;두 데이터의 범주가 다른 상황에서 거리가 가까워져도 마찬가지고요.&lt;/li&gt;
          &lt;li&gt;이런 검증 손실 값을 최소화함으로써 모델은 범주가 같은 두 데이터의 거리가 가까워질수록 또는 범주가 다른 데이터의 거리가 멀어지게 하는 특징을 획득하게 됩니다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;GNN
    &lt;ul&gt;
      &lt;li&gt;인공 신경망으로 Dense graph(밀집 그래프) 구조 사용 (백터나 행렬이 아닌)
        &lt;ul&gt;
          &lt;li&gt;Dense graph(밀집 그래프)란? 모든 노드가 서로 완전히 연결된 것&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Meta learning (메타러닝)
    &lt;ul&gt;
      &lt;li&gt;기계 스스로 무엇인가를 배우는 ‘방법’ 또는 ‘지식’을 습득하는 기계학습 이론&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>Dasol Yoo</name></author><category term="AI" /><category term="Deep Learning" /><summary type="html">Reference</summary></entry><entry><title type="html">모델 성능 평가 지표</title><link href="https://dasolu.github.io//ai/2021/05/18/ml-vailidation.html" rel="alternate" type="text/html" title="모델 성능 평가 지표" /><published>2021-05-18T00:00:00+00:00</published><updated>2021-05-18T00:00:00+00:00</updated><id>https://dasolu.github.io//ai/2021/05/18/ml-vailidation</id><content type="html" xml:base="https://dasolu.github.io//ai/2021/05/18/ml-vailidation.html">&lt;p&gt;&lt;strong&gt;‘현재 딥러닝을 하고 있다면 축하한다. 딥러닝을 시작하려고 마음을 먹었다면 축하한다. 만약, 세상을 바꾸고 싶다면, 여기가 바로 그런 곳이다’.&lt;/strong&gt; -Andrew Ng-&lt;/p&gt;

&lt;h2 id=&quot;confusion-matrix&quot;&gt;Confusion matrix&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;정답
    &lt;ul&gt;
      &lt;li&gt;True를 &lt;strong&gt;True&lt;/strong&gt;로 예측: True &lt;strong&gt;Positive&lt;/strong&gt;(TP)&lt;/li&gt;
      &lt;li&gt;False를 &lt;strong&gt;False&lt;/strong&gt;로 예측: True &lt;strong&gt;Negative&lt;/strong&gt;(TN)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;오답
    &lt;ul&gt;
      &lt;li&gt;True를 &lt;strong&gt;False&lt;/strong&gt;로 예측: False &lt;strong&gt;Negative&lt;/strong&gt;(FN)&lt;/li&gt;
      &lt;li&gt;False를 &lt;strong&gt;True&lt;/strong&gt;로 예측: False &lt;strong&gt;Positive&lt;/strong&gt;(FP)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;precision&quot;&gt;Precision&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;정밀도 = 모델이 True라고 분류한 것 중에서 실제 True인 것의 비율&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Precision = True Positive/(True Positive+False Positive)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Positive 정답률, PPV(Positive Predictive Value)&lt;/li&gt;
  &lt;li&gt;모델이 True라고 분류한 데이터 중에 실제 True인 경우가 많을수록 정밀하다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;recall&quot;&gt;Recall&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;재현율 = 실제 True인 것 중에서 모델이 True라고 예측한 것의 비율&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Recall = True Positive/(True Positive+False Negative)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Sensitivity, hit rate&lt;/li&gt;
  &lt;li&gt;실제 데이터에서 True인 경우 중 모델이 True라고 말한 경우가 많을술록 재현이 잘되었다고 말한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;좋은-모델이란&quot;&gt;좋은 모델이란?&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Precision의 관점에서 실제 False이지만 True라고 분류한 경우의 수(&lt;strong&gt;False Positive&lt;/strong&gt;)가 적어야 하며,&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;동시에 Recall의 관점에서 실제 True이지만 False로 분류한 경우의 수(&lt;strong&gt;False Negative&lt;/strong&gt;)가 적어야 한다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;precision과-recall의-관계&quot;&gt;Precision과 Recall의 관계&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;False Positive&lt;/strong&gt;와 False Negative는 하나가 줄면 하나가 증가하는 trade-off 관계이므로 Precision과 Recall을 동시에 증가시키기 어렵다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;accuracy&quot;&gt;Accuracy&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;정확도 = 전체 중에서 정답을 맞춘 비율&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Accuracy = (True Positive + True Negative) / (TP+TN+FP+FN)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;사용하는 데이터가 True or False에 bias되었을 때 accuracy는 모델을 평가하는 적절한 지표가 아닐 수 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;

&lt;p&gt;https://sumniya.tistory.com/26&lt;/p&gt;</content><author><name>Dasol Yoo</name></author><category term="AI" /><category term="AI" /><category term="Vailidation" /><summary type="html">‘현재 딥러닝을 하고 있다면 축하한다. 딥러닝을 시작하려고 마음을 먹었다면 축하한다. 만약, 세상을 바꾸고 싶다면, 여기가 바로 그런 곳이다’. -Andrew Ng-</summary></entry><entry><title type="html">DFS (Depth-First Search) 알고리즘</title><link href="https://dasolu.github.io//algorithm/2021/05/05/DFS.html" rel="alternate" type="text/html" title="DFS (Depth-First Search) 알고리즘" /><published>2021-05-05T00:00:00+00:00</published><updated>2021-05-05T00:00:00+00:00</updated><id>https://dasolu.github.io//algorithm/2021/05/05/DFS</id><content type="html" xml:base="https://dasolu.github.io//algorithm/2021/05/05/DFS.html">&lt;p&gt;DFS (Depth-First-Search)은 깊이 우선 탐색 알고리즘의 줄임말입니다.&lt;/p&gt;

&lt;h2 id=&quot;필요성&quot;&gt;필요성&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;한 node에서 &lt;strong&gt;목표 node로 도착할 수 있는 경로(short-path)&lt;/strong&gt;를 찾을 때&lt;/li&gt;
  &lt;li&gt;예) 미로찾기, 재귀, 백트레킹&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;구현&quot;&gt;구현&lt;/h2&gt;

&lt;p&gt;구현 방법은 두 가지만 기억하면 됩니다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;문제를 그래프로 구현한다.
    &lt;ul&gt;
      &lt;li&gt;인접 리스트(adjacency list)을 사용해서 이웃 node와의 관계를 기록한다.
        &lt;ul&gt;
          &lt;li&gt;장점: 인접 행렬(모든 노드의 관계 저장)보다 효율적인 메모리 사용 (연결된 노드만들 저장하기 때문)&lt;/li&gt;
          &lt;li&gt;단점: 두 노드가 연결되어있는지 확인하는 속도 느림 (특정 노드와 연결된 모든 인접 노드를 순회해야하기 때문)
            &lt;ul&gt;
              &lt;li&gt;이런 속성 덕분에 특정 노드와 연결된 모든 인접 노드를 순회해야하는 문제에서 메모리 효율성을 높일 수 있다.&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;깊이 우선 탐색 방법을 사용한다.
    &lt;ul&gt;
      &lt;li&gt;스택를 생성하고 스택에 첫 번째 노드 넣기&lt;/li&gt;
      &lt;li&gt;스택에서 노드 꺼내기&lt;/li&gt;
      &lt;li&gt;노드의 방문 여부를 조사
        &lt;ul&gt;
          &lt;li&gt;목적: 탐색 스택에 같은 노드가 반복해서 추가되어 무한 탐색되는 경우를 방지하기 위함&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;노드를 방문하지 않았다면 노드를 방문한 것으로 표시하고 자식 노드 탐색 시작&lt;/li&gt;
      &lt;li&gt;자식 노드 중 방문하지 않은 자식 노드만을 탐색 스택에 추가&lt;/li&gt;
      &lt;li&gt;탐색 스택에 있는 노드가 없어지거나 답을 찾을 때까지 위의 과정 반복&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Make Graph
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# n:node개수, m:edge개수, v:시작 node
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;# node 개수 만큼 빈 list를 만들어준다.
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;n1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;# node에 연결된 자식 node를 기록한다.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deque&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# stack에 노드가 없을 때까지
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;node&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#방문하지 않은 노드만 방문한다.
&lt;/span&gt;          	&lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;#노드를 방문한 것으로 기록한다.
&lt;/span&gt;            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;child&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# pop은 오른쪽 원소부터 꺼내므로 내림차순 정렬해준다.
&lt;/span&gt;                &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;child&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 방문하지 않은 자식 노드를 큐에 추가한다.
&lt;/span&gt;                    &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;child&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;재귀함수를 이용하는 방법&lt;/p&gt;

&lt;p&gt;​	참고 서적: 이것이 코딩테스트다 by 나동빈&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# 현재 노드를 방문 처리
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# 현재 노드와 연결된 다른 노드를 재귀로 방문
&lt;/span&gt;  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;dfs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visited&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Dasol Yoo</name></author><category term="Algorithm" /><category term="Algorithm" /><summary type="html">DFS (Depth-First-Search)은 깊이 우선 탐색 알고리즘의 줄임말입니다.</summary></entry><entry><title type="html">Mutable &amp;amp; Immutable</title><link href="https://dasolu.github.io//basic/2021/05/02/python-function-mutable.html" rel="alternate" type="text/html" title="Mutable &amp;amp; Immutable" /><published>2021-05-02T00:00:00+00:00</published><updated>2021-05-02T00:00:00+00:00</updated><id>https://dasolu.github.io//basic/2021/05/02/python-function-mutable</id><content type="html" xml:base="https://dasolu.github.io//basic/2021/05/02/python-function-mutable.html">&lt;p&gt;python 함수 밖에 있는 데이터를 함수 안에 가져와서 연산하고 변화된 데이터를 return해야할 때가 있죠!&lt;/p&gt;

&lt;p&gt;python 기초 공부를 마치신 분들은 integer를 함수 안으로 가져오는 방법에 대해서 익숙하실겁니다.&lt;/p&gt;

&lt;p&gt;저도 integer에 대해서 공부했기때문에, list를 가져오는 방법도 동일할 것이라고 생각했습니다.&lt;/p&gt;

&lt;p&gt;📌 그렇지만 list는 integer와 달리 불러오지 않아도 함수 안에서 바로 사용할 수 있습니다‼️&lt;/p&gt;

&lt;p&gt;이유가 뭘까요?&lt;/p&gt;

&lt;h2 id=&quot;mutable과-immutable&quot;&gt;mutable과 immutable&lt;/h2&gt;

&lt;h3 id=&quot;필요성&quot;&gt;필요성&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;python은 객체 지향이므로 &lt;strong&gt;객체 생성 후 변경 여부 관리가 중요&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;예를 들어 객체를 &lt;strong&gt;함수의 parameter로 전달할 때&lt;/strong&gt;, &lt;strong&gt;변경 가능한 객체의 관리가 필요&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;mutable-참조-객체&quot;&gt;mutable (참조 객체)&lt;/h3&gt;

&lt;p&gt;변수에 저장되는 것? &lt;strong&gt;객채의 값들이 저장된 참조&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;따라서 실제 &lt;strong&gt;값 변경이 가능&lt;/strong&gt;&lt;/p&gt;

&lt;h4 id=&quot;종류&quot;&gt;종류&lt;/h4&gt;

&lt;p&gt;list, dic, set&lt;/p&gt;

&lt;h4 id=&quot;적용-방법&quot;&gt;적용 방법&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;함수의 parameter 또는 변수로 사용하며 &lt;strong&gt;원본 값 변경을 하고 싶은 경우&lt;/strong&gt;?
    &lt;ul&gt;
      &lt;li&gt;참조만 복사하는 shallow copy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;원본 값 변경하지 않으려면&lt;/strong&gt;?
    &lt;ul&gt;
      &lt;li&gt;참조와 전체 값을 복사하여 다른 객체를 생성하는 &lt;strong&gt;deep copy&lt;/strong&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;immutable-값-객체&quot;&gt;immutable (값 객체)&lt;/h3&gt;

&lt;p&gt;변수에 저장되는 것? &lt;strong&gt;객채의 값&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;따라서 &lt;strong&gt;변경 불가 (변수 치환은 가능)&lt;/strong&gt;&lt;/p&gt;

&lt;h4 id=&quot;종류-1&quot;&gt;종류&lt;/h4&gt;

&lt;p&gt;tuple, string, Numbers(숫자형)&lt;/p&gt;

&lt;h2 id=&quot;mutable은-항상-변경될까&quot;&gt;mutable은 항상 변경될까?&lt;/h2&gt;

&lt;h3 id=&quot;정답-아니다️&quot;&gt;🌟정답: 아니다‼️&lt;/h3&gt;

&lt;p&gt;📌&lt;strong&gt;전체를 대입하는 경우 새로운 주소를 가지는 지역 변수로 인식&lt;/strong&gt;(가정)된다.&lt;/p&gt;

&lt;p&gt;따라서 원본 변경이 되지 않는다.&lt;/p&gt;

&lt;p&gt;📌오직 &lt;strong&gt;mutable 객체의 일부를 바꾸는 경우에 전역변수&lt;/strong&gt;로 인식되어,&lt;/p&gt;

&lt;p&gt;원본 변경이 된다.&lt;/p&gt;

&lt;h3 id=&quot;변경-안되는-경우&quot;&gt;변경 안되는 경우&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; [2, 2] 지역 변수로 인식
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140724879389376 함수 밖 x와 다른 새로운 주소를 가리킴
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[1, 1]
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140724621066624
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[1, 1] 원본 변경 안됨
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140724621066624 원본과 동일한 주소를 가짐. 변경 안됨
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;변경되는-경우&quot;&gt;변경되는 경우&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; [2, 1] 전역 변수로 인식
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;1140724633650432 함수 밖 원본 x와 동일한 주소를 가짐
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[1, 1]
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140724633650432
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[2, 1] 원본 변경됨
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;1140724633650432 원본과 동일한 주소를 가짐
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;shallow--deep-copy&quot;&gt;shallow &amp;amp; deep copy&lt;/h2&gt;

&lt;h4 id=&quot;shallow&quot;&gt;shallow&lt;/h4&gt;

&lt;p&gt;객체의 &lt;strong&gt;주소&lt;/strong&gt;를 복사한다.&lt;/p&gt;

&lt;p&gt;📌 따라서 복사한 값을 변경하면 원본도 바뀐다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140225591189056 140225591189056
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#-&amp;gt; [0, 100] [0, 100]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;deep-copy&quot;&gt;deep copy&lt;/h4&gt;

&lt;p&gt;객체의 값을 복사하여 주소가 다른 새로운 객체를 생성한다.&lt;/p&gt;

&lt;p&gt;📌 따라서 복사한 값을 변경해도 원본은 바뀌지 않는다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140225331150528 140225591181376
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[0, 100] [0, 1]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;copy&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;deepcopy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#-&amp;gt;140225591154176 140225331159744
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy_a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#-&amp;gt;[0, 100] [0, 1]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;함수-밖의-integer를-함수-안으로-가져와-변경하는-방법&quot;&gt;함수 밖의 integer를 함수 안으로 가져와 변경하는 방법&lt;/h2&gt;

&lt;p&gt;두 가지 방법이 알려져 있습니다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;매개변수&lt;/strong&gt;로 가져오기
    &lt;ul&gt;
      &lt;li&gt;def function(매개변수)에서 “매개변수” 자리에 integer를 넣어준다.&lt;/li&gt;
      &lt;li&gt;함수 안에서 연산한다.&lt;/li&gt;
      &lt;li&gt;변화된 integer 값을 (new_integer) return 으로 내보낸다.&lt;/li&gt;
      &lt;li&gt;‼️&lt;strong&gt;주의) 새로운 변수를 return하는 것 뿐이지, 원본 값은 변경되지 않는다.&lt;/strong&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 2
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387968 지역변수이므로 다른 주소를 가짐
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 지역 변수의 주소와 같은 주소를 return
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387936
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 2
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387968 함수 내부에서 사용하던 지역변수와 같은 주소 return
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 1 원본 값 변경 안됨
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387936 원본과 동일한 주소
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;global&lt;/strong&gt;을 사용하기
    &lt;ul&gt;
      &lt;li&gt;매개변수를 사용하지 않고 global interger로 가져온다.&lt;/li&gt;
      &lt;li&gt;함수 안에서 연산한다.&lt;/li&gt;
      &lt;li&gt;return으로 변화된 값을 내보낸다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;global&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387936 global을 사용하여 원본과 동일한 주소 가짐
&lt;/span&gt;    
    &lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# immutable 객체는 연산을 통해 새로운 객체 생성
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 2
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387968 새로운 주소를 가지는 새 객체
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 지역 변수의 주소와 같은 주소를 return
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387936
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 2
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387968 함수 내부에서 사용하던 지역변수와 같은 주소 return
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; 2 원본 값 변경
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;integer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;4344387968 원본과 다른 주소 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;함수-밖의-list를-함수-안으로-가져오는-방법&quot;&gt;함수 밖의 list를 함수 안으로 가져오는 방법&lt;/h2&gt;

&lt;p&gt;📌list는 함수 밖 list를 사용할 때, 그냥 바로 사용하면 됩니다.&lt;/p&gt;

&lt;p&gt;​	integer와 달리 매개변수로 데러오지 않아도, global로 선언하지 않아도 됩니다‼️&lt;/p&gt;

&lt;p&gt;그 이유는? list가 mutable객체이기 때문입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;l&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    
&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#-&amp;gt; [101, 2]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;list와-integer-함수-매개변수-사용-방법-차이-이유&quot;&gt;list와 integer 함수 매개변수 사용 방법 차이 이유?&lt;/h2&gt;

&lt;p&gt;📌 integer는 &lt;strong&gt;immutable&lt;/strong&gt;(변화 불가능한)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;integer가 정의되면 특정 주소에 저장되기 때문에, integer를 복사하고 그 값을 연산해도 원본 값은 변화하지 않는다.&lt;/li&gt;
  &lt;li&gt;따라서 매개변수 또는 global로 직접 값을 가져와서 연산해줘야 원본에 변화를 줄 수 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌list는 &lt;strong&gt;mutable&lt;/strong&gt;(변화 가능한)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;list.pop()과 같은 연산은 list 원본에 변화를 줄 수 있다.&lt;/li&gt;
  &lt;li&gt;따라서 &lt;strong&gt;함수 내부에서 list의 연산은 함수 밖의 list 원본에 영향을 미친다.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;https://stackoverflow.com/questions/23029727/why-do-list-operations-in-python-operate-outside-of-the-function-scope&lt;/li&gt;
  &lt;li&gt;포스코 AI&amp;amp;BigData 아카데미 수업&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Dasol Yoo</name></author><category term="Basic" /><category term="Basic" /><category term="CodingTest" /><summary type="html">python 함수 밖에 있는 데이터를 함수 안에 가져와서 연산하고 변화된 데이터를 return해야할 때가 있죠!</summary></entry><entry><title type="html">BAEKJOON 백준 시작 방법 초보자 길라잡이</title><link href="https://dasolu.github.io//codingtest/2021/04/30/backjoon-basic.html" rel="alternate" type="text/html" title="BAEKJOON 백준 시작 방법 초보자 길라잡이" /><published>2021-04-30T00:00:00+00:00</published><updated>2021-04-30T00:00:00+00:00</updated><id>https://dasolu.github.io//codingtest/2021/04/30/backjoon-basic</id><content type="html" xml:base="https://dasolu.github.io//codingtest/2021/04/30/backjoon-basic.html">&lt;p&gt;프로그래머스만 사용하다가 백준을 시작하면 테스트 값 입력 방식이 달라서 당황스러울 수 있습니다.&lt;/p&gt;

&lt;p&gt;백준은 프로그래머스와 다르게 입력 값을 직접 받아서 처리해줘야하기 때문입니다.&lt;/p&gt;

&lt;p&gt;백준 &lt;a href=&quot;https://www.acmicpc.net/problem/13023&quot;&gt;ABCDE 문제 13023번&lt;/a&gt;을 예로 들며 백준 문제 풀기 방법에 대해 익혔습니다.&lt;/p&gt;

&lt;h2 id=&quot;입력-예시&quot;&gt;입력 예시&lt;/h2&gt;

&lt;p&gt;프로그래머스에서는 함수를 만들고 제출하면 함수에 입력 값이 자동으로 입력되었었죠?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;하지만 백준에서는 답안을 제출할 때 입력을 받아서 처리한뒤 사용하는 코드를 추가해줘야합니다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;예를 들어, 백준에서는 아래와 같이 배열도 리스트도 아닌 숫자 모음이 입력 예시로 주어집니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;입력-값-받아오기&quot;&gt;입력 값 받아오기&lt;/h2&gt;

&lt;p&gt;백준에서 공식적으로 추천하는 방법은 &lt;strong&gt;input()&lt;/strong&gt; 사용입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;그런데 문제 풀이를 구글에 검색해보면 &lt;strong&gt;sys.stdin.readline()&lt;/strong&gt;을 사용합니다. (stdin은 standard input을 의미합니다.)&lt;/p&gt;

&lt;p&gt;📌&lt;strong&gt;input()대신 sys.stding.readline을 사용하면 input이 여러 줄인 경우 시간 초과를 막을 수 있습니다.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📌&lt;strong&gt;sys.stdin.readline()&lt;/strong&gt;은 입력 값을 &lt;strong&gt;한 줄 단위로 읽고 str 자료형으로 저장&lt;/strong&gt;합니다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;따라서 input이 여러 줄이라면 for loop에서 &lt;strong&gt;sys.stdin.readline()&lt;/strong&gt;를 사용하여 한 줄씩 읽어주면 됩니다.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;따라서 str 자료형을 int로 바꿔줘야합니다.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 입력 받기
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sy&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readline&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;# 한 줄 단위로 입력되고 str으로 저장된다.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;한-줄-읽기&quot;&gt;한 줄 읽기&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 한 줄씩 읽기
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;# 입력의 첫 번째 줄의 str을 모두 int로 바꾼다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;5 4
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;0 1
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#-&amp;gt;1 2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;여러-줄-읽기-반복문-사용&quot;&gt;여러 줄 읽기: 반복문 사용&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 여러 줄 반복문으로 읽기
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;print-시간-단축-방법&quot;&gt;print 시간 단축 방법&lt;/h3&gt;

&lt;h4 id=&quot;integer&quot;&gt;integer&lt;/h4&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;list&quot;&gt;list&lt;/h4&gt;

&lt;p&gt;시간은 단축되지만 메모리 사용은 증가한다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;' '&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Dasol Yoo</name></author><category term="CodingTest" /><category term="CodingTest" /><category term="BAEKJOON" /><summary type="html">프로그래머스만 사용하다가 백준을 시작하면 테스트 값 입력 방식이 달라서 당황스러울 수 있습니다.</summary></entry></feed>