<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>bora.log</title>
        <link>https://velog.io/</link>
        <description>컴공 대학생의 공부기록</description>
        <lastBuildDate>Thu, 24 Oct 2024 04:19:56 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>bora.log</title>
            <url>https://velog.velcdn.com/images/yeonbo_ra/profile/45a3d848-4bd1-43a1-82d6-82ad5745c7ea/social_profile.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. bora.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/yeonbo_ra" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[Java] 06. GUI & Swing]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-06.-GUI-Swing</link>
            <guid>https://velog.io/@yeonbo_ra/Java-06.-GUI-Swing</guid>
            <pubDate>Thu, 24 Oct 2024 04:19:56 GMT</pubDate>
            <description><![CDATA[<h2 id="1-introdunction-to-gui-programming">1. Introdunction to GUI Programming</h2>
<h3 id="guigraphical-user-interface">GUI(Graphical User Interface)</h3>
<ul>
<li>유저가 직접 정보를 볼 수 있는 화면</li>
<li>유저와 상호작용 하는 방식. 개발을 모르더라도 사용 가능하도록 함.
  ex) button, text fields, menus, windows</li>
</ul>
<h3 id="java-swing">Java Swing</h3>
<ul>
<li>GUI를 위해 미리 정의해놓은 class들의 모음</li>
<li>Platform Independent : 특정 OS에 국한되지 않음</li>
<li>Rich and Customizable Component : 대부분의 component와 기능 제공 + 개발자가 커스텀 가능</li>
</ul>
<h3 id="key-concept-of-swing">Key Concept of Swing</h3>
<ul>
<li>Component-Based Model<ul>
<li>다양한 Component 조합해서 화면 구성</li>
<li>container ⊃ butten, text field</li>
</ul>
</li>
<li>Event-Driven Model<ul>
<li>Event 를 통해 유저와 상호작용 함
  ex) button 클릭 / text 입력</li>
<li>Component 가 이벤트를 생성하면 event listener 가 들음.</li>
</ul>
</li>
<li>Hierarchical Organization<ul>
<li>Component 들은 위계 질서를 가지고 정렬되어 있음</li>
<li>복잡하게 구성된 유저 인터페이스 생성 가능.</li>
</ul>
</li>
</ul>
<h2 id="2-components--containers">2. Components &amp; Containers</h2>
<h3 id="containers">Containers</h3>
<ul>
<li><p>Component를 가지고 구성하는 도화지.</p>
</li>
<li><p>GUI 레이아웃을 구성할 때 필수적</p>
<h4 id="top-level">Top level</h4>
<ul>
<li><code>JFrame</code> : main 창. 이 아래 panel(⊃ component) 배치</li>
<li><code>JDialog</code> : 팝업창. 경고, 알림용</li>
<li><code>JApplet</code> : 보안 이슈로 잘 사용하지 않음</li>
</ul>
<h4 id="intermidiate-level-→-공간-구분-시-사용">Intermidiate level → 공간 구분 시 사용</h4>
<ul>
<li><code>JPanel</code> : component끼리 모아두는 곳<ul>
<li>layout manager 통해 요소 정렬</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li>Container 내부에 또 다른 Container 넣을 수 있음.</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/1ab358c4-3709-4655-a09d-9c339ab12e4d/image.png" alt=""></p>
<h3 id="basic-components">Basic Components</h3>
<ul>
<li>GUI 를 만들 때 기본 클래스</li>
<li>모든 Component는 <code>java.swing.JComponent</code> 클래스를 상속 받음<ul>
<li>기본 값 : size, position, color</li>
<li>기본 행동 : responsing user input </li>
</ul>
</li>
<li>한계<ul>
<li>Lack of Sophistication : 복잡한 구조를 만들기엔 부족함.</li>
<li>Limited Customization : 실시간 업데이트가 안됨. 한 번 만든 후에는 변화 불가</li>
</ul>
</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/da5df33b-f2e3-420c-97b8-b5a6337de87c/image.png" alt=""></p>
<h4 id="종류">종류</h4>
<ul>
<li><code>JButton</code> : 클릭될 수 있는 버튼</li>
<li><code>JLabel</code> : 텍스트나 이미지를 보여줌 (이후 수정 불가)</li>
<li><code>JTextField</code> : 한 줄짜리 유저가 입력 가능한 입력 공간</li>
<li><code>JPasswordField</code> : 입력한 값이 보이지 않는 입력 공간</li>
</ul>
<h2 id="3-advanced-components">3. Advanced Components</h2>
<h4 id="jtree">JTree</h4>
<ul>
<li>계층적인 데이터 구조를 나타낼 때 사용</li>
<li>node는 확장하거나 나눠질 수 있음</li>
</ul>
<pre><code class="language-java">import javax.swing.JFrame;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

public class BasicJTreeExample extends JFrame {
    public BasicJTreeExample() {
        setTitle(&quot;Basic JTree Example&quot;);
        setSize(300, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create a root node
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(&quot;Root&quot;);

        // Ad first level child nodes
        DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(&quot;Child 1&quot;);
        DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(&quot;Child 2&quot;);

        // Add second level child nodes to child 1
        DefaultMutableTreeNode grandChild1 = new DefaultMutableTreeNode(&quot;grandChild 1&quot;);
        DefaultMutableTreeNode grandChild2 = new DefaultMutableTreeNode(&quot;grandChild 2&quot;);

        child1.add(grandChild1);
        child1.add(grandChild2);

        // Construct the tree structure
        root.add(child1);
        root.add(child2);

        // Create a JTree
        JTree tree = new JTree(root);

        // Add the tree to the frame
        JScrollPane TreeView = new JScrollPane(tree);
        add(TreeView);

        setVisible(true);
    }

    public static void main(String[] args) {
        new BasicJTreeExample();
    }
}</code></pre>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/072ca8b5-a9f7-421f-890d-6c00b7fac515/image.png" alt=""></p>
<ul>
<li><code>JScrollPane</code> 에서만 사용 가능<ul>
<li>기본 Panel은 사이즈가 고정. 그렇지만 Tree는 얼마나 길지 모르므로 ScrollPane 사용.</li>
<li><code>JTree</code> ⊂ <code>JScrollPane</code> ⊂ <code>JPanel</code> 가능</li>
</ul>
</li>
</ul>
<h3 id="jtable">JTable</h3>
<ul>
<li>표 형식의 데이터 구조를 나타낼 때 사용</li>
<li>열 정렬, cell 수정, custom cell rendering 지원<pre><code class="language-java">import javax.swing.*;
import javax.swing.table.DefaultTableModel;
</code></pre>
</li>
</ul>
<p>public class BasicJTableExample extends JFrame {
    public BasicJTableExample() {
        setTitle(&quot;Basic JTable Example&quot;);
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</p>
<pre><code>    // Define column names for the table
    String[] columnNames = {&quot;ID&quot;, &quot;Name&quot;, &quot;Age&quot;, &quot;Occupation&quot;};

    // Define data for the table (2D array)
    Object[][] data = {
            {1, &quot;Alice&quot;, 30, &quot;Engineer&quot;},
            {2, &quot;Bob&quot;, 25, &quot;Designer&quot;},
            {3, &quot;Charlie&quot;, 35, &quot;Teacher&quot;},
            {4, &quot;Dave&quot;, 28, &quot;Developer&quot;}
    };

    // Create table model with the specified data and column names
    DefaultTableModel model = new DefaultTableModel(data, columnNames);

    // Create JTable with the model
    JTable table = new JTable(model);

    // Add the table to a scroll pane
    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);

    setVisible(true);
}

public static void main(String[] args) {
    new BasicJTableExample();
}</code></pre><p>}</p>
<pre><code>![](https://velog.velcdn.com/images/yeonbo_ra/post/e47b0ef5-02f5-4d8a-9f61-dcad335934ee/image.png)
- `JTree`와 마찬가지로 `JScrollPane`에서만 사용 가능

### JTappedPane
- 여러 탭의 인터페이스를 가능하게 함. 여러 패널 &amp; 섹션이 한 화면에 나올 수 있음
- `JTappedPane` 안에 `Panel` 넣기
```java
import javax.swing.*;

public class BasicJTabbedPaneExample extends JFrame {
    public BasicJTabbedPaneExample() {
        setTitle(&quot;Basic JTabbedPane Example&quot;);
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create JTabbedPane
        JTabbedPane tabbedPane = new JTabbedPane();

        // Create panels for each tab
        JPanel panel1 = new JPanel();
        panel1.add(new JLabel(&quot;This is the first tab.&quot;));

        JPanel panel2 = new JPanel();
        panel2.add(new JLabel(&quot;This is the second tab.&quot;));

        JPanel panel3 = new JPanel();
        panel3.add(new JLabel(&quot;This is the third tab.&quot;));

        // Add panels to JTabbedPane with titles
        tabbedPane.addTab(&quot;Tab 1&quot;, panel1);
        tabbedPane.addTab(&quot;Tab 2&quot;, panel2);
        tabbedPane.addTab(&quot;Tab 3&quot;, panel3);

        // Add the tabbed pane to the frame
        add(tabbedPane);

        setVisible(true);
    }

    public static void main(String[] args) {
        new BasicJTabbedPaneExample();
    }
}</code></pre><p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/834b20ea-4a99-4b9b-9dcd-71153a0b07a6/image.png" alt=""></p>
<h4 id="jsplitpane">JSplitPane</h4>
<ul>
<li>컨테이너를 두 개의 크기 재지정 가능한 패널로 나눔. 유저가 드래그해 사이즈 조절 가능</li>
<li><code>JTappedPane</code> 안에 어떻게 나눌건지 넣고, 각각 위치할 <code>Panel</code> 넣기 <pre><code class="language-java">import javax.swing.*;
</code></pre>
</li>
</ul>
<p>public class BasicJSplitPaneExample extends JFrame {
    public BasicJSplitPaneExample() {
        setTitle(&quot;Basic JSplitPane Example&quot;);
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</p>
<pre><code>    // Create two panels to split
    JPanel leftPanel = new JPanel();
    leftPanel.add(new JLabel(&quot;This is the left panel.&quot;));

    JPanel rightPanel = new JPanel();
    rightPanel.add(new JLabel(&quot;This is the right panel.&quot;));

    // Create JSplitPane with the two panels
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
    splitPane.setDividerLocation(150); // Initial divider position

    // Add the split pane to the frame
    add(splitPane);

    setVisible(true);
}

public static void main(String[] args) {
    new BasicJSplitPaneExample();
}</code></pre><p>}</p>
<pre><code>![](https://velog.velcdn.com/images/yeonbo_ra/post/19053b1c-a68f-4473-ac25-dd08bc4e70a4/image.png)

#### Extra
- `JSlider` : 유저가 슬라이더로 값을 조절할 수 있게 함 (ex. 볼륨 조절)
  - `slider = new JSlider(최소, 최대, 초기값);`
- `JSpinner` : 유저가 여러 값 중 선택할 수 있도록 함
  - `spinner = new JSpinner(new SpinnerNumberModel(초기값, 최소, 최대, 증가량));`
- `JProgressBar` : 작업률을 보여줌
  - `progressBar = new JProgressBar(초기값, 최대);`

![](https://velog.velcdn.com/images/yeonbo_ra/post/2e16e024-5706-4b09-80f5-d40a6386645e/image.png)

## 4. Layout Manager
- 기본적인 레이아웃들
- component들을 알아서 크기 조절 &amp; 배치해줌

- `FlowLayout` 
  - component를 한 줄에 배치, 줄이 모두 차면 다음 줄로 넘김(반응형,
  - 간단한 왼 → 오른쪽 레이아웃
  ![](https://velog.velcdn.com/images/yeonbo_ra/post/d0cb1bcc-bd41-4c88-981b-6ef3aac6b784/image.png)

- `BorderLayout` 
  - component 들을 나눠진 다섯 영역으로 나눔
  - North, South, East, West, Center
``` java
JFrame frame = new JFrame(&quot;BorderLayout&quot;);
frame.setLayout(new BorderLayout());

frame.add(new JButton(&quot;North&quot;), BorderLayout.NORTH);
frame.add(new JButton(&quot;South&quot;), BorderLayout.SOUTH);
frame.add(new JButton(&quot;West&quot;), BorderLayout.WEST);
frame.add(new JButton(&quot;East&quot;), BorderLayout.EAST);
frame.add(new JButton(&quot;Center&quot;), BorderLayout.CENTER);

frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);</code></pre><p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/2295bbf7-de47-4cfc-954e-f1c4356076aa/image.png" alt=""></p>
<ul>
<li><p><code>GridLayout</code> </p>
<ul>
<li>특정한 행과 열로 나뉜 그리드에 Component 배치</li>
<li>각 칸마다의 크기가 같음<pre><code class="language-java">frame.setLayout(new GridLayout(2, 2)); // 2 * 2 행렬</code></pre>
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/e0aa0997-387e-4ced-874b-584b2bdd1471/image.png" alt=""></li>
</ul>
<h2 id="5-event-handling">5. Event Handling</h2>
<h3 id="event-handling">Event Handling</h3>
<ul>
<li>GUI component 들로 유저 상호작용을 관리하는 과정<ul>
<li>클릭, 키입력, 마우스 움직임 등<h4 id="event-listener">Event Listener</h4>
</li>
<li>component 에서 발생시킨 특정한 타입의 event를 듣는 interface</li>
<li><code>ActionListener</code> : 버튼 클릭 같은 액선 이벤트를 들음</li>
<li><code>MouseListener</code> : 마우스 클릭이나 움직임 같은 마우스 이벤트를 들음</li>
<li><code>KeyListener</code> : 키 입력이나 떼기 같은 키보드 이벤트를 들음</li>
</ul>
</li>
</ul>
<h3 id="process-of-event-handling">Process of Event Handling</h3>
<ul>
<li><p>Event Source : 이벤트를 만드는 Component </p>
</li>
<li><p>Event Listener </p>
<ul>
<li>특정한 이벤트를 듣는 인터페이스</li>
<li>Event Source와 붙어있음</li>
</ul>
</li>
<li><p>Event Object : 이벤트의 타입, 소스에 대한 캡슐화 된 정보</p>
</li>
<li><p>Event Source가 이벤트를 생성하면 Event Listener 가 그것을 듣고 Event Object를 생성함.</p>
</li>
</ul>
</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/32edf65f-3dd8-4ad1-ad63-2134b181dda1/image.png" alt=""></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[이산구조] 05. Algorithms ]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-05.-Algorithms</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-05.-Algorithms</guid>
            <pubDate>Sat, 19 Oct 2024 10:49:20 GMT</pubDate>
            <description><![CDATA[<h1 id="module-5-algorithms">Module #5: Algorithms</h1>
<h2 id="1-property-of-algorithms">1. Property of Algorithms</h2>
<h4 id="알고리즘--계산을-하거나-문제를-풀기-위한-정확한-명령의-유한한-서열">알고리즘 : 계산을 하거나, 문제를 풀기 위한 정확한 명령의 유한한 서열</h4>
<ul>
<li>프로그램은 알고리즘을 구현한다.</li>
</ul>
<h3 id="properties">Properties</h3>
<ul>
<li>Input : 특정한 집합으로부터의 입력값</li>
<li>Output : 입력한 값에 대한 출력값</li>
<li>Definiteness : 알고리즘의 단계는 명확히 정의되어야 함</li>
<li>Correctness : 어떠한 입력값에 대해서도 항상 정답을 구해야 함</li>
<li>Finiteness : 유한한 횟수의 단계를 거쳐 답을 도출해야 함</li>
<li>Effectiveness : 정확하고 유한한 시간 내에 수행해야 함</li>
<li>Generality : 조건을 만족하는 모든 입력에 대해 적용 가능해야 함</li>
<li>Efficiency : 최소한의 시간 &amp; 공간을 사용 해야 함</li>
</ul>
<h3 id="pseudocode">Pseudocode</h3>
<ul>
<li>의사 코드, 알고리즘을 표현하는 방법</li>
</ul>
<blockquote>
<p><strong>procedure</strong> <code>이름</code>(인자: 타입)</p>
</blockquote>
<p>ex) <strong>procedure</strong> <em>maximum</em>(L: list of integers)</p>
<blockquote>
<p><em>변수</em> := 표현</p>
</blockquote>
<ul>
<li>의사 코드에선 정형화 되지 않은 표현도 허용된다.
v := 3x + 7
x := the largest integer in the list L
swap x and y
→ 실제 프로그래밍 언어에선 사용 불가</li>
</ul>
<blockquote>
<p><strong>begin</strong>
<em>statements</em>
<strong>end</strong></p>
<blockquote>
<p><strong>if</strong> <em>condition</em>
<strong>then</strong> <em>statement</em>
→ 프로그래밍 언어의 if</p>
</blockquote>
<blockquote>
<p><strong>while</strong> <em>condition</em>
<em>statement</em>
→ 프로그래밍 언어의 while</p>
</blockquote>
<blockquote>
<p><strong>for</strong> <em>var</em> := <em>initial</em> <strong>to</strong> <em>final</em>
<em>statement</em>
→ 프로그래밍 언어의 for</p>
</blockquote>
</blockquote>
<blockquote>
<p>{comment}
→ 주석, 설명을 덧붙이기 위해 사용</p>
</blockquote>
<ul>
<li><p>example</p>
<blockquote>
<p><strong>procedure</strong> <code>max</code>($a_1, a_2, ...,a_n$ : intergers)
&nbsp;&nbsp;&nbsp;&nbsp;<em>max</em> := $a_1$ &nbsp;&nbsp;&nbsp;&nbsp; {largest element so far}
&nbsp;&nbsp;&nbsp;&nbsp;for i := 2 to n &nbsp;&nbsp;&nbsp;&nbsp; {go thru rest of elems}
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if <em>max</em> &lt; $a_i$ then <em>max</em> := $a_i$ &nbsp;&nbsp;&nbsp;&nbsp; {found bigger?}
  &nbsp;&nbsp;&nbsp;&nbsp;{이 지점에서 max는 list의 원소 중 가장 큰 정수와 같다}
&nbsp;&nbsp;&nbsp;&nbsp;return <em>max</em> {max is the largest element}</p>
</blockquote>
</li>
<li><p>example </p>
<blockquote>
<p><strong>procedure</strong> <code>sum</code>($a_1, a_2, ...,a_n$ : intergers)
&nbsp;&nbsp;&nbsp;&nbsp; s := 0 &nbsp;&nbsp;&nbsp;&nbsp; {sum of elems so far}
&nbsp;&nbsp;&nbsp;&nbsp; <strong>for</strong> i := 1 <strong>to</strong> n &nbsp;&nbsp;&nbsp;&nbsp; {go thru all elems}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s := s + a<sub>i</sub> &nbsp;&nbsp;&nbsp;&nbsp; {add current item}
&nbsp;&nbsp;&nbsp;&nbsp; {이 지점에서 s는 모든 list 안의 값의 합}
&nbsp;&nbsp;&nbsp;&nbsp;<strong>return</strong> <em>s</em></p>
</blockquote>
</li>
</ul>
<h2 id="2-algorithms-for-searching-and-sorting">2. Algorithms for Searching and Sorting</h2>
<h3 id="search-algorithm">Search Algorithm</h3>
<h4 id="linear-search">Linear Search</h4>
<ul>
<li>선형 탐색 : 차례대로 x를 다음 원소와 비교하며 일치하는지 확인하는 알고리즘<blockquote>
<p><strong>procedure</strong> <code>linear search</code>(x : integer, $a_1, a_2, ..., a_n$: distinct integers)
&nbsp;&nbsp;&nbsp;&nbsp;i := 1
&nbsp;&nbsp;&nbsp;&nbsp;<strong>while</strong> (i ≤ n and x ≠ $a_i$)
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i := i+1
&nbsp;&nbsp;&nbsp;&nbsp;<strong>if</strong> i ≤ n <strong>then</strong> <em>location</em> := i
&nbsp;&nbsp;&nbsp;&nbsp;<strong>else</strong> <em>location</em> := i
&nbsp;&nbsp;&nbsp;&nbsp;<strong>return</strong> <em>location</em> &nbsp;&nbsp;&nbsp;&nbsp; {location is the subscript of the term that equal x, or is 0 if x is not found}</p>
</blockquote>
</li>
</ul>
<p>→ 시간 복잡도 : O(n)</p>
<h4 id="binary-search">Binary Search</h4>
<ul>
<li>이진 탐색 : 리스트 중간 원소 조사, 두 구간으로 나눠 어느 쪽에 있는지 판단하고 범위를 줄이는 알고리즘<blockquote>
<p><strong>procedure</strong> <code>binary search</code>(x : integer, $a_1, a_2, ..., a_n$ : increasing integers)
&nbsp;&nbsp;&nbsp;&nbsp;i := 1 &nbsp;&nbsp;&nbsp;&nbsp;{i is left endpoint of search interval}
&nbsp;&nbsp;&nbsp;&nbsp;j := n &nbsp;&nbsp;&nbsp;&nbsp;{j is right endpoint of search interval}
&nbsp;&nbsp;&nbsp;&nbsp;<strong>while</strong> i &lt; j
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m := $\lfloor(i+j)/2\rfloor$
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>if</strong> $x &gt; a_m$ <strong>then</strong> i := m + 1
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>else</strong> j := m
&nbsp;&nbsp;&nbsp;&nbsp;<strong>if</strong> x = $a_i$ <strong>then</strong> <em>location</em> := i
&nbsp;&nbsp;&nbsp;&nbsp;<strong>else</strong> <em>location</em> := 0
&nbsp;&nbsp;&nbsp;&nbsp;<strong>return</strong> <em>location</em> &nbsp;&nbsp;&nbsp;&nbsp;{location is the subscript of the term $a_i$ equal to x, or 0 if x is not found</p>
</blockquote>
</li>
</ul>
<p>→ 시간 복잡도 : O(log n)</p>
<h3 id="sort-algorithm">Sort Algorithm</h3>
<h4 id="bubble-sort">Bubble Sort</h4>
<ul>
<li>버블 정렬 : 인접한 원소를 차례대로 비교, 순서가 잘못되어 있으면 서로 교환해 정렬하는 알고리즘<blockquote>
<p><strong>procedure</strong> <code>bubble sort</code>($a_1, ..., a_n$ : real numbers with n ≥ 2)
&nbsp;&nbsp;&nbsp;&nbsp;<strong>for</strong> i := 1 <strong>to</strong> n-1
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>for</strong> j := 1 <strong>to</strong> n-i</p>
<pre><code>  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;**if** $a_j &gt; a_{j+1}$ **then** interchange $a_j$ and $a_{j+1}$</code></pre><p>{$a_1, ..., a_n$ is in increasing order}</p>
</blockquote>
</li>
</ul>
<p>→ 시간 복잡도 : O(n<sup>2</sup>
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/a43cf13d-da81-4c44-9bbc-bae2b497cda0/image.png" alt=""></p>
<h4 id="insertion-sort">Insertion Sort</h4>
<ul>
<li>삽입 정렬 : - 두 번째 원소 부터 시작, 첫 원소와 비교해 앞/뒤 정해, 점점 뒤로가고, 앞쪽에서 정렬이 되는 알고리즘<blockquote>
<p><strong>procedure</strong> <code>insertion sort</code>($a_1, a_2,...,a_n$: real numbers with n ≥ 2)
&nbsp;&nbsp;&nbsp;&nbsp;<strong>for</strong> j := 2 <strong>to</strong> n
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i := 1
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>while</strong> $a_j &gt; a_i$</p>
<pre><code>  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i := i + 1</code></pre><p>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m := $a_j$
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>for</strong> k := 0 <strong>to</strong> j - i - 1</p>
<pre><code>  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a_{j-k} := a_{j-k-1}$</code></pre><p>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$a_i$ := m
{$a_1, ..., a_n$ is in increasing order}</p>
</blockquote>
</li>
</ul>
<p>→ 시간 복잡도 : O(n<sup>2</sup>
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/b7ef80e8-dfc6-4f56-88c4-f4c44eaf0636/image.png" alt=""></p>
<h2 id="3-greedy-algorithms">3. Greedy Algorithms</h2>
<h4 id="욕심쟁이-알고리즘greedy-algorithm--각-단계마다-가장-좋은-선택을-하는-알고리즘">욕심쟁이 알고리즘(greedy algorithm) : 각 단계마다 가장 좋은 선택을 하는 알고리즘</h4>
<ul>
<li><p>계산원 알고리즘 : 동전으로 거스름돈을 주는 방법을 계산하는 알고리즘 </p>
<blockquote>
<p><strong>procedure</strong> <code>change</code>($c_1, c_2, ..., c_n$: values of denominations of coins, where $c_1 &gt; c_2 &gt; ... &gt;c_r$, n : a positive integer
&nbsp;&nbsp;&nbsp;&nbsp;<strong>for</strong> i := 1 <strong>to</strong> r
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$d_i$ := 0 {$d_i$ counts the coins of denomination $c_i$ used}
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>while</strong> n ≥ $c_i$ </p>
<pre><code>  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$d_i$ := $d_i$ + 1 {andd a coin of denomination $c_i$ 
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;n := n - $c_i$ </code></pre><p>{$d_i$ is the number of coins of denomination $c_i$ in the change for i = 1, 2, …, r}</p>
</blockquote>
</li>
<li><p>greedy 알고리즘이 모든 알고리즘에 대한 답인 것은 아니다.</p>
</li>
</ul>
<h2 id="4-halting-problem">4. Halting Problem</h2>
<ul>
<li>Halting Problem : 주어진 프로그램과 그 입력값에 대해 프고르갬이 유한한 시간 안에 종료될지, 아니면 무한 루프에 빠져 종료되지 않을지 판별하는 알고리즘은 존재하지 않는다.</li>
</ul>
<ol>
<li>입력으로 프로그램 P와 그 프로그램의 입력값 I를 받는 절차 H(P, I)가 있다고 가정.</li>
<li>H는 프로그램 P가 입력 I로 실행되었을 때, P가 멈출지 멈추지 않을지 판정하는 절차.</li>
</ol>
<p>→ 해결할 수 없다는 것 증명</p>
<ol>
<li><p>가정 : 만약 H(P, I)라는 절차가 존재한다고 가정</p>
</li>
<li><p>만약 프로그램이 멈추면 &quot;halt&quot;, 멈추지 않으면 &quot;loops forever&quot; 출력</p>
</li>
<li><p>프로그램 K(P) 정의</p>
<ul>
<li>만약 H(P, P) 가 &quot;loops forever&quot; 출력할 시 K(P)는 멈춤.</li>
<li>만약 H(P, P) 가 &quot;halt&quot; 출력할 시 K(P)는 무한 루프.</li>
</ul>
</li>
<li><p>K(K)를 호출한다면</p>
<ul>
<li>K(K)가 &quot;loops forever&quot; 라면 K(K)는 멈춘다 → <strong>모순</strong></li>
<li>K(K)가 &quot;halt&quot; 라면 K(K)는 무한 루프에 빠진다 → <strong>모순</strong></li>
</ul>
</li>
</ol>
<ul>
<li>따라서, Halting 문제를 해결할 수 있는 일반적인 알고리즘은 존재하지 않는다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/45bc0136-45e8-4d98-b302-c1af6bbaddf3/image.png" alt=""></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[이산구조] 04. Functions]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-04.-Functions</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-04.-Functions</guid>
            <pubDate>Sat, 19 Oct 2024 03:02:45 GMT</pubDate>
            <description><![CDATA[<h1 id="module-4-functions">Module #4: Functions</h1>
<p>##</p>
<h2 id="1-basic-of-function">1. Basic of Function</h2>
<h4 id="함수function--a-b가-집합일-때-a로부터-b로의-함수-f는-a의-원소-각각에-b의-원소를-단-하나만-대응-시킨-것이다">함수(function) : A, B가 집합일 때, A로부터 B로의 함수 f는 A의 원소 각각에 B의 원소를 단 하나만 대응 시킨 것이다.</h4>
<ul>
<li>함수에 대한 표현들
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/d6353926-6c2b-46d8-9899-0d318778ec97/image.png" alt=""></li>
<li>명제 : 상황이라는 정의역에서 {T, F}라는 공역으로 가는 함수</li>
<li>bit String의 길이 : 숫자 {1, ..., n} 으로부터 bit {0,1}로 향하는 함수</li>
<li>집합 : 원소라는 정의역에서 존재하는지 여부인 {T, F}라는 공dur으로 가는 함수</li>
<li>집합 기호 : 집합으로부터 집합으로 가는 함수<ul>
<li>∩(({1,3},{3,4})) = {3}</li>
</ul>
</li>
</ul>
<h3 id="notations">Notations</h3>
<ul>
<li><p>Y<sup>X</sup> = f : X → Y 를 만족하는 모든 가능한 함수 F들의 집합</p>
<ul>
<li>|F| = |Y|<sup>|X|</sup></li>
</ul>
</li>
<li><p>F ≡ 0, T ≡ 1, 2 ≡ {0, 1} = {F, T}</p>
<blockquote>
<p><code>f : A → B</code> / <code>f(a) = b</code> (where a ∈ A &amp; b ∈ B)
A는 f의 <code>정의역(domain)</code>
B는 f의 <code>공역(codomain)</code>
B에서 f의 상(image)의 집합 <code>치역(range)</code>
b는 f의 <code>상(image)</code>
a는 f의 <code>원상(pre-image)</code></p>
</blockquote>
</li>
<li><p>상인 b는 일반적으로 1개 이상의 원상을 가진다</p>
</li>
<li><p>치역은 공역보다 작거나 같다</p>
</li>
<li><p>함수의 그래프 : f가 A→B인 함수일때, {(a, b) | a∈A 이고, f(a) = b, b∈B}인 순서쌍의 집합</p>
<ul>
<li>그림으로 표현할 수 있다.</li>
</ul>
</li>
</ul>
<h3 id="operator">Operator</h3>
<ul>
<li>Operator : n개의 쌍에 대한 함수<ul>
<li>Unary Operator : 인자가 1개 (ex. <code>~</code>)</li>
<li>Binary Operator : 인자가 2개 (ex. <code>∪</code>,<code>∩</code>)</li>
</ul>
</li>
<li>plus( + ) : 함수 합<ul>
<li>(f + g)a = f(a) + g(a)</li>
</ul>
</li>
<li>times( × ) : 함수 곱<ul>
<li>(f × g)a = f(a) × g(a)</li>
</ul>
</li>
<li>compose( $\circ$ ) : 함수 합성<ul>
<li>(f $\circ$ g)a = f(g(a))</li>
<li>교환 법칙이 성립하지 않는다.</li>
</ul>
</li>
</ul>
<hr>
<h2 id="2-special-functions">2. Special Functions</h2>
<h4 id="one-to-one-function1-1">One-to-One Function(1-1)</h4>
<ul>
<li><strong>단사함수</strong> : f의 정의역에 속한 모든 a와 b에 있어서 <code>f(a) = f(b)</code> 이면 반드시 <code>a = b</code>인 함수. (일대일 함수)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/eaf19346-c430-46fd-9066-6d108ea5dee3/image.png" alt=""></li>
<li>1개의 치역 원소에 1개의 정의역 원소만 대응 </li>
<li><strong>Strictly increasing(단조 증가 함수)</strong> : 정의역 안의 임의의 원소 x, y가 x&lt;y이면 반드시 f(x) &lt; f(y)인 함수</li>
<li><strong>Strictly decreasing(단조 감소 함수)</strong> : 정의역 안의 임의의 원소 x, y가 x&lt;y이면 반드시 f(x) &gt; f(y)인 함수<ul>
<li>f 가 단조 증가 or 단조 감소 함수이면 f는 단사 함수이다 (역은 성립 X)</li>
</ul>
</li>
</ul>
<h4 id="onto-function">Onto Function</h4>
<ul>
<li><strong>전사 함수</strong> : 공역과 치역이 같은 함수 </li>
<li>전사 함수 &amp; 단사 함수 일수 있고, 한쪽만 만족할 수도 있다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/1fa95472-04b6-45ed-b796-3c4521c5c050/image.png" alt="">
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/1e0fdc15-0969-4e63-abad-a0a3924b0838/image.png" alt=""></li>
</ul>
<h4 id="bijections">Bijections</h4>
<ul>
<li><strong>전단사함수</strong> : 전사함수이면서 동시에 단사함수인 함수. (일대일 대응)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/3df22cfc-3ce6-43a4-bf24-ec8b014e3901/image.png" alt=""></li>
<li>f가 전단사함수일때, f의 역함수 f<sup>-1</sup> : B → A 가 정의될 수 있다.<ul>
<li>f<sup>-1</sup> $\circ$ f = I(identity function)</li>
</ul>
</li>
</ul>
<h4 id="identity-function">Identity Function</h4>
<ul>
<li><strong>항등 함수</strong> : <code>I : A → A</code>, 입력과 출력이 같은 함수</li>
<li>항등함수는 전단사함수이다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/0a0c498f-ce77-4c4b-bc40-7c63854268ac/image.png" alt=""></li>
</ul>
<h3 id="floor--ceiling-function">Floor &amp; Ceiling Function</h3>
<ul>
<li><p><code>Floor Function</code> $\lfloor x \rfloor$ : 실수 x에 대해 x와 같거나 작은 수 중 가장 가까운 정수를 대응하는 함수.</p>
</li>
<li><p><code>Ceiling Function</code> $\lceil x \rceil$ : 실수 x에 대해 x와 같거나 큰 수중  가장 가까운 정수를 대응하는 함수. 
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/1251ee89-74ea-424a-a27e-8f4955dd0b4f/image.png" alt=""></p>
</li>
<li><p>if $x ∈ Z$, $\lfloor x \rfloor$  = $\lceil x \rceil$ = $x$</p>
</li>
<li><p>ex) $\lfloor {x\over3} \rfloor$
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/ecf0cfaf-5e0a-439c-8a8c-529abbf90349/image.png" alt=""></p>
</li>
</ul>
<hr>
<h2 id="3-cardinality--infinite-sets">3. Cardinality &amp; Infinite Sets</h2>
<ul>
<li><p>Define Cardinality for infinite set</p>
</li>
<li><p>Cardinality : 1개의 relation(관계)에 포함되어 있는 tuple의 수</p>
<blockquote>
<p>두 집합 A와 B가 동일한 <code>Cardinality</code>를 가진다.(|A| = |B|)
$$\Longleftrightarrow$$
A 로부터 B로  향하는 <code>전단사함수</code>가 있다.</p>
</blockquote>
</li>
<li><p>무한 집합일지라도 셀 수 있는 집합이 존재한다 </p>
<ul>
<li>집합이 유한 or |S| = |N| 할 때</li>
<li>ex) N(자연수 집합), Z(정수 집합), 자연수의 순서쌍(n, m)</li>
</ul>
</li>
<li><p>셀 수 없는 집합. </p>
<ul>
<li>집합이 무한 or |S| &gt; |N|</li>
<li>ex) R(실수), C(복소수),</li>
<li>[0, 1) = {r ∈ R| 0 $\leq$ r $&lt;$ 1|} </li>
</ul>
</li>
<li><p>Diagonalization 대각선 논법 : 실수의 집합은 셀 수 없다
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/d52793c2-ed96-4943-9d7c-ba2b96f41900/image.png" alt=""></p>
</li>
<li><p>Transfinite Numbers</p>
<ul>
<li>무한집합 S가 셀 수 있을 경우 S의 크기를 $\aleph_0$ 라고 표기.</li>
<li>|N| = $\aleph_0$ <ul>
<li>가장 작은 transfinite cardinal number(무한기수)</li>
</ul>
</li>
<li>|R| = $\aleph_1$ <ul>
<li>second transfinite cardinal</li>
</ul>
</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[이산구조] 03. The Theory of Set]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-03.-The-Theory-of-Set</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-03.-The-Theory-of-Set</guid>
            <pubDate>Fri, 18 Oct 2024 14:43:58 GMT</pubDate>
            <description><![CDATA[<h1 id="module-3-the-theory-of-sets">Module #3: The Theory of Sets</h1>
<h2 id="1-basic-of-sets">1. Basic of sets</h2>
<h4 id="set집합--순서를-고려하지-않는-서로-다른-개체들의-모임">Set(집합) : 순서를 고려하지 않는 서로 다른 개체들의 모임</h4>
<h3 id="basic-notation">Basic Notation</h3>
<ul>
<li><p>집합을 가르킬 때 S, T, U와 같이 영어 대문자 사용.</p>
</li>
<li><p>집합 내부에 속한 원소들은 영어 소문자 사용</p>
</li>
<li><p>원소 나열법 : 중괄호 안에 모든 구성원을 나열하는 표기법 </p>
</li>
<li><p>조건 제시법 : 모든 원소를 나열하는 것이 불가능할 경우 사용.</p>
<ul>
<li>{x| x는 속성 P를 갖고 있다}와 같이 사용</li>
</ul>
</li>
<li><p>집합 A와 B가 같다 $\Longleftrightarrow$ 완전히 같은 원소를 가지고 있음.</p>
</li>
<li><p>집합은 벤다이어그램이라는 그림을 통해 나타낼 수 있다.</p>
</li>
<li><p>집합 A에 원소 a가 속할 때</p>
<ul>
<li><code>A ∋ a</code> 와 같이 표현한다.</li>
</ul>
</li>
<li><p>집합도 원소가 될 수 있다.</p>
<ul>
<li>{1} ≠ {{1}}</li>
</ul>
</li>
</ul>
<h3 id="special-sets">Special Sets</h3>
<h4 id="infinite-sets">Infinite Sets</h4>
<ul>
<li>집합은 무한할 수 있다.</li>
<li>특수한 무한 집합에 대한 기호들<ul>
<li>N : 자연수 전체의 집합</li>
<li>Z : 정수 전체의 집합</li>
<li>R : 실수 전체의 집합</li>
</ul>
</li>
</ul>
<h4 id="empty-sets">Empty Sets</h4>
<ul>
<li><strong>∅</strong> 공집합 : 원소를 가지지 않는 특수한 집합.</li>
<li>∅ = {} = {x | false}</li>
</ul>
<h3 id="subset">Subset</h3>
<ul>
<li>S가 T의 부분집합이면 S의 모든 원소는 T에 속한다.</li>
<li>S ⊆ T $\Longleftrightarrow$ ∀x(x ∈ S → x ∈ T)</li>
<li>공집합은 모든 집합의 부분집합이다.</li>
<li>자기 자신도 부분집합이다.</li>
<li>S = T $\Longleftrightarrow$ S ⊆ T ∧ S ⊇ T</li>
<li>S ⊆ T &amp; S ≠ T이면 S ⊂ T이다. (진부분집합)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/e2354df6-f09e-419b-97c2-aae7843c7515/image.png" alt=""></li>
</ul>
<h2 id="2-utilization-of-sets">2. Utilization of sets</h2>
<h3 id="function-of-set">Function of Set</h3>
<h4 id="cardinality">Cardinality</h4>
<ul>
<li><code>|S|</code> : Cardinality of S. 집합 S의 크기, S의 원소의 갯수</li>
<li>원소의 갯수 ∈ N 이면, S는 유한하다. 그 이상이면, S는 무한하다</li>
<li>N, Z, R은 모두 무한하다.</li>
</ul>
<h4 id="power-set">Power Set</h4>
<ul>
<li><code>P(S)</code> : Power Set of S. S의 멱집합, S의 모든 부분 집합의 집합</li>
<li>집합 S = {0, 1, 2} 의 P(S) = {∅, {0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}}</li>
<li>2<sup>S</sup>로 작성할 수 있다.</li>
<li>|P(N)| &gt; |N| 이다.</li>
</ul>
<h3 id="cartesian-products-of-set">Cartesian Products of Set</h3>
<h4 id="ordered-n-tuples">Ordered n-tuples</h4>
<ul>
<li>순서가 있는 집합.</li>
<li>(a<sub>1</sub>, a<sub>2</sub>, ..., a<sub>n</sub>) 와 같이 나타낸다.</li>
<li>(1, 2) ≠ (2, 1)</li>
</ul>
<h4 id="cartesian-product-데카르트-곱">Cartesian Product 데카르트 곱</h4>
<ul>
<li>A, B 가 집합일 때, 데카르트 곱 A×B는 A ∋ a, B ∋ b 일 때 모든 (a, b) 순서쌍의 집합이다.</li>
<li>{a, b} × {1, 2} = {a, 1}, {a, 2}, {b, 1}, {b, 2}</li>
<li>|A×B| = |A||B|</li>
<li>교환 법칙이 성립하지 않는다.</li>
</ul>
<h2 id="3-laws-of-operations-of-sets">3. Laws of operations of sets</h2>
<h3 id="operation-of-set">Operation of set</h3>
<blockquote>
<p>합집합(∪, union) : A와 B가 집합일 때, A 또는 B에 속하거나 양쪽에 모두 속하는 원소들을 포함하는 집합</p>
</blockquote>
<blockquote>
<p>교집합(∩, intersection) : A와 B가 집합일 때, A와 B 양쪽 모두에 속한 원소들을 포함하는 집합</p>
</blockquote>
<blockquote>
<p>서로소(disjoint) : 두 집합의 교집합이 공집합(A∩B = ∅)일 때, 두 집합은 서로소이다.</p>
</blockquote>
<ul>
<li>|A∪B| = |A| + |B| - |A∩B|</li>
</ul>
<blockquote>
<p>차집합(-, set difference) : A와 B가 집합일 때, A-B은 A에 속하지만 B에는 속하지 않는 원소들만 포함하는 집합</p>
</blockquote>
<blockquote>
<p>여집합(<sup>c</sup>, set complement) : A와 B가 집합일 때, $\overline{A}$ 는 U-A를 의미한다.</p>
</blockquote>
<ul>
<li>A-B = A∩B<sup>c</sup></li>
</ul>
<h3 id="set-identities">Set Identities</h3>
<blockquote>
<p><strong>Identity</strong> : A∩U = A / A∪∅ = A</p>
</blockquote>
<blockquote>
<p><strong>Domination</strong> : A∪U = U / A∩∅ = ∅</p>
</blockquote>
<blockquote>
<p><strong>Idempotent</strong> : A∪A = A / A∩A = A</p>
</blockquote>
<blockquote>
<p><strong>Double complement</strong> : (A’)’ = A</p>
</blockquote>
<blockquote>
<p><strong>Commutative</strong> : A∪B = B∪A / A∩B = B∩A</p>
</blockquote>
<blockquote>
<p><strong>Associative</strong> : A∪(B∪C) = (A∪B)∪C / A∩(B∩C) = (A∩B)∩C</p>
</blockquote>
<blockquote>
<p><strong>Distributive</strong> : A∪(B∩C) = (A∪B)∩(A∪C) / A∩(B∪C) = (A∩B)∪(A∩C)</p>
</blockquote>
<blockquote>
<p><strong>DeMorgan&#39;s Law</strong> : (A∪B)’ = A’∩B’ / (A∩B)’ = A’∪B’</p>
</blockquote>
<h4 id="집합의-동치-증명-방법">집합의 동치 증명 방법</h4>
<ul>
<li>서로가 서로의 부분 집합임을 증명</li>
<li>진리표가 같음을 통해 보임</li>
</ul>
<h2 id="4-generalized-set">4. Generalized Set</h2>
<h4 id="generalized-union">Generalized Union</h4>
<ul>
<li>여러 집합들 중 적어도 하나의 집합에 나타나는 원소들을 포함한 집합.
$$
A_1 \cup A_2 \cup ... A_n = \displaystyle{\cup_{i=1}^nA_i}
$$</li>
</ul>
<h4 id="generalized-intersection">Generalized Intersection</h4>
<ul>
<li>여러 집합들 모두에 나타나는 원소들을 포함한 집합.
$$
A_1 \cap A_2 \cap ... A_n = \displaystyle \cap_{i=1}^nA_i
$$</li>
</ul>
<h4 id="representation">Representation</h4>
<ul>
<li><p>한 이산 구조를 다른 이산 구조 표현으로 나타내기</p>
</li>
<li><p>Set : 0 = ∅ / 1 = {0} / 2 = {0, 1} / 3 = {0, 1, 2}</p>
</li>
<li><p>Bit Strings : 0 = 0 / 1 = 1 / 2 = 10 / 3 = 11 / 4 = 100</p>
</li>
<li><p>집합을 bit string으로 나타내기. </p>
<ul>
<li>그 원소를 가지고 있으면 1, 없으면 0
ex)<ul>
<li>S = {2, 3, 5, 7, 11}</li>
<li>B = 001101010001 → 2, 3, 5, 7, 11번째 만 <code>1</code></li>
</ul>
</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[자료구조] 02. Arrays and Structures]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0-02.-Arrays-and-Structures</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0-02.-Arrays-and-Structures</guid>
            <pubDate>Fri, 18 Oct 2024 06:54:24 GMT</pubDate>
            <description><![CDATA[<h2 id="1-arrays">1. Arrays</h2>
<h3 id="11-adt">1.1 ADT</h3>
<ul>
<li>배열 : &lt;index, value&gt;의 쌍으로 구성된 집합</li>
<li>기본 기능 : 값 검색, 값 저장</li>
<li>ADT <strong><em>Array</em></strong><blockquote>
<p><strong>Objects</strong> : index의 각 값에 대해 집합 item에 속한 한 값이 존재하는 &lt;index, value&gt; 쌍의 집합. index는 1차원 또는 다차원의 유한 순서 집합이다.</p>
</blockquote>
</li>
<li><em>Functions*<em>:
&nbsp;&nbsp;&nbsp;&nbsp;모든 A∈Array / i∈index / x∈item / j,size∈integer
&nbsp;&nbsp;&nbsp;&nbsp;</em>Array</em> <code>Create(j, list)</code>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>return</strong> j 차원의 배열
&nbsp;&nbsp;&nbsp;&nbsp;<em>Item</em> <code>Retrieve(A, i)</code>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (i∈index)<pre><code>   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;**return** 배열 A의 인덱스 i 값과 관련된 항목</code></pre>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else <strong>return</strong> 에러
&nbsp;&nbsp;&nbsp;&nbsp;<em>Array</em> <code>Store(A, i, x)</code> 
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (i∈index)<pre><code>   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;**return** 새로운 쌍 &lt;i, x&gt;가 삽입된 배열 A</code></pre>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else <strong>return</strong> 에러</li>
</ul>
<h3 id="12-c에서의-배열">1.2 C에서의 배열</h3>
<ul>
<li><p>1차원 배열의 선언 : <code>int list[5];</code>(정수의 배열)  / <code>int *plist[5];</code>(정수 포인터의 배열)</p>
</li>
<li><p>배열 간의 주소 차이는 배열을 구성하는 변수의 크기에 비례한다.
  <img src="https://velog.velcdn.com/images/yeonbo_ra/post/d3d39572-6806-465e-9193-4cb479de8864/image.png" alt="">
  → 정수형(4 byte) 만큼 주소값 증가</p>
</li>
<li><p>C에서 <code>list[i]</code>는 정수의 포인터로 사용할 수 있다</p>
<ul>
<li><code>int *list1</code> 과 <code>int list2[5]</code>가 같은 것을 나타낼 수 있다</li>
<li><code>(list2+i)</code> = <code>&amp;list2[i]</code></li>
<li><code>*(list2+i)</code> = <code>list2[i]</code></li>
</ul>
</li>
<li><p>배열 프로그램의 예</p>
<pre><code class="language-c">#define MAX_SIZE 100
float sum(float a[], int n);
float input[MAX_SIZE], answer;
</code></pre>
</li>
</ul>
<p>void main(){
  int i;
  for (i = 0; i &lt; MAX_SIZE; i++)
    input[i] = i;
  answer = sum(input, MAX_SIZE);
  printf(&quot;The sum is: %f\n&quot;, answer);
}</p>
<p>float sum(float a[], int n){
  int i;
  float tempsum = 0;
  for(i = 0; i &lt; n; i++)
    tempsum += a[i];
  return tempsum;
}</p>
<pre><code>→ sum 함수 호출시 a배열의 첫 원소에 대한 주소값 복사.
→ main 에선 i번째 원소에 i 저장 
→ sum 에선 a의 모든 원소를 더함 

- [1차원 배열의 주소 계산]
`int one[] = {0,1,2,3,4};` 의 i 번째 주소와 그 주소 내 값을 출력하는 함수
```c
void print1(int *ptr, int rows){
  // 포인터를 사용해 1차원 배열을 출력
  int i;
  printf(&quot;Address Contents\n&quot;);
  for(i = 0; i &lt; rows; i++)
    printf(&quot;%8u%5d\n&quot;, ptr + i, *(ptr + i));
  printf(&quot;\n&quot;);
}</code></pre><hr>
<h2 id="2-dynamically-allocated-array">2. Dynamically Allocated Array</h2>
<h3 id="21-1차원-배열의-동적-할당">2.1 1차원 배열의 동적 할당</h3>
<pre><code class="language-c">// malloc 을 이용한 1차원 배열
int i,n,*list;
printf(&quot;Enter the number of numbers to generate: &quot;);
scanf(&quot;%d&quot;,&amp;n);
if(n &lt; 1){
    fprintf(stderr, &quot;Improper value of n\n&quot;);
    exit(EXIT_FAILURE);
}
MALLOC(list, n * sizeof(int));</code></pre>
<pre><code class="language-c">// malloc 매크로
#define MALLOC(p,s) \ // 포인터 p, 자료형의 크기 s
    if ((p = malloc(s) == NULL) { \
        fprintf(stderr, &quot;Insufficient memory&quot;); \
                exit(EXIT_FAILURE); \
    }</code></pre>
<h3 id="22-2차원-배열의-동적-할당">2.2 2차원 배열의 동적 할당</h3>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/2f489bca-15fe-48e8-aef3-885bc366fcd8/image.png" alt=""></p>
<pre><code class="language-c">// 2차원 배열의 동적 할당
int** make2dArray(int rows, int cols){
  // rows x cols 크기의 2차원 배열을 생성
  int **x, i;

  MALLOC(x, rows * sizeof(int *));  // 행에 대한 공간 생성
  for(i = 0; i &lt; rows; i++) 
    MALLOC(x[i], cols * sizeof(int)); // 각 행마다의 열에 대한 공간 생성
  return x;
}</code></pre>
<ul>
<li><code>void *calloc(elt_count, elt_size</code> 함수<ul>
<li><code>elt_size</code>만큼의 데이터 크기를 가진 <code>elt_count</code>길이의 동적 배열을 만드는 함수</li>
<li>사용자가 지정한 매모리 할당 &amp; 0으로 자동 초기화(malloc은 초기화 X)</li>
</ul>
</li>
<li><code>void *realloc(p, s)</code> 함수<ul>
<li>기존 포인터 p를 s만큼의 사이즈로 바꾸는 함수</li>
</ul>
</li>
</ul>
<hr>
<h2 id="3-structures-and-unions">3. Structures and Unions</h2>
<h3 id="31-구조체">3.1 구조체</h3>
<ul>
<li>구조체 : 서로 다른 타입의 데이터를 그룹화 하는 것<pre><code class="language-c">// 구조체 만들기
typedef struct {
  char name[10];
  int age;
  float salary;
} Person;
</code></pre>
</li>
</ul>
<p>// 값 할당하기
strcpy(person.name, &quot;james&quot;);
person.age = 10;
person.salary = 35000;</p>
<pre><code>→ `typedef` + `struct`로 단축해서 생성 가능

- 구조체 값 자체의 동등성 여부는 검사할 수 없음. 대신 함수를 생성해서 처리해야 함
```c
// 구조체 비교
#define FALSE 0
#define TRUE 1
typedef struct{
  char name[20];
  int age;
  float salary;
} humanBeing;

humanBeing person1, person2;
// person1과 person2 직접적 비교는 불가능

int humansEqual(humanBeing person1, humanBeing person2){
  // 동일인 일시 TRUE, 그렇지 않으면 FALSE 반환
  if (strcmp(person1.name, person2.name))
    return FALSE;
  if (person1.age != person2.age)
    return FALSE;
  if (person1.salary != person2.salary)
    return FALSE;
  return TRUE;
}</code></pre><ul>
<li>구조체 속 구조체 정의 가능<pre><code class="language-c">// 구조체 속 구조체
typedef struct date{
  int month;
  int day;
  int year;
} date;
</code></pre>
</li>
</ul>
<p>typedef struct{
  char name[20];
  int age;
  float salary;
  date dob;
} humanBeing;</p>
<p>// 접근 방법
humanBeing person;
person.dob.month = 2;
person.dob.day = 11;
person.dob.year = 2022;</p>
<pre><code>
### 3.2 유니온
- 유니온 : 메모리 공간을 공용으로 사용
  - 여러 필드 중 한 필드만 활성화 되어 사용 가능

ex) humanBeing 에서 sexType을 추가해 한 필드에서 여자라면 출산 아동수를, 남자라면 턱수염 여부를 저장
```c
typedef struct {
    enum tagField {female, male} sex;
    union {
        int childern;  // 여자인 경우
        int beard;  // 남자인 경우 
    } u;
} sexType;

typedef struct{
  char name[20];
  int age;
  float salary;
  sexType sexInfo;
} humanBeing;

// 접근 방법
humanBeing person1, person2;

person1.sexInfo.sex = male;
person1.sexInfo.u.beard = FALSE;

person1.sexInfo.sex = female;
person1.sexInfo.u.childern = 4;</code></pre><p>→ 먼저 enum을 통해 태그 필드에 값 설정 
→ union에 있는 필드의 활성화를 결정</p>
<ul>
<li>C언어는 union의 올바른 필드 사용을 요구하지 않는다 (오류 발생 X)</li>
</ul>
<h3 id="33-구조체의-내부-구현">3.3 구조체의 내부 구현</h3>
<ul>
<li>구조체 내부 요소의 주소값 <ul>
<li>구조 정의에서 명세된 순서로 주소의 위치를 저장</li>
<li>실제로는 메모리를 맞추기 위해 padding 할 수 있다</li>
</ul>
</li>
<li>구조는 같은 유형의 메모리 경계에서 시작하고 끝남.<ul>
<li>짝수 바이트 or 4, 8, 16 배수 메모리 경계</li>
</ul>
</li>
</ul>
<h3 id="34-자기-참조-구조self-referential-structures">3.4 자기 참조 구조(Self-Referential Structures)</h3>
<ul>
<li>자기 참조 구조 : 구성 요소 중 자기 자신을 가리키는 포인터가 1개 이상 존재하는 구조<ul>
<li>동적 저장 관리 루틴(malloc / free)가 필요<pre><code class="language-c">typedef struct {
char data;
struct list *link;
} list;</code></pre>
→ data는 하나의 문자, link는 자기 자신(list)에 대한 포인터
→ 이를 활용해 list 구조 여러 개를 서로 연결할 수 있다.</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] 05. Collection Framework]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-06.-Collection-Framework</link>
            <guid>https://velog.io/@yeonbo_ra/Java-06.-Collection-Framework</guid>
            <pubDate>Thu, 17 Oct 2024 03:37:37 GMT</pubDate>
            <description><![CDATA[<h2 id="1-introduction-to-collections">1. Introduction to Collections</h2>
<h3 id="collection">Collection</h3>
<ul>
<li>정의 : 객체 그룹을 저장하고 조작할 수 있는 아키텍쳐를 제공하는 Java의 프레임워크<ul>
<li>Java Standard Library에서 제공해주는 기능. 미리 구현이 되어 있음</li>
</ul>
</li>
<li>장점 <ul>
<li>Standardization : 같은 컬렉션 안에 있는 구조들은 비슷한 Operation을 구현</li>
<li>Reusability : 재사용 가능한 자료구조와 알고리즘 제공</li>
</ul>
</li>
</ul>
<h3 id="key-components">Key Components</h3>
<ul>
<li>Interface<ul>
<li>구현하는 기능들에 대한 설명</li>
<li>ex)<ul>
<li><code>List</code> : 중복이 허용되는 순서가 있는 구조</li>
<li><code>Set</code> : 중복이 허용되지 않는 구조</li>
<li><code>Map</code> : key, value 쌍이 있고, key 값이 중복되지 않는 구조</li>
</ul>
</li>
</ul>
</li>
<li>Implementations <ul>
<li>인터페이스가 실제로 구현된 클래스들. 실제 기능을 제공</li>
<li>ex) <ul>
<li><code>ArrayList</code> : List를 implement 하는 크기 조정 가능한 배열</li>
<li><code>HashSet</code> : Set을 implement 하는 순서를 저장하지 않는 해시 테이블</li>
<li><code>HashMap</code> : Map을 implement 하는 null key 와 null value를 허용하는 해시 테이블</li>
</ul>
</li>
</ul>
</li>
<li>Algorithms <ul>
<li>컬렉션들에서 공통적인 operation을 수행하는 메소드</li>
<li>Sort, Search, Shuffle 등등.</li>
</ul>
</li>
</ul>
<h2 id="2-interfaces">2. Interfaces</h2>
<h3 id="list-interface">List Interface</h3>
<ul>
<li>요소간 중복이 허용되는 순서 있는 구조<h4 id="arraylist">ArrayList</h4>
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/9e279fa8-b7c4-4cb8-aa00-8199181835b0/image.png" alt=""></li>
<li>크기 조정 가능한 배열, 필요한 만큼 크기를 늘릴 수 있다.</li>
<li>index를 통한 접근 속도가 빠르다 → O(1)</li>
<li>데이터 추가 / 삭제 속도가 느리다 → O(n)</li>
<li>중복 허용, null value 허용
→ 잘 변하지 않는 list에 사용한다.</li>
</ul>
<h4 id="linkedlist">LinkedList</h4>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/35756bab-c78b-4d6f-be6a-686572b1ba2c/image.png" alt=""></p>
<ul>
<li><code>List</code>와 <code>Deque</code>를 모두 implement 하는 구조</li>
<li>index를 통한 접근 속도가 느리다 → O(n)</li>
<li>데이터 추가 / 삭제 속도가 빠르다 → O(1)</li>
<li>중복 허용, null value 허용</li>
<li>Queue(FIFO) 나 Stack(LIFO) 로 사용 가능
→ 데이터의 추가 &amp; 삭제가 빈번한 list에 사용한다.</li>
</ul>
<pre><code class="language-java">import java.util.LinkedList;

public class Example {
    public static void main(String args[]) {
        LinkedList&lt;Integer&gt; numbers = new LinkedList&lt;&gt;();

        // Adding elements
        numbers.add(10);
        numbers.add(20);
        numbers.add(30);

        // Accessing elements
        System.out.println(&quot;First element: &quot; + numbers.getFisrt());

        // Removing elements
        numbers.removeFirst();

        // Size of the list
        System.out.println(&quot;Size of list: &quot; + numbers.size());

        // Iterating over the list
        for (Integer number : numbers) {
            System.out.println(number);
        }
    }
}</code></pre>
<h3 id="set-interface">Set Interface</h3>
<ul>
<li>요소간 중복이 허용되지 않는 순서 없는 구조
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/eeb1c0c3-7136-4d44-a8eb-e7c6b166b911/image.png" alt=""><h4 id="hashset">HashSet</h4>
</li>
<li><code>Set</code>을 구현, hash table의 백업을 받음</li>
<li>null 값을 허용</li>
<li>add(), remove(), contains() 에 대한 시간 복잡도 O(1)
→ 순서가 상관 없고, 빠른 접근이 필요할 때 사용<pre><code class="language-java">import java.util.HashSet;
</code></pre>
</li>
</ul>
<p>public class Example {
    public static void main(String args[]) {
        HashSet<String> set = new HashSet&lt;&gt;();</p>
<pre><code>    // Adding elements
    set.add(&quot;Dog&quot;);
    set.add(&quot;Cat&quot;);
    set.add(&quot;Bird&quot;);
    set.add(&quot;Dog&quot;); // 중복 요소, 추가되지 않음

    // Checking if an element exists
    System.out.println(&quot;Contains &#39;Cat&#39;: &quot; + set.contains(&quot;Cat&quot;));

    // Size of the set
    System.out.println(&quot;Size of set: &quot; + set.size());

    // Iterating over the set
    for (String animal : set) {
        System.out.println(animal);
    }
}</code></pre><p>}</p>
<pre><code>
#### LinkedHashSet
- `Set`을 구현, hash table 과 linked list의 백업을 받음
- `HashSet`을 상속 받음. Double Linked List 유지
- 요소의 삽입 순서를 유지한다
- 기본적 Operation에 대한 시간 복잡도 O(1)
- null 값 허용
→ 중복 불가 &amp; 삽입 순서 유지가 필요할 때 사용

#### TreeSet
- `SortedSet`을 상속하는 `NavigableSet` 을 구현
- red-black tree 의 백업을 받음
- 요소들을 key 기준으로 정렬 (오름차순 / 커스텀 가능)
- null 값 허용 X
- add(), remove(), contains() 에 대한 시간 복잡도 O(log n)
→ 정렬된 Set 이 필요할 때 사용
``` java
Map&lt;integer, String&gt; treeMap = new TreeMap&lt;&gt;();
treeMap.put(3, &quot;Three&quot;);
treeMap.put(1, &quot;One&quot;);
treeMap.put(2, &quot;Two&quot;);

System.out.println(treeMap); // key 순으로 정렬 : {1=One, 2=Two, 3=Three}</code></pre><h3 id="map-interface">Map Interface</h3>
<ul>
<li>Key - Value 의 쌍을 가지는 구조. 1개의 key에 1개의 Value mapping</li>
<li>Key 값의 중복을 허용하지 않는다.<h4 id="hashmap">HashMap</h4>
</li>
<li><code>Map</code>을 구현, hash table의 백업을 받음</li>
<li>1개의 null key 와 여러 개의 null value 허용 (나머지 케이스들을 모두 저장하는 곳)</li>
<li>key / value 의 순서 저장 X</li>
<li>put(), get() 에 대한 시간 복잡도 O(1)
→ 순서 상관없이 빠른 접근이 필요할 때 사용</li>
</ul>
<h4 id="linkedhashmap">LinkedHashMap</h4>
<ul>
<li><code>HashMap</code> 상속 받음. Double Linked List 유지</li>
<li>1개의 null key 와 여러 개의 null value 허용</li>
<li>기본적 Operation에 대한 시간 복잡도 O(1)</li>
<li>순서가 예상 가능하다(넣은 순서)
→ 넣은 순서 유지가 필요할 때 사용</li>
</ul>
<h4 id="treemap">TreeMap</h4>
<ul>
<li><code>NavigableMap</code> 구현, red-black tree 의 백업 받음</li>
<li>key가 정렬됨. (오름차순 / 커스텀)</li>
<li>null key 허용 X (throws <code>NullPointerException</code>)</li>
<li>기본적 Operation에 대한 시간 복잡도 O(log n)
→ key를 정렬해야할 때 사용</li>
</ul>
<h2 id="3-iterator">3. Iterator</h2>
<h3 id="definition">Definition</h3>
<ul>
<li>어떤 collection 이든 공통적으로 구현하는 것들</li>
<li>장점<ul>
<li>Uniform access : 모든 collection에 대해 똑같은 방식으로 접근할 수 있도록 함</li>
<li>Encapsulation : 어떤 collection인지 감춰 실수로 바꾸는 것을 막을 수 있음</li>
</ul>
</li>
</ul>
<h3 id="types-of-iterators">Types of Iterators</h3>
<ul>
<li><code>hasNext()</code> : 다음 요소가 존재하면 true 반환 (전체 요소 순회 시 사용)</li>
<li><code>next()</code> : 다음 요소를 반환 </li>
<li><code>remove()</code> : 마지막으로 반환된 요소를 삭제<pre><code class="language-java">List&lt;String&gt; list = new ArrayList&lt;&gt;(Arrays.asList(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;));
Iterator&lt;String&gt; iterator = list.iterator();
while (iterator.hasNext()) {
  String element = iterator.next();
  System.out.println(element);
}</code></pre>
</li>
</ul>
<h2 id="4-using-collections-for-data-manipulation">4. Using Collections for Data Manipulation</h2>
<h3 id="sorting">Sorting</h3>
<ul>
<li><p><code>Collections.sort()</code></p>
<ul>
<li>요소들을 natural ordering 에 기반해 정렬 (알파벳 순, 대문자 &gt; 소문자)</li>
<li><pre><code class="language-java">List&lt;String&gt; list = Arrays.asList(&quot;Banana&quot;, &quot;Apple&quot;, &quot;Cherry&quot;);
Collections.sort(list);
// Apple, Banana, Cherry 순으로 정렬</code></pre>
</li>
</ul>
</li>
<li><p><code>List.sort()</code></p>
<ul>
<li>list 인터페이스에 있는 기본적 메소드</li>
<li><code>list.sort(Comparator.naturalOrder());</code></li>
</ul>
</li>
<li><p><code>Arrays.sort()</code></p>
<ul>
<li>array의 요소들을 오름차순으로 정렬</li>
<li><pre><code class="language-java">  int[] numbers = {4, 2, 7, 3};
Arrays.sort(numbers);
// 2, 3, 4, 7 순으로 정렬
</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="custom-sorting">Custom Sorting</h3>
<ul>
<li><code>Comparator</code> 인터페이스<ul>
<li>comparator(T o1, T o2) 메소드를 제공하는 함수형 인터페이스</li>
<li><code>Collections.sort(list, Comparator.reverseOrder());</code></li>
<li>함수 자체에서 입력값 두 개를 비교하기 위해 사용 → 입력값 2개</li>
</ul>
</li>
<li><code>Comparable</code> 인터페이스<ul>
<li>객체의 값과 다른 객체 입력값 1개를 비교하기 위해 사용 → 입력값 1개</li>
<li><pre><code class="language-java">  public class Person implements Comparable&lt;Person&gt; {
    private String name;
    private int age;
    // getters, setters, constructor
        @Override
    public int comPareTo(person other) {
        return Integer.compare(this.age), other.age);
    }
}
</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="searching">Searching</h3>
<ul>
<li><p><code>Collection.binarySearch()</code></p>
<ul>
<li>이진 탐색 알고리즘을 사용해 탐색</li>
<li><pre><code class="language-java">int index = Collections.binarySearch(list, &quot;Apple&quot;);</code></pre>
</li>
</ul>
</li>
<li><p><code>Map.containsKey()</code></p>
<ul>
<li>map 이 특정한 key 값을 가지고 있다면 true 반환 </li>
</ul>
</li>
<li><p><code>List.contains()</code></p>
<ul>
<li>list 가 특정한 요소를 가지고 있다면 true 반환</li>
</ul>
</li>
<li><p>탐색의 시간 복잡도는 어떤 자료 구조를 사용하는지에 따라 달라진다.</p>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[디지털 회로 개론] 03. The Karnaugh Map]]></title>
            <link>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-03.-The-Karnaugh-Map</link>
            <guid>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-03.-The-Karnaugh-Map</guid>
            <pubDate>Tue, 15 Oct 2024 08:17:58 GMT</pubDate>
            <description><![CDATA[<h1 id="31-카르노-맵">3.1 카르노 맵</h1>
<ul>
<li><p>SOP(Sum of Product)표현에서 사용하기 적합한 곱항을 발견하는 도식적인 접근법</p>
</li>
<li><p>Letter : 변수와 상수 </p>
</li>
<li><p>Literal : 상수와 변수와 그 보수 (중복해서 계산)
ex) B = {0,1 }, variable : x, y</p>
<ul>
<li>letter : x, y, 0, 1</li>
<li>literal : x, y, x&#39;, y&#39;, 0, 1</li>
</ul>
</li>
<li><p>Product term</p>
<ul>
<li>1</li>
<li>non-constant literal : 변수&amp;보수</li>
<li>곱으로만 묶여야 함. 한 literal이 두 번 나오면 안됨.</li>
<li>1, x, xy&#39; / x+y (X), xy&#39;x (X)</li>
</ul>
</li>
<li><p>Sum term</p>
<ul>
<li>0</li>
<li>non-constant literal : 변수&amp;보수</li>
<li>합으로만 묶여야 함. 한 literal이 두 번 나오면 안됨.</li>
<li>0, x, x+y&#39; / xy (X), x+y&#39;+x (X)</li>
</ul>
</li>
<li><p>Minterm : 모든 변수가 항상 한번씩 사용된 product term</p>
</li>
<li><p>Maxterm : 모든 변수가 항상 한번씩 사용된 sum term</p>
</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/1b12a593-5f48-4d20-be2b-13c869b5a60b/image.png" alt=""></p>
<h3 id="카르노-맵">카르노 맵</h3>
<ul>
<li>F(a, b, c, d) = a&#39;b&#39;c&#39;d&#39; + a&#39;bc + ab&#39;c + bd + cd (SOP)
= $\Sigma$(0,3,5,6,7,10,11,13,15)</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/f0e14ca3-8b5b-4fec-9c4f-0e59c400f0f8/image.png" alt="카르노맵 예시"></p>
<ul>
<li>Implicant : 2<sup>k</sup>개 의 1의 묶음 → 카르노 맵 묶는 단위</li>
<li>Prime Implicant : 더 큰 묶음에 포함되지 않는 묶음</li>
<li>Essential Prime Implicant : 하나의 prime Implicant를 형성하고 있는 1들 중에서 적어도 하나는 다른 Implicant에 속하지 않고 자신의 Prime Implicant 묶음에만 속하는 Prime Implicant</li>
</ul>
<p>→ 간략화된 함수에는 EPI 전부와 non-essential PI 일부가 포함된다</p>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/b8eb6e10-3ec0-4f33-bd77-66f4f70e770e/image.png" alt=""></p>
<hr>
<h1 id="32-카르노-맵을-이용한-최소-합의-곱sop">3.2 카르노 맵을 이용한 최소 합의 곱(SOP)</h1>
<ul>
<li><p>맵 방법 1</p>
<ul>
<li><u>모든</u> Prime Implicant를 찾는다</li>
<li><u>모든</u> EPI를 포함시킨다</li>
<li>아직 커버되지 않은 모든 최소항(minterms)을 포함하기 위해 최소 비용의 비필수(non-essential) 소수 임플리컨트 집합을 선택</li>
</ul>
</li>
<li><p>2변수 맵
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/25d96b0b-8bfd-4717-bcd5-cf5a126e81e2/image.png" alt=""></p>
</li>
<li><p>3변수 맵
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/2a87e1b0-179c-4c51-988a-26513ea0e013/image.png" alt=""></p>
</li>
<li><p>4변수 맵
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/1b7ffb77-9af6-49da-be2f-16e7168e0e51/image.png" alt=""></p>
</li>
<li><p>5변수 맵
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/9e72afb0-c8b0-4f72-8216-2d91c6bdba1a/image.png" alt=""></p>
</li>
</ul>
<hr>
<h2 id="33-dont-cares">3.3 Don&#39;t Cares</h2>
<ul>
<li><p>카르노맵에서 Don&#39;t care는 함수에 포함되는 포함되지 않든 상관하지 않는다.</p>
</li>
<li><p>맵 방법 2</p>
<ul>
<li>모든 필수 주항을 찾는다</li>
<li>필수 주항에 의해 커버되는 모든 1들을 X로 바꾼다. </li>
<li>그 후는 방법 1 이용.</li>
</ul>
</li>
</ul>
<h2 id="34-곱의-합pos">3.4 곱의 합(POS)</h2>
<p>1) 함수의 보수 맵을 만든다.(0은 1으로, 1은 0으로, X는 그대로)
2) 함수의 보수에 대한 최소 SOP 표현을 찾는다.
3) SOP 표현을 POS 표현으로 바꾼다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[자료구조] 01. Basic Comcepts]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0-01.-Basic-Comcepts</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0-01.-Basic-Comcepts</guid>
            <pubDate>Mon, 14 Oct 2024 14:28:28 GMT</pubDate>
            <description><![CDATA[<h2 id="1-system-life-cycle">1. System Life cycle</h2>
<ul>
<li><p>Requirement : 요구사항. 주어진 자료 입력 + 생성해내야 하는 결과(출력)</p>
</li>
<li><p>Analysis : 분석. </p>
<ul>
<li>bottom-up : 밑에서 위로. 코딩에 주안점을 둠</li>
<li>top-down : 문제를 분석해 작은 단위로 분리해 해결 → 더 좋은 방식</li>
</ul>
</li>
<li><p>Design : 설계. 추상 데이터 타입(ADT) + 알고리즘 설계</p>
</li>
<li><p>Refinement and Coding : 자료 객체에 대한 표현 선택 &amp; 알고리즘 작성</p>
</li>
<li><p>Verification : 검증. 프로그램 정확성 체크, 테스트 &amp; 오류 수정</p>
<ul>
<li>시간 복잡도 : running time</li>
<li>공간 복잡도 : amount of memory used</li>
</ul>
</li>
</ul>
<hr>
<h2 id="2-algorithm-specification">2. Algorithm Specification</h2>
<h3 id="21-알고리즘이란">2.1 알고리즘이란?</h3>
<ul>
<li>알고리즘 : 특정한 일을 수행하는 명령어들의 유한 집합
1) Input : 입력. 외부에서 제공되는 데이터가 0개 이상 존재
2) Output : 출력. 적어도 한 개 이상의 결과를 생성
3) Definiteness : 각 단계들은 명확해야 함.
4) Finiteness : 알고리즘은 유한시간 안에는 반드시 끝나야 함.
5) Effectiveness : 모든 명령은 종이와 연필만으로 수행할 수 있을 정도로 기본적이어야 함.</li>
</ul>
<ul>
<li>알고리즘 표현 : 자연어, flowchart, 프로그래밍 언어</li>
</ul>
<blockquote>
<p><strong>Selection Sort</strong> 
1st : finding the smallest integer;
2nd : exchange (함수 or macro);</p>
<blockquote>
<p>for (i=0; i&lt;n; i++){
    &nbsp;&nbsp;&nbsp;&nbsp;Examine list[i] to list[n-1]
    &nbsp;&nbsp;&nbsp;&nbsp;and suppose that the smallest integer is at list[min]
    &nbsp;&nbsp;&nbsp;&nbsp;Interchange list[i] and list[min]
}</p>
</blockquote>
</blockquote>
<pre><code class="language-c">// Swap Function
void swap(int *x, int *y){
    int temp = *x;
    *x = *y;
    *y = temp;
}

// Call : swap(&amp;a, &amp;b)</code></pre>
<pre><code class="language-c">// Swap Macro
#define SWAP(x,y,t) ((t) = (x), (x) = (y), (y) = (t)</code></pre>
<pre><code class="language-c">// Selection Sort 
void sort(int list[], int n){
      int i, j, min, temp;
      for(i = 0; i &lt; n-1; i++){
        min = i;
        for(j = i+1; j &lt; n; j++)
          if(list[j] &lt; list[min]) 
            min = j;
           SWAP(list[i], list[min], temp);
      }
}</code></pre>
<ul>
<li>Sort 알고리즘은 n $\geq$ 1 이상의 정수들의 모음을 정렬한다.</li>
</ul>
<blockquote>
<p><strong>Binary Search</strong> 
1st : 아직 검사할 정수가 남아 있는지 결정
2nd : searchnum과 list[middle] 비고</p>
<blockquote>
<p>while(there are more integers to check){
    &nbsp;&nbsp;&nbsp;&nbsp;middle = (left + right) / 2;
    &nbsp;&nbsp;&nbsp;&nbsp;if (searchnum &lt; list[middle])
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return middle;
    &nbsp;&nbsp;&nbsp;&nbsp;else left = middle + 1;</p>
</blockquote>
</blockquote>
<pre><code class="language-c">//Compare Function
int compare(int x, int y){
  if(x &lt; y) return -1;
  else if(x == y) return 0;
  else return 1;
}</code></pre>
<pre><code class="language-c">// Compare Macro
#define COMPARE (x,y) ((x) &lt; (y)) ? -1: ((x) == (y)) ? 0 : 1)</code></pre>
<pre><code class="language-c">// Binary Search
int binsearch(int list[], int searchnum, int left, int right){
  int middle;
  while(left &lt;= right){
    middle = (left + right) / 2;
    switch(COMPARE(list[middle], searchnum)){
      case -1: 
        left = middle + 1; 
        break;
      case 0: return middle;
      case 1: right = middle - 1;
    }
  }
  return -1;
}</code></pre>
<hr>
<h3 id="22-재귀-알고리즘">2.2 재귀 알고리즘</h3>
<ul>
<li><p>Direct recursion : 직접 순환. 함수가 그 수행이 완료되기 전에 자기 자신을 다시 호출</p>
</li>
<li><p>Indirect recursion : 간접 순환. 호출 함수를 다시 호출하게 되어 있는 다른 함수를 호출</p>
</li>
<li><p>[Binomial Coefficients] : 조합의 재귀적 표현</p>
<blockquote>
<p>$$ \left[
\begin{matrix}
  n \
  m \
\end{matrix}
\right] 
= {n!\over m!(n-m)!} $$</p>
</blockquote>
<blockquote>
<p>$$ \left[
\begin{matrix}
  n \
  m \
\end{matrix}
\right] 
=  \left[
\begin{matrix}
  n-1 \
  m \
\end{matrix}
\right] + \left[
\begin{matrix}
  n-1 \
  m-1 \
\end{matrix}
\right] $$</p>
</blockquote>
</li>
<li><p>[Fatorial] : 팩토리얼</p>
<blockquote>
<p>$$ n! = \begin{cases}
n \times (n-1)! \quad if, \ n &gt; 1\
1 \quad if,\ n = 1
\end{cases}$$</p>
</blockquote>
</li>
<li><p>[Binary Search] : 이진 탐색</p>
</li>
</ul>
<pre><code>BSrch[key, left, right]
    if key &lt; list[middle]
        BSrch[key, left, middle-1]
    if key = list[middle]
        list[middle]
    if key &gt; list[middle]
        BSrch[key, middle+1, right]</code></pre><pre><code class="language-c">// 이진 탐색 재귀적 구현
int binsearch(int list[], int searchnum, int left, int right){
  int middle;
  if(left &lt;= right){
    middle = (left + right) / 2;
    switch(COMPARE(list[middle], searchnum)){
      case -1: 
        return binsearch(list, searchnum, middle + 1, right);
      case 0: return middle;
      case 1: 
        return binsearch(list, searchnum, left, middle - 1);
    }
  }
  return -1;
}</code></pre>
<ul>
<li>[Fibonacci Number] : 피보나치 수열</li>
</ul>
<blockquote>
<p>f<sub>n</sub> = 0 (if n = 0)
f<sub>n</sub> = 1 (if n = 1)
f<sub>n</sub> = f<sub>n-1</sub> + f<sub>n-2</sub> (if n &gt; 1)</p>
</blockquote>
<pre><code class="language-c">// 일반 함수
int fibo(int n){
    int g, h, f, i;
    if(n&gt;1){
        g = 0;
        h = 1;
        for(i = 2; i &lt;= n; i++){
            f = g + h;
            g = h;
            h = f;
        }
    }
    else f = n;
    return f;
}</code></pre>
<pre><code class="language-c">// 재귀 함수
int rfibo(int n){
    if(n &gt; 1) 
        return rfibo(n-1) + rfibo(n-2);
    else return n;
}</code></pre>
<ul>
<li>[Permutations] : 순열 생성</li>
</ul>
<pre><code class="language-c">// 순열의 재귀적 생성
void perm(char *list, int i, int n){
  int j, temp;
  if(i == n){
    for(j = 0; j &lt;= n; j++)
      printf(&quot;%c&quot;, list[j]);
    printf(&quot;\n&quot;);
  } else {
      // list에 1개 이상의 문자가 들어있으면 재귀적으로 생성
    for(j = i; j &lt;= n; j++){
      SWAP(&amp;list[i], &amp;list[j]);
      perm(list, i + 1, n);
      SWAP(&amp;list[i], &amp;list[j]);
    }
  }
}</code></pre>
<hr>
<h2 id="3-data-abstraction">3. Data Abstraction</h2>
<ul>
<li><p>데이터 타입 : 객체(object)와 그 객체를 가지고 하는 연산(operation)들의 모음</p>
<ul>
<li>C의 기본 데이터 타입 : <code>char</code>, <code>int</code>, <code>float</code>, <code>double</code> ...</li>
<li>여러 데이터를 grouping : <code>array</code>, <code>struct</code></li>
<li>pointer 타입 </li>
</ul>
</li>
<li><p>추상 데이터 타입(ADT, Abstract Data Type) : 객체와 연산의 명세가 구현으로부터 분리된 데이터 타입.
→ 내부적 표현 or 구현에 대한 설명이 필요 없음</p>
<ul>
<li>ADT 가 가지는 함수의 종류<ol>
<li>생성자(creater)/구성자(constructor) : 지정된 타입에 맞는 새로운 인스턴스 생성</li>
<li>변환자(transformer) : 1개 이상의 다른 인스턴스를 사용해 지정된 타입의 한 인스턴스 만듬.</li>
<li>관찰자(observers)/보고자(reporter) : 인스턴스에 대한 정보 제공. 변화는 X</li>
</ol>
</li>
</ul>
</li>
<li><p>[ADT <strong><em>Natural_Number</em></strong> ]</p>
<blockquote>
<p><strong>Object</strong> : 0에서 시작해서 컴퓨터상의 최대 정수 값(INT_MAX)까지 순서화된 정수의 부분 범위</p>
</blockquote>
</li>
<li><p><em>Function*</em>: 
&nbsp;&nbsp;&nbsp;&nbsp;<em>Nat_Number_의 모든 원소 x,y 그리고 _Boolean_의 원소 T
&nbsp;&nbsp;&nbsp;&nbsp;_NaturalNumber</em> <code>Zero()</code>  ::=    0
&nbsp;&nbsp;&nbsp;&nbsp;<em>Boolean</em> <code>IsZero(x)</code>  ::=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (x) <strong>return</strong> FALSE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else <strong>return</strong> TRUE
&nbsp;&nbsp;&nbsp;&nbsp;<em>Boolean</em> <code>Equal(x,y)</code>  ::=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(x==y) <strong>return</strong> TRUE 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else <strong>return</strong> FALSE
&nbsp;&nbsp;&nbsp;&nbsp;<em>NaturalNumber</em> <code>Successor(x)</code>  ::= 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(x == INT_MAX) <strong>return</strong> x
&nbsp;&nbsp;&nbsp;&amp;nbsp&nbsp;&nbsp;&nbsp;&amp;nbspelse <strong>return</strong> x+1
&nbsp;&nbsp;&nbsp;&amp;nbsp_NaturalNumber_ <code>Add(x,y)</code>  ::= 
&nbsp;&nbsp;&nbsp;&amp;nbsp&nbsp;&nbsp;&nbsp;&amp;nbspif((x+y) &lt;= INT_MAX) <strong>return</strong> x+y
&nbsp;&nbsp;&nbsp;&amp;nbsp&nbsp;&nbsp;&nbsp;&amp;nbspelse <strong>return</strong> INT_MAX
&nbsp;&nbsp;&nbsp;&amp;nbsp_NaturalNumber_ <code>Subtract</code>  ::= 
&nbsp;&nbsp;&nbsp;&amp;nbsp&nbsp;&nbsp;&nbsp;&amp;nbspif(x&lt;y) <strong>return</strong> 0
&nbsp;&nbsp;&nbsp;&amp;nbsp&nbsp;&nbsp;&nbsp;&amp;nbspelse <strong>return</strong> x-y</p>
</li>
<li><p>자세한 구현을 피하기 위해 ADT 사용</p>
</li>
</ul>
<hr>
<h2 id="4-performance-analysis">4. Performance Analysis</h2>
<h4 id="성능-분석의-기준">성능 분석의 기준</h4>
<ol>
<li>프로그램이 원래의 명세와 부합하는가?</li>
<li>정확하게 작동하는가?</li>
<li>프로그램을 어떻게 사용하고 어떻게 수행하는지에 관한 문서화가 프로그램 내에 되어져 있는가?</li>
<li>논리적 단위를 생성하기 위해 프로그램이 함수를 효과적으로 사용하는가?</li>
<li>프로그램 코드는 읽기 쉬운가?</li>
</ol>
<ul>
<li>성능 분석</li>
</ul>
<ol start="6">
<li>프로그램이 메인 메모리와 보조기억장치를 효율적으로 사용하는가?</li>
<li>작업에 대한 프로그램의 실행 시간은 허용할 만한가?</li>
</ol>
<ul>
<li>Performance Analysis : 기계와 독립적인 시간 &amp; 공간에 대해 평가</li>
<li>Performace Measurement : 기계와 독립적이지 않은(의존적인) running time 계산. 비효율적인 코드 찾을 때 사용</li>
</ul>
<h3 id="41-공간-복잡도">4.1 공간 복잡도</h3>
<ul>
<li><p>Fixed space requirement : 고정 공간 요구. 프로그램 입출력의 횟수나 크기와 관계 없는 공간 요구</p>
<ul>
<li>명령어 공간, 단순 변수, 고정 크기의 구조화 변수, 상수 등.</li>
</ul>
</li>
<li><p>Variable space requirement : 특정 인스턴스에 의존하는 크기를 가진 구조화 변수의 공간</p>
</li>
<li><p>전체 프로그램이 필요한 공간 : 고정 공간 + 가변 공간</p>
<blockquote>
<p>$S(P) = c + S_P(I)$</p>
</blockquote>
<p>→ 공간 복잡도 분석시에는 가변 공간 요구에만 관심 가짐. </p>
</li>
<li><p>공간 복잡도 구하는 예시</p>
<pre><code class="language-c">// 단순 산술 함수
float abc(float a, float b, float c){
return a+b+b*c+(a+b-c)/(a+b)+4.0;</code></pre>
<p>→ $S_{abc}(I) = 0$</p>
</li>
</ul>
<pre><code class="language-c">// 리스트에 있는 수를 합산하기 위한 반복 함수
float sum(float list[], int n){
  int i;
  float tempSum = 0;
  for(i = 0; i &lt; n; i++)
    tempSum += list[i];
  return tempSum;
}</code></pre>
<p>→ $S_{n}(I) = 0$ : 인자가 pass-by-reference일 때(포인터로 전달)
→ $S_{n}(I) = n$ : 인자가 pass-by-value일 때(전체 배열 복사)</p>
<pre><code class="language-c">// 리스트에 있는 수를 합산하기 위한 순환 함수
float rsum(float list[], int n){
  if(n) return rsum(list, n-1) + list[n-1];
  return 0;
}</code></pre>
<p>→ 같은 함수라도 순환 함수로 구현하면 공간 요구가 더 커짐.</p>
<hr>
<h3 id="42-시간-복잡도">4.2 시간 복잡도</h3>
<ul>
<li><p>소요되는 총 시간 : 컴파일 시간 + 실행 시간</p>
<blockquote>
<p>$T(P) = c + T_p(I)$</p>
</blockquote>
<p>→ 시간 복잡도 분석시에는 실행 시간에만 관심 가짐. </p>
</li>
<li><p>프로그램 단계 program step : 실행 시간이 인스턴스 특성에 구문적으로 / 의미적으로 독립성을 갖는 프로그램의 단위</p>
</li>
<li><p>시간 복잡도 구하는 예시</p>
<pre><code class="language-c">// 리스트에 있는 수를 합산하기 위한 반복 함수
float sum(float list[], int n){
int i;
float tempSum = 0;
for(i = 0; i &lt; n; i++)
  tempSum += list[i];
return tempSum;
}</code></pre>
<p>→ 2n + 3</p>
<ul>
<li>단계 수 테이블 방식 : 명령문에 대한 단계수(s/e, steps/execution), 빈도수(명령문이 수행되는 횟수, frequency)<ul>
<li>s/e * 빈도수 = 총 단계 수 (total steps)</li>
<li><img src="https://velog.velcdn.com/images/yeonbo_ra/post/45770e01-6c03-46d3-8b4b-516eb624cd23/image.png" alt=""></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li>같은 함수라도 case에 따라 step count가 다를 수 있다.</li>
</ul>
<hr>
<h2 id="43-asymptotic-notation-o-omega-theta">4.3 Asymptotic Notation (O, $\Omega$, $\Theta$)</h2>
<ul>
<li><p>Step count를 직접 구하는 대신 점근 표기법 사용 </p>
<h4 id="big-o-notation">Big-O Notation</h4>
<blockquote>
<p><strong>f(x) = O(g(x))</strong>
↔ x &gt; k 일 때 항상 $|f(x)| \leq C|g(x)|$ 를 만족하는 상수 C와 k 가 존재한다.</p>
</blockquote>
</li>
<li><p>최고 차항만 남기기</p>
</li>
<li><p>Big-O의 예시</p>
<ul>
<li>3n + 2 = O(n)</li>
<li>10n<sup>2</sup> + 4n + 2 = O(n<sup>2</sup>)</li>
<li>6 $\cdot$ 2<sup>n</sup> + 4n<sup>2</sup> + 2 = O(2<sup>n</sup>)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/497c63eb-c1af-44f5-a7e8-f0cd101a10ec/image.png" alt=""></li>
</ul>
</li>
</ul>
<h4 id="big-omega">Big-Omega</h4>
<blockquote>
<p><strong>f(x) = $\Omega$(g(n))</strong>
↔ x &gt; k 일 때 항상 $|f(x)| \geq C|g(x)|$ 를 만족하는 상수 C와 k 가 존재한다.</p>
</blockquote>
<ul>
<li>빅오가 상한값이하면, 오메가는 하한값.</li>
<li>작은 것 중 가장 큰 것.</li>
<li>Big-$\Omega$의 예시<ul>
<li>3n + 2 = $\Omega$(n)</li>
<li>10n<sup>2</sup> + 4n + 2 = $\Omega$(n<sup>2</sup>)</li>
<li>6 $\cdot$ 2<sup>n</sup> + 4n<sup>2</sup> + 2 = $\Omega$(2<sup>n</sup>)</li>
</ul>
</li>
</ul>
<h4 id="big-theta">Big-Theta</h4>
<blockquote>
<p><strong>f(x) = $\Theta$(g(n))</strong>
↔ f(x) = O(g(x)) &amp;&amp; f(x) = Ω(g(x))</p>
</blockquote>
<ul>
<li>Big-$\Theta$의 예시<ul>
<li>3n + 2 = $\Theta$(n)</li>
<li>10n<sup>2</sup> + 4n + 2 = $\Theta$(n<sup>2</sup>)</li>
<li>6 $\cdot$ 2<sup>n</sup> + 4n<sup>2</sup> + 2 = $\Theta$(2<sup>n</sup>)</li>
</ul>
</li>
</ul>
<h4 id="시간-복잡도-구하기">시간 복잡도 구하기</h4>
<ul>
<li><p>[Matrix addition]</p>
<pre><code class="language-c">void add(int a[][MAX_SIZE] ...){
  int i, j;
  for(i = 0; i &lt; rows; i++)
      for(j = 0; j &lt; cols; j++)
          c[i][j] = a[i][j] + b[i][j];
}</code></pre>
<p>→ 시간 복잡도 : $\Theta$(rows * cols)</p>
</li>
<li><p>[Binary Search] 
→ 시간 복잡도 : $\Theta$(log n) </p>
<ul>
<li>best case : $\Theta$(1)</li>
</ul>
</li>
<li><p>[Magic Square]</p>
<pre><code class="language-c">// 매직 스퀘어 프로그램
int main(void){
// 정방형을 반복적으로 생성
int square[MAX_SIZE][MAX_SIZE];
int i, j, row, column;  // 지수
int count; // 계수
int size; // 정방형의 크기

printf(&quot;Enter the size of the square: &quot;);
scanf(&quot;%d&quot;, &amp;size);

// 입력에 오류가 있는지 체크
if(size &lt; 1 || size &gt; MAX_SIZE + 1){
  fprintf(stderr, &quot;Error! Size is out of range\n&quot;);
  exit(1);
}
if(!(size % 2)){
  fprintf(stderr, &quot;Error! Size is even\n&quot;);
  exit(1);
}

for (i=0; i&lt;size; i++)
  for(j=0; j&lt;size; j++)
    square[i][j] = 0;
square[0][(size - 1) / 2] = 1; // 첫 번째 행의 중앙에 1 넣기
// i와 j는 현재 위치
i = 0;
j = (size - 1) / 2;
for(count = 2; count &lt;= size * size; count++){
  // 다음 위치 계산
  row = (i - 1 &lt; 0) ? size - 1 : i - 1;  // 위로
  column = (j - 1 &lt; 0) ? size - 1 : j - 1;  // 왼쪽으로
  // 이미 채워져 있는지 확인
  if(square[row][column]){  // 아래로
    i = (++i) % size;
  }
  else{  // 정방형이 비어있을 경우
    i = row;
    j = column;
  }
  square[i][j] = count;
}
// 정방형 출력
printf(&quot;\nMagic Square of size %d: \n\n&quot;, size);
for(i = 0; i &lt; size; i++){
  for(j = 0; j &lt; size; j++)
    printf(&quot;%5d&quot;, square[i][j]);
  printf(&quot;\n&quot;);
}
printf(&quot;\n\n&quot;);
}</code></pre>
<p>시간 복잡도 : $\Theta$(n<sup>2</sup>)</p>
</li>
</ul>
<hr>
<h3 id="44-실용적-복잡도">4.4 실용적 복잡도</h3>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/da35dc0d-55cb-4007-a87a-6e8570fa71e7/image.png" alt=""></p>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/74ab5420-a837-4f30-9d08-9d669b00c267/image.png" alt=""></p>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/02d9f3b2-99a2-407c-b84b-ccdd7f08a1a0/image.png" alt=""></p>
<hr>
<h2 id="5-performance-measurement">5. Performance Measurement</h2>
<ul>
<li>시간 측정 방법 : &lt;time.h&gt; 사용</li>
</ul>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="center">Method1</th>
<th align="center">Method2</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Start Timing</td>
<td align="center">Start = clock();</td>
<td align="center">Start = time(NULL);</td>
</tr>
<tr>
<td align="left">Stop Timing</td>
<td align="center">Stop = clock();</td>
<td align="center">Stop = time(NULL);</td>
</tr>
<tr>
<td align="left">Type returned</td>
<td align="center">Clock_t</td>
<td align="center">Time_t</td>
</tr>
<tr>
<td align="left">Result in second</td>
<td align="center">Duration = ((double)(Stop-Start))/CLOCKS_PER_SEC;</td>
<td align="center">Duration=(double)difftime(Stop,Start)</td>
</tr>
</tbody></table>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] 04. File I/O]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-04.-File-IO</link>
            <guid>https://velog.io/@yeonbo_ra/Java-04.-File-IO</guid>
            <pubDate>Sat, 12 Oct 2024 10:27:32 GMT</pubDate>
            <description><![CDATA[<h2 id="1-reading--and-writing-files">1. Reading  and Writing Files</h2>
<h3 id="파일-읽기--filereader--bufferedreader">파일 읽기 : FileReader / BufferedReader</h3>
<ul>
<li>한 번 열면 반드시 닫아야 한다. → <code>try-catch</code> 블럭 사용</li>
<li>FileReader : 한글자씩 읽음(비효율적) <ul>
<li>짧은 문자열 읽을 때 사용</li>
</ul>
</li>
<li>BufferedReader : <code>readline()</code> 사용 가능<ul>
<li>주로 이 class를 사용
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/01806e88-5c84-430e-9414-a5d58e09a607/image.png" alt=""></li>
</ul>
</li>
</ul>
<pre><code class="language-java">try (BufferedReader br = new BufferedReader(new FileReader(&quot;file.txt&quot;))) {
    String line;
    while ((line = br.readLine() != null){
        System.out.println(line);
    }
} catch (IOException e) {
    e.printStackTrace();
}</code></pre>
<p>→ FileReader을 인자로 받아 읽도록 함</p>
<h3 id="파일-쓰기--filewriter--bufferedwriter">파일 쓰기 : FileWriter / BufferedWriter</h3>
<ul>
<li>한 번 열면 반드시 닫아야 한다. → <code>try-catch</code> 블럭 사용</li>
<li>FileWriter : 한글자씩 씀(비효율적) <ul>
<li>짧은 문자열 쓸 때 사용</li>
</ul>
</li>
<li>BufferedWriter : String을 한 번에 입력 가능<ul>
<li>주로 이 class를 사용<pre><code class="language-java">try (BufferedWriter bw = new BufferedWriter(new FileWriter(&quot;file.txt&quot;))){
bw.write(&quot;Hello, World!&quot;);
} catch (IOException e) {
e.printStackTrace();
}</code></pre>
→ FileWriter을 인자로 받아 쓰도록 함</li>
</ul>
</li>
</ul>
<hr>
<h2 id="2-serialization">2. Serialization</h2>
<h3 id="시리얼화">시리얼화</h3>
<ul>
<li><p>어떤 타입의 객체(object)이던 상관없이 byte 타입으로 저장하는 것</p>
</li>
<li><p>ObjectOutputStream / ObjectInputStream 사용</p>
</li>
<li><p>How to?</p>
<ol>
<li><p>Serialzable 인터페이스 implement &amp; serialVersionID 통해 check</p>
<pre><code class="language-java">   public class MyClass implements Serializable {
       private static final long serialVersionID = 1L;

       // class field and method
   }</code></pre>
</li>
<li><p>객체를 시리얼화 : ObjectOutStream 사용 → File에 저장</p>
<pre><code class="language-java">   try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(&quot;object.ser&quot;))) {
       oos.writeObject(new Myclass()));
   } catch (IOException e) {
       e.printStackTrace();
   }</code></pre>
<p>   → FileOutputStream을 인자로 받아 사용</p>
</li>
<li><p>시리얼에서 다시 객체로 불러오기 → File에서 불러와서 객체에 저장</p>
<pre><code class="language-java">   try(ObjectInputStream ois = new ObjectInputStream(new FileInputStream(&quot;object.ser&quot;))){
       MyClass obj = (MyClass) ois.readObject();
   } catch (IOException | ClassNotFoundException e){
       e.printStactTrace();
   }</code></pre>
<p>   → FileInputStream을 인자로 받아 사용</p>
<h3 id="시리얼화의-장점">시리얼화의 장점</h3>
</li>
</ol>
</li>
<li><p>Persistence : 파일 or DB에 저장했다 다시 불러올 수 있음</p>
</li>
<li><p>Distributed system : 다른 JVM에 전달 가능</p>
</li>
<li><p>Deep copy : 객체의 깊은 복사할 때 사용 가능</p>
</li>
<li><p>Caching : 캐싱할 때 좋음</p>
</li>
<li><p>Interoperability : 여러 곳에서 사용 가능</p>
</li>
<li><p>Versioning : 시리얼 ID를 통해 버전 체크 가능</p>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] 03. Exception Handing]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-03.-Exception-Handing</link>
            <guid>https://velog.io/@yeonbo_ra/Java-03.-Exception-Handing</guid>
            <pubDate>Sat, 12 Oct 2024 10:05:51 GMT</pubDate>
            <description><![CDATA[<h2 id="1-exception-hierarchy">1. Exception Hierarchy</h2>
<h3 id="throwable">Throwable</h3>
<ul>
<li><p>Error와 Exception의 상위 클래스
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/050bd621-8f1f-4f9e-b39b-69e44e5371ba/image.png" alt=""></p>
</li>
<li><p>Throwable </p>
<ul>
<li><strong>Error</strong><ul>
<li><code>OutOfMemoryError</code></li>
<li><code>StackOverflowError</code></li>
<li><code>VirtualMachineError</code></li>
<li>etc.</li>
</ul>
</li>
<li><strong>Exception</strong><ul>
<li><code>RuntimeException</code><ul>
<li><code>NullPointerException</code></li>
<li><code>ArrayIndexOutOfBoundsException</code></li>
<li><code>ClassCastException</code></li>
<li>etc.</li>
</ul>
</li>
<li><code>IOException</code></li>
<li><code>SQLException</code></li>
<li>etc.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="error-클래스">Error 클래스</h3>
<ul>
<li>컴퓨터에 영향을 줄 수 있어서 발생. JVM이 찾아냄</li>
<li>환경에 다뤄야 하는 부분
ex) OutOfMemoryError, StackOverflowError, VirtualMachineError</li>
</ul>
<h3 id="exception-클래스">Exception 클래스</h3>
<ul>
<li><p>런타임 중에 발생. 직접 체크해야하는 부분</p>
</li>
<li><p>Checked : <code>try-catch</code> 구문으로 예외를 처리해야 하는 부분</p>
<ul>
<li>IOException, SQLException, ClassNotFoundException</li>
</ul>
</li>
<li><p>Unchecked : 코드 수정으로 처리해야 하는 부분</p>
<ul>
<li>NullPointerException, ArrayIndexOutOfBoundsException</li>
</ul>
</li>
<li><p>예외의 상하 관계 
ex) FileNotFoundException &lt; IOException &lt; Exception</p>
</li>
</ul>
<h2 id="2-try-catch-block-and-throw-clause">2. Try-Catch Block and Throw Clause</h2>
<h3 id="try-catch-블럭">Try-Catch 블럭</h3>
<pre><code class="language-java">try {
    // 예외를 찾을 수 있는 코드 넣기
} catch (ExceptionType2 e1) {
    // 오류 발생 시 실행할 구문
} catch (ExceptionType2 e2) {
    // 한 try에 여러 catch 사용 가능
} finally {
    // 오류 발생 여부 관계 없이 반드시 실행
}</code></pre>
<ul>
<li>try에서 예외가 발생되는 순간 바로 catch로 넘어간다. 예외 발생 시점 이후의 try 구문은 무시된다.</li>
<li>catch에 들어가는 예외는 작은 → 큰 순으로 적어야 한다.</li>
<li>Exception 클래스는 모든 예외의 상위 클래스, 어떤 예외라도 받을 수 있다.</li>
</ul>
<h3 id="throw-clause">Throw clause</h3>
<ul>
<li>특정 메소드가 exception을 throw 할 수 있다고 경고하는 것<pre><code class="language-java">public void myMethod() throws IOException {
</code></pre>
</li>
</ul>
<p>}</p>
<pre><code>- exception에 대한 경고가 있는 메소드는 반드시 try-catch로 처리해야한다.
  - 처리 위치는 상관이 없으나, 처리 안할시 오류 발생

## 3. Custom Exception
- 사용자가 직접 만드는 예외
  - 클래스 정의 &amp; 생성자로 예외 생성
   ``` java
  public class MyCustomException extends Exception {
      public MyCustomException(String Message){ // 생성자
          super(message);
  }</code></pre><pre><code> → Exception 클래스 상속 받기</code></pre><ul>
<li>예외가 들어갈 메소드 만들기 &amp; 예외 던지기<pre><code class="language-java">public class TestCustomException {
  public void myMethod() thorws MyCustomException{
       throw new MyCustomException(&quot;Custom error message&quot;);
   }
}</code></pre>
</li>
<li>main : 예외가 들어간 메소드 실행 &amp; 예외 처리<pre><code class="language-java">public static void main(String[] args) {
  TestCustomException test = new TestCustomException();
   try{
       test.myMethod();    
   } catch (MyCustomException e) {
       System.out.println(&quot;Caught custom exception: &quot; + e.getMessage());
   }
}</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] 02. OOP]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-02.-OOP</link>
            <guid>https://velog.io/@yeonbo_ra/Java-02.-OOP</guid>
            <pubDate>Sun, 06 Oct 2024 08:21:29 GMT</pubDate>
            <description><![CDATA[<h2 id="1-introduction-to-oop">1. Introduction to OOP</h2>
<h3 id="oop의-정의">OOP의 정의</h3>
<blockquote>
<p><strong>Object-Oriented Programming</strong> : 객체지향적 프로그래밍</p>
</blockquote>
<ul>
<li>Object : 객체, 데이터와 메소드를 캡슐화한 class의 인스턴스 단위</li>
<li>Class : 클래스, Object의 청사진</li>
<li>Data : 변수, field</li>
<li>Code : 메소드, method</li>
</ul>
<h3 id="oop의-장점">OOP의 장점</h3>
<ul>
<li><p>Modularity 모듈성 :  하나의 큰 덩어리를 만들기 위해 작은 모듈로 나누는 것</p>
</li>
<li><p>Reusability 재사용성 : 코드를 재사용 하기 좋음</p>
</li>
<li><p>Extensibility 확장성 : 존재하는 코드의 기능을 늘리기 좋음 (상속)</p>
<ul>
<li>core 한 기능을 구현 해놓고 파츠를 붙임</li>
</ul>
</li>
<li><p>Maintainability 유지성 : 부분들이 나눠져 있어 유지 보수에 좋음</p>
<ul>
<li>변화가 필요한 부분에만 코드 수정</li>
</ul>
</li>
</ul>
<hr>
<h2 id="2-classes-and-objects">2. Classes and Objects</h2>
<h3 id="class---클래스">Class - 클래스</h3>
<blockquote>
<p><strong>Class</strong> : object를 만드는 청사진. 변수와 메소드를 정의함.</p>
</blockquote>
<pre><code class="language-java">public class Car{
    String color;
    int speed;
    //field

    void accelerate(){
        speed += 10;
    }
    // method
}</code></pre>
<h3 id="object---객체">Object - 객체</h3>
<blockquote>
<p><strong>Object</strong> : class의 인스턴스. new 키워드를 사용해서 만들어짐.</p>
</blockquote>
<pre><code class="language-java">Car myCar = new Car();
// Car 클래스의 myCar라는 새로운 객체 생성
myCar.color = &quot;red&quot;;
myCar.accelerate();
// 클래스 정의 시의 변수와 메소드 사용 가능</code></pre>
<hr>
<h2 id="3-constructors-and-methods">3. Constructors and Methods</h2>
<h3 id="constructor---생성자">Constructor - 생성자</h3>
<blockquote>
<p><strong>Constructor</strong> : 객체가 생성될 때 <strong>초기화</strong> 할 수 있는 특별한 메소드</p>
</blockquote>
<ul>
<li>생성자의 이름은 class 명과 동일.</li>
<li>this 키워드 사용 가능(오직 생성자에서만 사용 가능)</li>
<li>Overloading 가눙</li>
</ul>
<pre><code class="language-java">public class Car{
    String color;
    int speed;

    //Constructor
    public Car(String color, int speed){
        this.color = color;
        this.speed = speed;
    }
}</code></pre>
<h3 id="methods---메소드">Methods - 메소드</h3>
<blockquote>
<p><strong>Method</strong> : class 안에 존재하는 함수들</p>
</blockquote>
<pre><code class="language-java">public class Car{
    String color;
    int speed;

    // Method
    void accelerate(){
        speed += 10;
    }

}</code></pre>
<hr>
<h2 id="3-inheritance-and-polymorphism">3. Inheritance and Polymorphism</h2>
<h3 id="inheritance---상속">Inheritance - 상속</h3>
<blockquote>
<p><strong>상속</strong> : 다른 class의 메소드와 변수를 상속 받는 것</p>
</blockquote>
<ul>
<li><p><code>extends</code> 키워드 사용</p>
<ul>
<li>superclass : 상위 클래스</li>
<li>subclass : 하위 클래스</li>
</ul>
</li>
<li><p>장점 : Reusability(재사용성), Hierarchy(상하관계), Overriding(오버라이딩)</p>
</li>
<li><p>생성자에서 <code>super</code> 키워드 사용 가능</p>
</li>
</ul>
<pre><code class="language-java">public class Animal{
    private String name;

    // Constructor
    public Animal(String name){
        this.name = name;
    }

    // Method
    public void makeSound(){
        System.out.println(&quot;Some animal Sound&quot;);
}</code></pre>
<p>→ 상위 클래스</p>
<pre><code class="language-java">public class Dog extends Animal{ 
    // Constructor
    public Dog(String name){
        super(name);
    }

    @Override
    public void makeSound(){
        System.out.println(&quot;Bark&quot;);
}</code></pre>
<p>→ 하위 클래스</p>
<ul>
<li>상속에는 다양한 형태가 있다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/10dc28ce-bcc3-40e1-bbb6-e5e95aecc1b2/image.png" alt="상속의 다양한 형태"></li>
</ul>
<h3 id="polymorphism---다형성">Polymorphism - 다형성</h3>
<blockquote>
<p><strong>Method Overriding</strong> : 상위 클래스의 메소드를 하위 클래스에서 재사용 하는 것</p>
</blockquote>
<blockquote>
<p><strong>Method Overloading</strong> : 같은 이름, 다른 인자를 가지는 메소드를 만드는 것. <code>반드시 다른 인자를 가져야 함.</code></p>
</blockquote>
<pre><code class="language-java">public class MathOperations{
    // 두 정수 더하기
    public int add(int a, int b)
        return a + b;

    // 세 정수 더하기로 overloading
    public int add(int a, int b, int c)
        return a + b + c;

    // 두 실수 더하기로 overloading
    public double add(double a, double b)
        return a + b;
}</code></pre>
<blockquote>
<p><strong>Dynamic Method Dispatch</strong> : 동적 메소드 디스패치. 하위 클래스는 상위 클래스를 대체할 수 있다.</p>
</blockquote>
<pre><code class="language-java">public static void main(String[] args){
    Animal myDog = new Dog(&quot;Buddy&quot;);
    Animal myCat = new Cat(&quot;Whiskers&quot;);
}</code></pre>
<ul>
<li>Animal 배열에 myDog, myCat이 들어갈 수 있다(Animal class를 상속하고 있기 때문에)</li>
</ul>
<hr>
<h2 id="4-encapsulation-and-abstraction">4. Encapsulation and Abstraction</h2>
<h3 id="encapsulation---캡슐화">Encapsulation - 캡슐화</h3>
<ul>
<li>접근 권한을 제한하기 위해 사용</li>
<li>접근 제한자를 활용한 데이터 숨김 → 함부로 열 수 없다</li>
<li>Getter &amp; Setter</li>
</ul>
<h3 id="access-modifier---접근-제한자">Access Modifier - 접근 제한자</h3>
<blockquote>
<p><strong>default</strong> : 기본값. 같은 package 내에서 사용 가능
<strong>public</strong> : 어디에서나, 누구나 사용 가능
<strong>private</strong> : class 내부에서만 사용 가능
<strong>protected</strong> : 같은 package + package 밖의 상속된 하위 클래스에서 사용 가능</p>
</blockquote>
<ul>
<li>보안 수준 : private &lt; default &lt; protected &lt; public</li>
<li>package 패키지 : 다른 패키지의 class를 이용하기 위해선 import 사용해야 한다.</li>
</ul>
<h3 id="abstraction---추상화">Abstraction - 추상화</h3>
<ul>
<li>디테일이 없는, 모양만 잡아둔 것. class, method 에 사용할 수 있다<pre><code class="language-java">abstract class Shape{ // 추상 클래스
  abstract double area();  // 추상 메소드
}</code></pre>
</li>
<li>추상 메소드는 내부에 코드를 작성하지 않는다.</li>
</ul>
<hr>
<h2 id="5-interfaces-and-abstract-classes">5. Interfaces and Abstract Classes</h2>
<h3 id="abstract-class---추상-클래스">Abstract Class - 추상 클래스</h3>
<ul>
<li><p>class이지만 인스턴스를 생성할 수 없다. <code>상속</code>의 역할.</p>
</li>
<li><p>추상 메소드 + 일반 메소드 both 생성 가능</p>
</li>
<li><p>변수 포함 가능</p>
<pre><code class="language-java">abstract class Shape{
  double length;  // 변수

  abstract double area();  // 추상 메소드
  void display(){  // 일반 메소드
      System.out.println(&quot;Displaying Shape&quot;);
  }
}</code></pre>
</li>
<li><p>상속 후 <code>overriding</code>을 통해 메소드의 세부 내용을 채워야 함.</p>
</li>
<li><p><code>A는 B다</code>의 관계 </p>
<ul>
<li>고양이는 동물이다</li>
<li>직사각형은 도형이다</li>
</ul>
</li>
</ul>
<h3 id="interface-인터페이스">Interface 인터페이스</h3>
<ul>
<li>추상 메소드만 포함 가능.</li>
<li>클래스와 상관없이 사용 가능. </li>
<li><code>implements</code> 키워드 사용. 한 번에 다양한 인터페이스 implement 가능<pre><code class="language-java">interface Sound {
  void makeSound();
}
</code></pre>
</li>
</ul>
<p>class Dog implements Sound{
    @Override
    public void makeSound(){
        System.out.println(&quot;Bark&quot;);
    }
}</p>
<p>```</p>
<ul>
<li><code>기능</code>에 관한 내용 <ul>
<li>동물은 귀여운 소리를 낸다</li>
<li>로봇은 귀여운 소리를 낸다</li>
</ul>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Java] 01. Java Basics]]></title>
            <link>https://velog.io/@yeonbo_ra/Java-01.-Java-Basics</link>
            <guid>https://velog.io/@yeonbo_ra/Java-01.-Java-Basics</guid>
            <pubDate>Sun, 06 Oct 2024 02:47:54 GMT</pubDate>
            <description><![CDATA[<h2 id="1-java-syntax-and-structure">1. Java Syntax and Structure</h2>
<h3 id="자바-프로그램의-기본-구조">자바 프로그램의 기본 구조</h3>
<blockquote>
<p>class : object 를 만드는 청사진. 변수와 메소드로 구성</p>
</blockquote>
<pre><code class="language-java">public class ClassName{
     // fields 변수
    // methods 함수
}</code></pre>
<ul>
<li>main 함수 : 실행의 시작점. 클래스에 1개만 존재할 수 있음<pre><code class="language-java">public static void main(String[] args) {
    // 실행할 코드
}</code></pre>
</li>
</ul>
<hr>
<h3 id="문법-규칙">문법 규칙</h3>
<ul>
<li><p>대문자 / 소문자 구별</p>
</li>
<li><p>이름 짓는 규칙</p>
<ul>
<li>class : 대문자 시작, <code>CamelCase</code> 사용
<code>MyClass</code></li>
<li>메소드 &amp; 변수 : 소문자 시작, <code>camelCase</code> 사용
<code>myVariable</code> / <code>myMethod</code></li>
<li>상수 : 대문자로만 작성, 공백은 <code>_</code> 사용
<code>MAX_VALUE</code></li>
</ul>
</li>
<li><p>주석</p>
<ul>
<li><p>한 줄 주석 : <code>//</code></p>
</li>
<li><p>여러 줄 주석 : <code>/*  */</code></p>
</li>
<li><p>Documentation Comments : <code>/**  */</code></p>
<pre><code class="language-java">public class Class{
  // 한 줄 주석

  /* 여러 줄
     주석 */

  /**
   * Documentation
   * Comments
   */
}</code></pre>
</li>
</ul>
</li>
</ul>
<hr>
<h2 id="2-data-types-variavles-and-operators">2. Data Types, Variavles, and Operators</h2>
<h3 id="원시-데이터-타입">원시 데이터 타입</h3>
<ul>
<li>정수</li>
</ul>
<table>
<thead>
<tr>
<th align="center">byte</th>
<th align="center">short</th>
<th align="center">int</th>
<th align="center">long</th>
</tr>
</thead>
<tbody><tr>
<td align="center">8 bit</td>
<td align="center">16bit</td>
<td align="center">32 bit</td>
<td align="center">64 bit</td>
</tr>
<tr>
<td align="center">~128 ~ 127</td>
<td align="center">-32,768 ~ 32,767</td>
<td align="center">-2<sup>31</sup> ~ 2<sup>31</sup>-1</td>
<td align="center">-2<sup>63</sup> ~ 2<sup>63</sup>-1</td>
</tr>
</tbody></table>
<ul>
<li>실수</li>
</ul>
<table>
<thead>
<tr>
<th align="center">float</th>
<th align="center">double</th>
</tr>
</thead>
<tbody><tr>
<td align="center">32 bit</td>
<td align="center">64 bit</td>
</tr>
</tbody></table>
<ul>
<li>기타 타입</li>
</ul>
<table>
<thead>
<tr>
<th align="center">char</th>
<th align="center">boolean</th>
</tr>
</thead>
<tbody><tr>
<td align="center">16 bit</td>
<td align="center">1 bit</td>
</tr>
<tr>
<td align="center">0 ~ 65,535</td>
<td align="center">true / false</td>
</tr>
</tbody></table>
<hr>
<h3 id="변수와-변수의-범위">변수와 변수의 범위</h3>
<blockquote>
<p>변수의 선언과 초기화</p>
</blockquote>
<pre><code class="language-java">int number;  // 선언
number = 10; // 초기화
int number = 10; // 선언과 동시에 초기화 가능</code></pre>
<h4 id="변수의-범위">변수의 범위</h4>
<ul>
<li><p>지역 변수 : 메소드나 중괄호 블럭 내에 선언된 변수. 벗어날 시 소멸</p>
<pre><code class="language-java">public void myMethod(){
  int localVar = 10;  // myMethod 내부에서만 존재하는 지역 변수
}
// 메소드 밖으로 나가면 소멸</code></pre>
</li>
<li><p>인스턴스 변수(객체 변수) : 클래스 안에 있지만 메소드 밖에 있는 변수. 객체(인스턴스) 당 하나
  → 클래스 안 모든 메소드에서 사용 가능. 객체(인스턴스) 소멸 시 같이 소멸</p>
<pre><code class="language-java">public class myClass{
  int instanceVar;  // myClass 안에서 존재하는 인스턴스 변수
}</code></pre>
</li>
<li><p>static variable 정적 변수, 클래스 변수 : static 키워드가 붙은 클래스 변수</p>
<ul>
<li>같은 클래스를 가지는 모든 객체(인스턴스)가 공유. 클래스 당 하나</li>
<li>클래스가 로딩되는 시점에 생겨남. (객체 생성 이전)<pre><code class="language-java">public class myClass{
static int classVar;  // 같은 클래스를 가진 모든 객체가 공유하는 변수
}</code></pre>
</li>
</ul>
</li>
</ul>
<hr>
<h3 id="연산자">연산자</h3>
<ul>
<li>비교 연산자</li>
</ul>
<table>
<thead>
<tr>
<th align="center">==</th>
<th align="center">!=</th>
<th align="center">&gt;</th>
<th align="center">&gt;=</th>
</tr>
</thead>
<tbody><tr>
<td align="center">같을 때 참</td>
<td align="center">다를 때 참</td>
<td align="center">클 때 참</td>
<td align="center">크거나 같을 때 참</td>
</tr>
</tbody></table>
<ul>
<li>논리 연산자</li>
</ul>
<table>
<thead>
<tr>
<th align="center">&amp;&amp;</th>
<th align="center">||</th>
<th align="center">!</th>
</tr>
</thead>
<tbody><tr>
<td align="center">AND</td>
<td align="center">OR</td>
<td align="center">NOT</td>
</tr>
</tbody></table>
<hr>
<h2 id="3-control-flow-statements">3. Control Flow Statements</h2>
<h3 id="조건문">조건문</h3>
<ul>
<li><p>if, else if, else </p>
<pre><code class="language-java">int number = 10;
if (number &gt; 0) {
  System.out.println(&quot;Positive&quot;);
} else if (number &lt; 0) {
  System.out.println(&quot;Negative&quot;);
} else {
  System.out.println(&quot;Zero&quot;);
}</code></pre>
</li>
<li><p>switch</p>
<pre><code class="language-java">int day = 3;
switch(day) {
  case 1 :
      System.out.println(&quot;Monday&quot;);
      break;
  case 2 :
      System.out.println(&quot;Tuesday&quot;);
      break;
  case 3 :
      System.out.println(&quot;Wednesday&quot;);
      break;
  default:
      System.out.println(&quot;Other day&quot;);
}</code></pre>
</li>
</ul>
<hr>
<h3 id="반복문">반복문</h3>
<ul>
<li>for</li>
<li>while</li>
<li>do ~ while<pre><code class="language-java">int i = 0;
do {
  System.out.println(&quot;Iteration: &quot; + i);
  i++;
} while (i&lt;5);</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[이산구조] 02. Predicate Logic]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-02.-Predicate-Logic</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-02.-Predicate-Logic</guid>
            <pubDate>Sat, 05 Oct 2024 23:17:58 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/cc9fe860-4629-4501-93c1-fd76a14bfe3c/image.jpg" alt=""></p>
<h1 id="module-2-basic-proof-methods">Module #2: Basic Proof Methods</h1>
<h2 id="1-predicate-logic">1. Predicate Logic</h2>
<blockquote>
<p>P(x) : x is greater than 3</p>
</blockquote>
<ul>
<li><p>명제함수(propositional function) P에서의 x의 값</p>
</li>
<li><p><em>주어*</em> : x</p>
</li>
<li><p><em>술어(predicate)*</em> : is greater than 3</p>
</li>
<li><p>규칙</p>
<ul>
<li>함수는 대문자, 변수는 소문자</li>
<li>함수 그 자체(P)는 명제가 아님. 변수가 들어가야 명제 (P(3), P(x))</li>
<li>변수는 1개 이상 가능 P(x, y, z)</li>
</ul>
</li>
<li><p>Universes of Discourse : 정의역</p>
</li>
</ul>
<hr>
<h3 id="한정기호">한정기호</h3>
<blockquote>
<p>전칭 한정기호(∀)  : 정의역에 속하는 모든 x값에 대하여 P(x)이다. </p>
</blockquote>
<ul>
<li>P(x)가 거짓이 되는 원소를 ∀xP(x)의 반례라고 부른다</li>
</ul>
<blockquote>
<p>존재 한정기호(∃) : 정의역에 속하는 적어도 하나의 값 x에 대하여 P(x)이다.</p>
<blockquote>
<p>유일 한정기호(∃!) : 유일하게 한 개만 존재할 때 사용한다.</p>
</blockquote>
</blockquote>
<table>
<thead>
<tr>
<th align="left">문장</th>
<th align="left">T</th>
<th align="left">F</th>
</tr>
</thead>
<tbody><tr>
<td align="left">∀xP(x)</td>
<td align="left">모든 x에 대하여 P(x)가 참이다.</td>
<td align="left">P(x)가 거짓이 되는 x가 존재한다.</td>
</tr>
<tr>
<td align="left">∃xP(x)</td>
<td align="left">P(x)가 참이 되는 x가 존재한다.</td>
<td align="left">모든 x에 대하여 P(x)가 거짓이다.</td>
</tr>
</tbody></table>
<ul>
<li>한정 기호의 순서에 따라 뜻이 달라진다</li>
</ul>
<table>
<thead>
<tr>
<th align="left">표현</th>
<th align="left">의미</th>
</tr>
</thead>
<tbody><tr>
<td align="left">∀x∀yP(x,y)</td>
<td align="left">모든 x, y의 쌍에 대하여 P(x, y)가 참이다.</td>
</tr>
<tr>
<td align="left">∀x∃yP(x,y)</td>
<td align="left">모든 x에 대하여 P(x, y)가 참이 되는 y가 있다.</td>
</tr>
<tr>
<td align="left">∃x∀yP(x,y)</td>
<td align="left">어떤 x에 대하여 모든 y에 대해 P(x, y)가 참이다.</td>
</tr>
<tr>
<td align="left">∃x∃yP(x,y)</td>
<td align="left">P(x, y)가 참이 되는 x, y의 쌍이 있다.</td>
</tr>
</tbody></table>
<ul>
<li>한정기호는 모든 논리 연산자보다 상위의 우선순위를 갖는다<blockquote>
<p>∃xQ(x) ∨ P(x) =  (∃xQ(x)) ∨ P(x)</p>
</blockquote>
</li>
</ul>
<h4 id="한정-기호에-대한-드-모르간-법칙">한정 기호에 대한 드 모르간 법칙</h4>
<blockquote>
<p><del>∀xP(x) = ∃x</del>P(x)
<del>∃xP(x) = ∀x</del>P(x)</p>
</blockquote>
<hr>
<h3 id="구속-변수와-자유-변수">구속 변수와 자유 변수</h3>
<blockquote>
<p>구속 변수 : 한정 기호가 적용된 변수</p>
</blockquote>
<blockquote>
<p>자유 변수 : 한정 기호가 적용되어 있지 않거나, 값이 할당되어 있지 않은 변수</p>
</blockquote>
<p>ex) ∀xP(x,y)에서 x는 구속 변수, y는 자유 변수이다.</p>
<hr>
<h2 id="2-proof">2. Proof</h2>
<h3 id="proof-terminology">Proof Terminology</h3>
<ul>
<li>Theroem(정리) : 참이라고 증명된 하나의 진술</li>
<li>Axiom(공리), hypotheses(가설), premises(전제) : 우리가 추론하는 구조를 정의하는 가정들</li>
<li>Rules of inference(추론 규칙) : 가설에서 결론을 도출하는 논리적으로 타당한 추론 패턴</li>
<li>Lemma(보조정리) : 주요 정리를 증명하기 위한 중간 단계로 사용되는 작은 정리</li>
<li>Corollary(따름정리) : 증명된 정리로부터 직접적으로 귀결될 수 있는 정리</li>
<li>Conjecture(가설) : 어떤 부분적 증거에 근거해 참이라고 주장되는 문장. </li>
<li>Theory(이론) : 주어진 공리 집합에서 증명할 수 있는 모든 정리들의 모음</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/24f92637-fbe4-424c-9f9e-f81b90490ff7/image.png" alt="Theory Visualization"></p>
<h3 id="inference-rules-추론-규칙">Inference Rules 추론 규칙</h3>
<ul>
<li>전제가 모두 참이면 결론도 참이다.</li>
</ul>
<blockquote>
<p><strong>Rule of Addtion</strong> (∨ 도입)</p>
</blockquote>
<ol>
<li>p
__</li>
<li>p ∨ q</li>
</ol>
<blockquote>
<p><strong>Rule of Simplification</strong> (∧ 제거)</p>
</blockquote>
<ol>
<li>p ∧ q
__</li>
<li>p</li>
</ol>
<blockquote>
<p><strong>Rule of Conjunction</strong> (∧ 도입)</p>
</blockquote>
<ol>
<li>p</li>
<li>q
__</li>
<li>p ∧ q</li>
</ol>
<blockquote>
<p><strong>Rule of modus ponens</strong> (the mode of affirming, → 제거)</p>
</blockquote>
<ol>
<li>p</li>
<li>p → q
__</li>
<li>q</li>
</ol>
<blockquote>
<p><strong>Rule of modus tollens</strong> (the mode of denying, 후건 부정)</p>
</blockquote>
<ol>
<li>~q</li>
<li>p → q
__</li>
<li>~p</li>
</ol>
<blockquote>
<p><strong>Rule of hypothetical syllogism</strong> (가설적 삼단논법)</p>
</blockquote>
<ol>
<li>p → q</li>
<li>q → r
__</li>
<li>p → r</li>
</ol>
<blockquote>
<p><strong>Rule of disjunctive syllogism</strong> (선언적 삼단논법, ∨ 제거)</p>
</blockquote>
<ol>
<li>p ∨ q</li>
<li>~p
__ </li>
<li>q</li>
</ol>
<h3 id="inference-rules-for-quantifiers-양화사의-추론규칙">Inference Rules for Quantifiers 양화사의 추론규칙</h3>
<blockquote>
<p><strong>Universal instantiation</strong> (∀ 제거)</p>
</blockquote>
<ol>
<li>∀x P(x)
__</li>
<li>P(o)  // 임의의 o 가정</li>
</ol>
<blockquote>
<p><strong>Universal generalization</strong> (∀ 도입)</p>
</blockquote>
<ol>
<li>P(g)  // 임의의 g 가정
__</li>
<li>∀x P(x)</li>
</ol>
<blockquote>
<p><strong>Existential instantiation</strong> (∃ 제거)</p>
</blockquote>
<ol>
<li>∃x P(x)
__</li>
<li>P(c)  // 임의의 c 가정</li>
</ol>
<blockquote>
<p><strong>Existential generalization</strong> (∃ 도입)</p>
</blockquote>
<ol>
<li>P(o)  // 임의의 존재하는 o 가정
__</li>
<li>∃x P(x)</li>
</ol>
<h3 id="증명의-오류들">증명의 오류들</h3>
<ul>
<li>Affirming the conclusion : 결론 긍정의 오류. 결론이 참일지라도 전제가 거짓일 수 있다.</li>
<li>Denying the hypothesiss : 가설 부정의 오류. p → q 일때, p가 거짓이라고해서 q가 거짓인 것은 아니다.</li>
<li>Circular Reasoning : 순환 논증. 결론을 뒷받침하기 위해 결론을 다시 사용하는 오류</li>
</ul>
<h3 id="증명의-방법들-p-→-q">증명의 방법들 (p → q)</h3>
<ul>
<li>Direct Proof 직접 증명 : p가 참일 때, q가 참임을 증명</li>
<li>Indirect Proof 간접 증명(대우에 의한 증명) : ~q를 가정하고, ~p임을 증명</li>
<li>Vacuous Proof 공허한 증명 : ~p를 증명</li>
<li>Trivial Proof 자명한 증명 : q를 증명</li>
<li>Proof by Contradiction 모순에 의한 증명 <ul>
<li>~p → (q ∧ ~q) 이 참임을 보여 p가 참임을 증명</li>
</ul>
</li>
<li>Proving Existential<ul>
<li>Existence Proof 존재 증명 : ∃x P(x)일 때, P를 만족하는 원소를 구함. → 생산적 증명</li>
<li>비생산적 증명 : 존재 정량화의 부정을 모순법을 사용해 증명</li>
</ul>
</li>
<li>Proof by cases 경우에 의한 증명 : 모든 경우의 수를 고려해 증명</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[디지털 회로 개론] 02. Combinational Systems]]></title>
            <link>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-02.-Combinational-Systems</link>
            <guid>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-02.-Combinational-Systems</guid>
            <pubDate>Fri, 04 Oct 2024 05:25:22 GMT</pubDate>
            <description><![CDATA[<h1 id="21-조합-시스템">2.1 조합 시스템</h1>
<blockquote>
<p>조합 시스템 Combinational System : 클락을 사용하지 않는 디지털 회로</p>
</blockquote>
<blockquote>
<p>디지털 회로(Digital circuit) : binary 정보를 조작하는 하드웨어 부품</p>
</blockquote>
<blockquote>
<p>논리 게이트는 논리 함수를 구현한다.
논리 함수 : AND, OR, NOT, XOR, NOR, NAND</p>
</blockquote>
<blockquote>
<p>Boolean Algebra : 논리 함수를 특정하고 변환하기 위한 수학적 시스템</p>
</blockquote>
<h3 id="level-of-abstraction-추상화-레벨">Level of Abstraction 추상화 레벨</h3>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/3f6fbeb0-d682-45dd-9335-70ccf47d535d/image.png" alt="추상화 레벨"></p>
<hr>
<h1 id="22-logical-operation-논리-연산자">2.2 Logical Operation 논리 연산자</h1>
<h4 id="--기본-연산자">- 기본 연산자</h4>
<blockquote>
<p>AND ( · )
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/b1b65a31-4a76-4c2d-b03b-1416dd5fcc25/image.png" alt="AND 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">xy</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</tbody></table>
<blockquote>
<p>OR (+)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/4aebbcf9-142b-4f74-9f03-acb41c934b43/image.png" alt="OR 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">x+y</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</tbody></table>
<blockquote>
<p>NOT (~)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/6f4d8d0f-9aaa-41a2-b8e6-1696657928de/image.png" alt="NOT 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">~x</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
</tr>
</tbody></table>
<blockquote>
<p>XOR (⊕)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/6ffad3e7-ae0c-474f-9639-4acd889c00ce/image.png" alt="XOR 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">x⊕y</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
</tbody></table>
<blockquote>
<p>NAND / (xy)&#39;
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/dbb84dbe-b4fc-4a91-af30-70f625b950d8/image.png" alt="NAND 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">(xy)&#39;</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
</tbody></table>
<blockquote>
<p>NOR / (x+y)&#39;
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/6a196fe8-8295-412c-9acf-1a1417fea902/image.png" alt="NOR 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">(x+y)&#39;</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
</tbody></table>
<blockquote>
<p>XNOR (x⊙y)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/ab511fc1-c03c-49e1-a1ee-6e8cade21b27/image.png" alt="XNOR 기호"></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">x</th>
<th align="center">y</th>
<th align="center">x⊙y</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</tbody></table>
<h4 id="--스위치에서의-논리-연산자">- 스위치에서의 논리 연산자</h4>
<p>AND → 직렬
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/d33de74a-6b38-447d-849b-2c43414f061a/image.png" alt="AND 스위치"></p>
<p>OR → 병렬
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/bed34867-6d8f-4f31-8daa-c9df09487711/image.png" alt="OR 스위치"></p>
<p>NOT → 기본적으로 닫혀있는 스위치
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/4e7204df-c6cc-4b6d-8781-f2c3b7f535ef/image.png" alt=""></p>
<p>똑같은 논리 함수에 대해 진리표(truth table), 논리 선도(logic diagram), 논리식(boolean equation)로 표현할 수 있다.</p>
<ul>
<li>논리 선도
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/bc6cb553-85d2-4fe5-8101-653af79713c1/image.png" alt="논리 선도"></li>
</ul>
<hr>
<h1 id="23-switching-algebra">2.3 Switching Algebra</h1>
<blockquote>
<ol>
<li>Commutative (교환 법칙)
a + b = b + a
ab = ba</li>
</ol>
</blockquote>
<blockquote>
<ol start="2">
<li>Associative (결합 법칙)
a + (b + c) = (a + b) + c
a(bc) = (ab)c</li>
</ol>
</blockquote>
<blockquote>
<ol start="3">
<li>Identity (항등원)
a + 0 = a<br>0 + a = a
a · 1 = a
1 · a = a</li>
</ol>
</blockquote>
<blockquote>
<ol start="4">
<li>Null (무효화)
a + 1 = 1
1 + a = 1
a · 0 = 0
0 · a = 0</li>
</ol>
</blockquote>
<blockquote>
<ol start="5">
<li>Complement (보수)
a + a&#39; = 1
a&#39; + a = 1
a · a&#39; = 0
a&#39; · a = 0</li>
</ol>
</blockquote>
<blockquote>
<ol start="6">
<li>Idempotency (등멱 법칙)
a + a = a
a · a = a</li>
</ol>
</blockquote>
<blockquote>
<ol start="7">
<li>Involution (퇴화 법칙)
(a&#39;)&#39; = a</li>
</ol>
</blockquote>
<blockquote>
<ol start="8">
<li>Distributive (분배 법칙)
a(b + c) = ab + ac
a + bc = (a + b)(a + c)</li>
</ol>
</blockquote>
<blockquote>
<ol start="9">
<li>Adjacency (통합)
ab + ab&#39; = a
(a + b)(a + b&#39;) = a
a&#39;b&#39; + ab&#39; + a&#39;b + ab = 1
(a&#39; + b&#39;)(a&#39; + b)(a + b&#39;)(a + b) = 0</li>
</ol>
</blockquote>
<blockquote>
<ol start="10">
<li>Simplification (간소화)
a + a&#39;b = a + b
a(a&#39; + b) = ab</li>
</ol>
</blockquote>
<blockquote>
<ol start="11">
<li>DeMorgan (드 모르간의 법칙)
(a + b)&#39; = a&#39;b&#39;
(ab)&#39; = a&#39; + b&#39;</li>
</ol>
</blockquote>
<blockquote>
<ol start="12">
<li>Absorption (흡수 법칙)
a + ab = a
a(a + b) = a</li>
</ol>
</blockquote>
<p>증명) 
a + ab = a · 1 + ab = a(1 + b) = a · 1 = a
a(a + b) = a + ab = a</p>
<blockquote>
<ol start="13">
<li>Consensus (컨센서스 법칙)
at<sub>1</sub> + a&#39;t<sub>2</sub> + t<sub>1</sub>t<sub>2</sub> = at<sub>1</sub> + a&#39;t<sub>2</sub>
(a + t<sub>1</sub>)(a&#39; + t<sub>2</sub>)(t<sub>1</sub> + t<sub>2</sub>) = (a + t<sub>1</sub>)(a&#39; + t<sub>2</sub>)</li>
</ol>
</blockquote>
<p>증명)<br>at₁ + a’t₂ + t₁t₂ =
= at₁ + a’t₂ + 1 · t₁t₂   (identity)
= at₁ + a’t₂ + (a+a’)t₁t₂   (complement)
= at₁ + a’t₂ + at₁t₂ + a’t₁t₂ (distributive)
= at₁ (1+t₂) + a’t₂ (1+t₁) (distribute)
= at₁ · 1 + a’t₂ · 1  (null)
= at₁ + a’t₂</p>
<blockquote>
<ol start="14">
<li>ab + a&#39;c = (a + c)(a&#39; + b)</li>
</ol>
</blockquote>
<p>증명)
ab + a&#39;c
= (ab + a&#39;)(ab + c) (distribute)
= (a + a&#39;)(a&#39; + b)(a + c)(b + c) (distribute)
= 1(a&#39; + b)(a + c)(b + c) (complement)
= (a + c)(a&#39; + b) (consensus)</p>
<h3 id="--표현의-단순화">- 표현의 단순화</h3>
<p>논리 함수는 최대한 단순하게 표현한다.</p>
<p>AB + A&#39;CD + A&#39;BD + A&#39;CD&#39;  + ABCD
= AB + AB(CD) + A&#39;C(D+D&#39;) + A&#39;BD (교환 법칙, 분배 법칙)
= AB + A&#39;C + A&#39;BD (흡수 법칙, 보수 법칙)
= B(A + A&#39;D) + A&#39;C (분배 법칙)
= B(A + D) + A&#39;C (간소화)</p>
<h3 id="--드-모르간-법칙을-통한-보수화">- 드 모르간 법칙을 통한 보수화</h3>
<p>F = wx&#39;y + xy&#39; + wxz
F&#39; = (w&#39;+x+y&#39;)(x&#39;+y)(w&#39;+x&#39;+z&#39;)</p>
<hr>
<h1 id="24-canomical-forms--표준-형식">2.4 Canomical Forms  표준 형식</h1>
<h2 id="--minterm">- Minterm</h2>
<ul>
<li>x,y,z에 대한 minterms
곱으로 나타낸 모든 항</li>
</ul>
<table>
<thead>
<tr>
<th align="center">x y z</th>
<th align="center">Minterms</th>
<th align="center">Notation</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0 0 0</td>
<td align="center">x&#39;y&#39;z&#39;</td>
<td align="center">m<sub>0</sub></td>
</tr>
<tr>
<td align="center">0 0 1</td>
<td align="center">x&#39;y&#39;z</td>
<td align="center">m<sub>1</sub></td>
</tr>
<tr>
<td align="center">0 1 0</td>
<td align="center">x&#39;yz&#39;</td>
<td align="center">m<sub>2</sub></td>
</tr>
<tr>
<td align="center">0 1 1</td>
<td align="center">x&#39;yz</td>
<td align="center">m<sub>3</sub></td>
</tr>
<tr>
<td align="center">1 0 0</td>
<td align="center">xy&#39;z&#39;</td>
<td align="center">m<sub>4</sub></td>
</tr>
<tr>
<td align="center">1 0 1</td>
<td align="center">xy&#39;z</td>
<td align="center">m<sub>5</sub></td>
</tr>
<tr>
<td align="center">1 1 0</td>
<td align="center">xyz&#39;</td>
<td align="center">m<sub>6</sub></td>
</tr>
<tr>
<td align="center">1 1 1</td>
<td align="center">xyz</td>
<td align="center">m<sub>7</sub></td>
</tr>
</tbody></table>
<p>F<sub>1</sub> = m<sub>3</sub> + m<sub>5</sub> + m<sub>6</sub> + m<sub>7</sub> = x&#39;yz + xy&#39;z + xyz&#39; + xyz
→ 1-minterms 
F&#39;<sub>1</sub> = m<sub>0</sub> + m<sub>1</sub> + m<sub>2</sub> + m<sub>4</sub> = x&#39;y&#39;z&#39; + x&#39;y&#39;z + x&#39;yz&#39; + xy&#39;z&#39;
→ 0-minterms </p>
<p>어떤 Boolean 함수라도 1-minterms의 합으로 표현할 수 있다. </p>
<p>ex) 
F<sub>1</sub> = ∑(3,5,6,7)
F&#39;<sub>1</sub> = ∑(0,1,2,4)</p>
<p>ex) F = x + yz
= x(y+y&#39;)(z+z&#39;)+(x+x&#39;)yz
=xyz+xyz&#39;+xy&#39;z+xy&#39;z&#39;+xyz+x&#39;yz
=xyz+x&#39;yz+xyz&#39;+xy&#39;z+xy&#39;z&#39;
=m<sub>7</sub> + m<sub>3</sub> + m<sub>6</sub> + m<sub>5</sub> + m<sub>4</sub>
= ∑(3,4,5,6,7)</p>
<h2 id="--maxterm">- Maxterm</h2>
<ul>
<li>x,y,z에 대한 maxterms
합으로 나타낸 모든 항</li>
</ul>
<table>
<thead>
<tr>
<th align="center">x y z</th>
<th align="center">Maxterms</th>
<th align="center">Notation</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0 0 0</td>
<td align="center">x+y+z</td>
<td align="center">M<sub>0</sub></td>
</tr>
<tr>
<td align="center">0 0 1</td>
<td align="center">x+y+z&#39;</td>
<td align="center">M<sub>1</sub></td>
</tr>
<tr>
<td align="center">0 1 0</td>
<td align="center">x+y&#39;+z</td>
<td align="center">M<sub>2</sub></td>
</tr>
<tr>
<td align="center">0 1 1</td>
<td align="center">x+y&#39;+z&#39;</td>
<td align="center">M<sub>3</sub></td>
</tr>
<tr>
<td align="center">1 0 0</td>
<td align="center">x&#39;+y+z</td>
<td align="center">M<sub>4</sub></td>
</tr>
<tr>
<td align="center">1 0 1</td>
<td align="center">x&#39;+y+z&#39;</td>
<td align="center">M<sub>5</sub></td>
</tr>
<tr>
<td align="center">1 1 0</td>
<td align="center">x&#39;+y&#39;+z</td>
<td align="center">M<sub>6</sub></td>
</tr>
<tr>
<td align="center">1 1 1</td>
<td align="center">x&#39;+y&#39;+z&#39;</td>
<td align="center">M<sub>7</sub></td>
</tr>
</tbody></table>
<p>ex) F<sub>1</sub>(x,y,z) = x&#39;yz+xy&#39;z+xyz&#39;+xyz
(F<sub>1</sub>)&#39; = (x+y&#39;+z&#39;)(x&#39;+y+z&#39;)(x&#39;+y&#39;+z)(x&#39;+y&#39;+z&#39;)
= M<sub>3</sub>M<sub>5</sub>M<sub>6</sub>M<sub>7</sub>
= ∏(3,5,6,7)</p>
<p>F<sub>1</sub> = M<sub>0</sub>M<sub>1</sub>M<sub>2</sub>M<sub>4</sub></p>
<p>ex) F = x&#39;y&#39;+xz
=(x&#39;y&#39;+x)(x&#39;y&#39;+z)
=(x+x&#39;)(x+y&#39;)(x&#39;+z)(y&#39;+z)
=(x+y&#39;)(x&#39;+z)(y&#39;+z)
=(x+y&#39;+z)(x+y&#39;+z&#39;)(x&#39;+y+z)(x&#39;+y&#39;+z)(x+y&#39;+z)(x&#39;+y&#39;+z)
=(x+y&#39;+z)(x+y&#39;+z&#39;)(x&#39;+y+z)(x&#39;+y&#39;+z)
=M<sub>2</sub>M<sub>3</sub>M<sub>4</sub>M<sub>6</sub>
=∏(2,3,4,6)</p>
<ul>
<li>Mintern 과 Maxterm은 서로 보수이다.
f = m<sub>0</sub>+m<sub>1</sub>+m<sub>5</sub>+m<sub>7</sub> = M<sub>2</sub>M<sub>3</sub>M<sub>4</sub>M<sub>6</sub></li>
</ul>
<blockquote>
<p>곱의 합 수식 sum of products(SOP) : 한 개 이상의 곱항들이 OR 연산자로 연결된 것.</p>
</blockquote>
<blockquote>
<p>합의 곱 수식 product of sums(POS) : 한 개 이상의 합항들이 AND 연산자로 연결된 것</p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[[디지털 회로 개론] 01. Digital Systems and Number Systems]]></title>
            <link>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-01.-Digital-Systems-and-Number-Systems</link>
            <guid>https://velog.io/@yeonbo_ra/%EB%94%94%EC%A7%80%ED%84%B8-%ED%9A%8C%EB%A1%9C-%EA%B0%9C%EB%A1%A0-01.-Digital-Systems-and-Number-Systems</guid>
            <pubDate>Mon, 30 Sep 2024 11:11:27 GMT</pubDate>
            <description><![CDATA[<h1 id="11-논리-설계">1.1 논리 설계</h1>
<blockquote>
<p>디지털 시스템(Digital systems) : 임의 개수의 입력과 임의 개수의 출력이 있는 시스템. 데이터 입력 외에 클럭이라 불리는 타이밍 신호가 있는 경우도 있다.</p>
</blockquote>
<h3 id="디지털-시스템의-종류">디지털 시스템의 종류</h3>
<ol>
<li>조합 시스템(Combinational Logic System) : 시스템 state 가 필요 없다. 
→  <code>Output = Function(Input)</code></li>
<li>순차 시스템(Sequential System) : 시스템 state가 필요한 시스템, 기억 장치(메모리)가 있는 시스템
 a) Synchronous Sequential System : state가 이산적으로 업데이트 되는 시스템.
 b) Asynchronous Sequential System : state가 연속적으로 업데이트 되는 시스템. 
→  <code>State = Function(State, Input)</code>
→  <code>Output = Function(State) || Function(State, Input)</code></li>
</ol>
<h3 id="디지털-시스템의-예시">디지털 시스템의 예시</h3>
<ol>
<li><p>Digital Counter
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/a0896d0d-5a96-4e6a-8869-f433be5cd079/image.png" alt="Digital Counter">
Input : Count Up, Reset
Output : Visual Display
State : &quot;Value&quot; of stored digits
→ Asynchronous Sequential System (클락이 없기 때문에)</p>
</li>
<li><p>Digital Computer
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/fbbd5b7c-097b-4165-922e-6afeb1ee9a83/image.png" alt="">
→ Synchronous Sequential System (CPU라는 클락이 있기 때문에)</p>
</li>
<li><p>Embedded Systems
내장형 컴퓨터. 자동차, 스피커, 스마트폰, PC, TV 등등</p>
</li>
</ol>
<hr>
<h1 id="12-진법에-대한-복습">1.2 진법에 대한 복습</h1>
<h2 id="121-binary-value">1.2.1 Binary Value</h2>
<p>디지털 시스템에선 정보를 전달하는 방법을 Binary Value 사용
연속적인 값 → 0 or 1</p>
<table>
<thead>
<tr>
<th align="center">0</th>
<th align="center">1</th>
</tr>
</thead>
<tbody><tr>
<td align="center">False</td>
<td align="center">True</td>
</tr>
<tr>
<td align="center">Low</td>
<td align="center">High</td>
</tr>
<tr>
<td align="center">Off</td>
<td align="center">On</td>
</tr>
</tbody></table>
<ul>
<li>Digital : 이산적인 값, 정수 값을 가짐</li>
<li>Analog : 실수 값을 가짐, continuous in value &amp; time
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/ef6eaf28-0c2f-4eab-a7ed-6ebe130d4d51/image.png" alt="Signal Example">
Time : 주기적으로 발생하는 event, clock
Asynchronous : clock과 비동기화, 시간 연속적, 값 불연속적
Synchronous : clock과 동기화, 시간&amp;값에서 불연속적</li>
</ul>
<h2 id="122-number-system">1.2.2 Number System</h2>
<p>$$
N = a_{n-1}r^{n-1}+a_{n-2}r^{n-2}+···+a_2r^2+a_1r+a_0$$
n  : number of digits
r : radix or base(밑)
a<sub>i</sub> : coefficients(계수) (0 ≤ a<sub>i</sub> &lt; r)</p>
<p>ex) 
$7642_{10}=7×10^3+6×10^2+4×10^1+2$
$101111_2=1×2^5+0×2^4+1×2^3+1×2^2+1×2^1+1\\quad \quad \quad ,,,, = 32+8+4+2+1=47_{10}$</p>
<p>10진수 : Demical number
2진수 : Binary number
8진수 : Octal number (3개씩 끊기)
16진수 : Hexademical number (0<del>9, A</del>F / 4개씩 끊기)</p>
<h2 id="123-정수의-음수--양수-표현법">1.2.3 정수의 음수 / 양수 표현법</h2>
<h3 id="signed-magnitude-representation--부호-값-표현">Signed-Magnitude Representation : 부호-값 표현</h3>
<p>→ 잘 사용되지 않는다</p>
<blockquote>
<p>MSB : Most Significant Bit, 가장 중요한 비트, 부호를 표현 </p>
</blockquote>
<p>MSB 부호를 사용해 표현.
Range : 0을 기준으로 대칭 </p>
<blockquote>
<p>$-(2^{n-1}-1)$ ~ $(2^{n-1}-1)$</p>
</blockquote>
<p>→ 0 표현 방법이 2개 : +0, -0</p>
<h3 id="2-complement--2의-보수-방법">2&#39; Complement : 2의 보수 방법</h3>
<p>→ 주로 이 방법을 사용한다</p>
<ol>
<li>음수일 때, 2진수로 변환</li>
<li>보수를 취함 (0 → 1 / 1 → 0)</li>
<li>1을 더함 (비트 한계를 넘어가는 값은 무시)
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/c2d7545d-691f-4a52-8c7f-49c1cc65493d/image.png" alt="2의 보수 방법의 예시">
Range : 음수가 1개 더 많음. 0이 1개이다.<blockquote>
<p>$-(2^{n-1})$ ~ $(2^{n-1}-1)$</p>
</blockquote>
</li>
</ol>
<table>
<thead>
<tr>
<th align="center">Binary</th>
<th align="center">Positive</th>
<th align="center">Signed</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0000</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">0001</td>
<td align="center">1</td>
<td align="center">+1</td>
</tr>
<tr>
<td align="center">0010</td>
<td align="center">2</td>
<td align="center">+2</td>
</tr>
<tr>
<td align="center">0011</td>
<td align="center">3</td>
<td align="center">+3</td>
</tr>
<tr>
<td align="center">0100</td>
<td align="center">4</td>
<td align="center">+4</td>
</tr>
<tr>
<td align="center">0101</td>
<td align="center">5</td>
<td align="center">+5</td>
</tr>
<tr>
<td align="center">0110</td>
<td align="center">6</td>
<td align="center">+6</td>
</tr>
<tr>
<td align="center">0111</td>
<td align="center">7</td>
<td align="center">+7</td>
</tr>
<tr>
<td align="center">1000</td>
<td align="center">8</td>
<td align="center">-8</td>
</tr>
<tr>
<td align="center">1001</td>
<td align="center">9</td>
<td align="center">-7</td>
</tr>
<tr>
<td align="center">1010</td>
<td align="center">10</td>
<td align="center">-6</td>
</tr>
<tr>
<td align="center">1011</td>
<td align="center">11</td>
<td align="center">-5</td>
</tr>
<tr>
<td align="center">1100</td>
<td align="center">12</td>
<td align="center">-4</td>
</tr>
<tr>
<td align="center">1101</td>
<td align="center">13</td>
<td align="center">-3</td>
</tr>
<tr>
<td align="center">1110</td>
<td align="center">14</td>
<td align="center">-2</td>
</tr>
<tr>
<td align="center">1111</td>
<td align="center">15</td>
<td align="center">-1</td>
</tr>
</tbody></table>
<h2 id="124-이진수의-덧셈과-뺄셈">1.2.4 이진수의 덧셈과 뺄셈</h2>
<h3 id="--덧셈">- 덧셈</h3>
<p>각 자리 끼리 더함. 다음 비트에 대한 캐리까지 더한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/c181b140-0195-42a2-b686-dfcde8e73383/image.png" alt="이진수의 덧셈의 예시"></p>
<blockquote>
<p>오버플로우(Overflow) : 산술 연산의 결과가 정해진 범위를 벗어날 때</p>
<blockquote>
<p>덧셈에서 서로 같은 부호를 더했는데 반대 부호가 나올 떄.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/93f92d22-2dbd-4032-b7b4-2de225615632/image.png" alt="오버플로우의 예시"></p>
</blockquote>
</blockquote>
<h3 id="--뺄셈">- 뺄셈</h3>
<p>두 번째 피연산자에 대해 2의 보수를 취하고 두 수를 더하는 방식을 사용한다.
a-b는 a + (-b) 와 같이 계산된다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/7ade7dab-746d-4958-82e7-f12f24529226/image.png" alt="이진수의 뺄셈의 예시">
연산 과정중 오버플로우는 괜찮다.</p>
<hr>
<h1 id="13-bcd-코드">1.3 BCD 코드</h1>
<blockquote>
<p>BCD(Binary Coded Decimal) : 이진코드 십진수</p>
</blockquote>
<p>10진수를 표현하는 여러가지 방법들</p>
<table>
<thead>
<tr>
<th align="center">Decimal digit</th>
<th align="center">8421 code</th>
<th align="center">5421 code</th>
<th align="center">2421 code</th>
<th align="center">Excess 3 code</th>
<th align="center">8,4,-2,-1 code</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0000</td>
<td align="center">0000</td>
<td align="center">0000</td>
<td align="center">0011</td>
<td align="center">0000</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0001</td>
<td align="center">0001</td>
<td align="center">0001</td>
<td align="center">0100</td>
<td align="center">0111</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">0010</td>
<td align="center">0010</td>
<td align="center">0010</td>
<td align="center">0101</td>
<td align="center">0110</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">0011</td>
<td align="center">0011</td>
<td align="center">0011</td>
<td align="center">0110</td>
<td align="center">0101</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">0100</td>
<td align="center">0100</td>
<td align="center">0100</td>
<td align="center">0111</td>
<td align="center">0100</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">0101</td>
<td align="center">1000</td>
<td align="center">1011</td>
<td align="center">1000</td>
<td align="center">1011</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">0110</td>
<td align="center">1001</td>
<td align="center">1100</td>
<td align="center">1001</td>
<td align="center">1010</td>
</tr>
<tr>
<td align="center">7</td>
<td align="center">0111</td>
<td align="center">1010</td>
<td align="center">1101</td>
<td align="center">1010</td>
<td align="center">1001</td>
</tr>
<tr>
<td align="center">8</td>
<td align="center">1000</td>
<td align="center">1011</td>
<td align="center">1110</td>
<td align="center">1011</td>
<td align="center">1000</td>
</tr>
<tr>
<td align="center">9</td>
<td align="center">1001</td>
<td align="center">1100</td>
<td align="center">1111</td>
<td align="center">1100</td>
<td align="center">1111</td>
</tr>
</tbody></table>
<ol>
<li>8421 code : 일반적인 이진법 코드</li>
<li>5421 code : 첫 번째 비트가 5를 의미</li>
<li>2421 code : 첫 번째 비트가 2를 의미</li>
<li>Excess 3 code : 3를 더한 값을 표시 (0<del>4, 5</del>9 보수 관계)</li>
<li>2 of 5 code : 5개 비트 중 2개만 사용 → 에러 찾기 용이</li>
<li>8,4,-2,-1 code : 각 비트가 8,4,-2,-1을 의미 (0<del>4, 5</del>9 보수 관계)</li>
</ol>
<p>BCD 코드에서 덧셈의 오류 → 6을 더한다 
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/f07d399c-0d04-4e54-8558-3994a79d4453/image.png" alt=""></p>
<ul>
<li>용어 정리<blockquote>
<p>binary number ↔ decimal number : conversion
decimal number ↔ BINARY CODE : coding</p>
</blockquote>
</li>
</ul>
<p><img src="https://velog.velcdn.com/images/yeonbo_ra/post/22644c06-337f-4087-9607-f1ff6ee0928d/image.png" alt=""></p>
<h1 id="14-기타-코드들">1.4 기타 코드들</h1>
<h3 id="1-gray-code">1. Gray Code</h3>
<ul>
<li>일종의 채널 코딩. 숫자간 한 비트씩 차이남</li>
</ul>
<table>
<thead>
<tr>
<th align="center">Number</th>
<th align="center">Gray code</th>
<th align="center">Number</th>
<th align="center">Gray code</th>
</tr>
</thead>
<tbody><tr>
<td align="center">0</td>
<td align="center">0000</td>
<td align="center">8</td>
<td align="center">1100</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">0001</td>
<td align="center">9</td>
<td align="center">1101</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">0011</td>
<td align="center">10</td>
<td align="center">1111</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">0010</td>
<td align="center">11</td>
<td align="center">1110</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">0110</td>
<td align="center">12</td>
<td align="center">1010</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">0111</td>
<td align="center">13</td>
<td align="center">1011</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">0101</td>
<td align="center">14</td>
<td align="center">1001</td>
</tr>
<tr>
<td align="center">7</td>
<td align="center">0100</td>
<td align="center">15</td>
<td align="center">1000</td>
</tr>
</tbody></table>
<h3 id="2-hamming-code">2. Hamming Code</h3>
<ul>
<li>Hamming 이 제작한 코드</li>
<li>Single error correction code : error를 찾고 수정까지 할 수 있음</li>
<li>4개의 data bits, 3개의 check bits(a<sub>1</sub>, a<sub>2</sub>, a<sub>4</sub>)</li>
</ul>
<blockquote>
<p>Check bits
a<sub>1</sub> = a<sub>3</sub> ⊕ a<sub>5</sub> ⊕ a<sub>7</sub>
a<sub>2</sub> = a<sub>3</sub> ⊕ a<sub>6</sub> ⊕ a<sub>7</sub>
a<sub>4</sub> = a<sub>5</sub> ⊕ a<sub>6</sub> ⊕ a<sub>7</sub></p>
</blockquote>
<blockquote>
<p>Error Detecting bits
e<sub>1</sub> = a<sub>1</sub> ⊕ a<sub>3</sub> ⊕ a<sub>5</sub> ⊕ a<sub>7</sub>
e<sub>2</sub> = a<sub>2</sub> ⊕ a<sub>3</sub> ⊕ a<sub>6</sub> ⊕ a<sub>7</sub>
e<sub>4</sub> = a<sub>4</sub> ⊕ a<sub>5</sub> ⊕ a<sub>6</sub> ⊕ a<sub>7</sub></p>
</blockquote>
<p>e는 모두 0이 나와야 한다. (자기 자신과 자기 자신의 XOR이기 때문)
→ 1이 나오면 오류</p>
<blockquote>
<p>오류인 bit : 4e<sub>4</sub> + 2e<sub>2</sub> + e<sub>1</sub></p>
</blockquote>
<p>n의 check bit가 있다면, 2<sup>n</sup>-n-1개의 information bit가 있을 수 있다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[이산구조] 01. Propositional Logic]]></title>
            <link>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-01.-Propositional-Logic</link>
            <guid>https://velog.io/@yeonbo_ra/%EC%9D%B4%EC%82%B0%EA%B5%AC%EC%A1%B0-01.-Propositional-Logic</guid>
            <pubDate>Thu, 26 Sep 2024 13:18:37 GMT</pubDate>
            <description><![CDATA[<h1 id="module-1-foundation-of-logic">Module #1: Foundation of Logic</h1>
<h2 id="서론">서론</h2>
<blockquote>
<p>이산구조란 무엇인가? 사실은 이산수학에 대한 내용이 대부분이다.
Discrete 한 value들에 대한 연산, 구조, 내용들을 다룬다.</p>
</blockquote>
<h2 id="1-basic-definition">1. Basic Definition</h2>
<blockquote>
<p>명제(Proposition) : 참 또는 거짓 중 하나를 나타내는, 선언적 문장</p>
</blockquote>
<p>의문문, 명령문, 감탄문 등은 참/거짓 판정이 불가하기에 명제가 아니다.
x + 1 = 2 와 같은 명제는 값이 배정되지 않은 변수(x)가 존재하므로 명제가 아니다.</p>
<blockquote>
<p>연산자(Operator) : 한 개 이상의 명제를 조합해주는 것</p>
<blockquote>
<p>단일연산자(Unary) : 1개의 명제를 가짐
이항연산자(Binary) : 2개의 명제를 연결함(접속사)</p>
</blockquote>
</blockquote>
<h3 id="논리-연산자">논리 연산자</h3>
<p><strong>부정</strong> : p가 명제가 하면 p의 부정(negation)은 <code>~p</code>로 표기된다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/5fa14fd5-65c9-4396-bebf-d89e33a0ccd2/image.png" alt="부정의 진리표"></p>
<p><strong>논리곱</strong> : p, q가 명제면 p와 q의 논리곱(conjunction)은 <code>p ∧ q</code>로 표기된다. 이는 &#39;p and q&#39;를 의미한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/2ab56e45-4214-4183-9cc4-1f136e366402/image.png" alt="논리곱의 진리표"></p>
<p><strong>논리합</strong> : p, q가 명제면 논리합(disjuction)은 <code>p ∨ q</code>로 표기된다. 이는 &#39;p or q&#39;를 의미한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/c4f5fe9d-2a37-4766-91c4-65368858f7f2/image.png" alt="논리합의 진리표"></p>
<p>영어에서 or은 포괄적 논리합 / 베타적 논리합의 의미로 사용될 수 있다. 논리합 ∨은 포괄적 논리합에 대응한다.</p>
<h3 id="여러-연산자가-같이-사용될-때">여러 연산자가 같이 사용될 때</h3>
<p>부정(~) 기호가 가장 높은 우선순위를 지닌다.
∧과 ∨이 동시에 사영될을 때는 ∧이 더 높은 우선순위를 지닌다. 
그렇지만 괄호를 잘 사용해 헷갈릴 일이 없도록 하자.
<br>
<strong>베타적 논리합</strong> : 베타적 논리합 : p, q가 명제면 p와 q의 베타적 논리합(disjunction)은 <code>p ⊕ q</code>로 표기된다. 이는 ‘p exclusive-or q’를 의미한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/ac9f15d5-c8a1-485e-8de7-aa726ccd276e/image.png" alt="베타적 논리합의 진리표">
<strong>조건문(함축)</strong> : p, q가 명제면 p와 q의 조건문(implication)은 <code>p → q</code>로 표기된다. 이는 ‘if p, then  q’를 의미한다. 이때 p를 가정, q를 결론이라고 한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/608e92cf-7485-4d8b-8fef-c4bb4b50fef8/image.png" alt="조건문의 진리표"></p>
<blockquote>
<p>가정이 거짓이면 항상 참임을 유의하자.</p>
</blockquote>
<ul>
<li>p→q 의 영어 표현들<ul>
<li>if p, q / q if p / if p, then q</li>
<li>p only if q / q provided that p</li>
<li>p is sufficient for q / q is necessary for p</li>
<li>p implies q / q is implied by p</li>
<li>when p, q / q when p / whenever p, q</li>
</ul>
</li>
</ul>
<p>조건문 p → q에 대해
<strong>역(converse)</strong> : q → p
<strong>이(inverse)</strong> : ~p → ~q
<strong>대우(contrapositive)</strong> : ~q → ~p</p>
<blockquote>
<p>조건문 p→q가 참이라면,  대우 ~q → ~p도 항상 참이다.</p>
</blockquote>
<br>

<p><strong>상호 조건문</strong> : p, q가 명제면 p와 q의 상호 조건문(biconditional statement)은 <code>p ↔ q</code>로 표기된다. 이는 ‘p if and only if(iff) q’를 의미한다.
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/f636492a-1337-4ad6-9a8d-5c384e0660a5/image.png" alt="상호 조건문의 진리표"></p>
<h3 id="비트bit와-비트-연산자">비트(bit)와 비트 연산자</h3>
<p><strong>비트(bit)</strong> : binary digit. 0 또는 1로 구성된 이진수</p>
<ul>
<li>0은 <code>거짓</code>, 1은 <code>참</code>을 의미한다.</li>
<li>+은 &#39;or&#39;을 의미하고, · 은 &#39;and&#39;를 의미한다
<img src="https://velog.velcdn.com/images/yeonbo_ra/post/e20ed3aa-81df-4c7d-8171-40a05c82cf14/image.png" alt="비트 연산자 진리표"></li>
</ul>
<p><strong>비트 문자열</strong> : 0개 이상의 비트를 갖는 비트열</p>
<hr>
<h2 id="2-propositional-equivalence">2. Propositional Equivalence</h2>
<p><strong>동치(equivalent)</strong> : 두 개의 복합명제가 <code>항상 같은 진리값</code>을 가질 경우 <br></p>
<p><strong>항진명제(tautology)</strong> : 복합명제를 구성하고 있는 명제 변수가 어떠한 진리값을 갖는다 하여도 전체 복합 명제의 값이 <code>항상 참</code>일 때 <br></p>
<p><strong>모순(contradiction)</strong> : 복합명제를 구성하고 있는 명제 변수가 어떠한 진리값을 갖는다 하여도 전체 복합 명제의 값이 <code>항상 거짓</code>일 때<br></p>
<h3 id="equivalence-laws-동치-규칙들">Equivalence Laws 동치 규칙들</h3>
<blockquote>
<p><strong>항등 법칙 Identity</strong> : p ∧ <strong>T</strong> ≡ p / p ∨ <strong>F</strong> ≡ p</p>
</blockquote>
<blockquote>
<p><strong>지배 법칙 Domination</strong> : p ∨ <strong>T</strong> ≡ <strong>T</strong> / p ∧ <strong>F</strong> ≡ <strong>F</strong></p>
</blockquote>
<blockquote>
<p><strong>등멱 법칙 Idempotent</strong> : p ∧ p ≡ p / p ∨ p ≡ p</p>
</blockquote>
<blockquote>
<p><strong>이중 부정 법칙 Double negation</strong> : <del>(</del>p) ≡ p</p>
</blockquote>
<blockquote>
<p><strong>교환 법칙 Commutative</strong> : p ∨ q ≡ q ∨ p / p ∧ q ≡ q ∧ p</p>
</blockquote>
<blockquote>
<p><strong>결합 법칙 Associative</strong> : p ∨ (q ∨ r) ≡ (p ∨ q) ∨ r / p ∧ (q ∧ r) ≡ (p ∧ q) ∧ r</p>
</blockquote>
<blockquote>
<p><strong>분배 법칙 Distributive</strong> : p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) / p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)</p>
</blockquote>
<blockquote>
<p><strong>드 모르간의 법칙</strong> : ~(p∧q) ≡ ~p ∨ ~q / ~(p∨q) ≡ ~p ∧ ~q</p>
</blockquote>
<blockquote>
<p><strong>부정 법칙</strong> : p ∨ ~p ≡ <strong>T</strong> / p ∧ ~p ≡ <strong>F</strong></p>
</blockquote>
<blockquote>
<p><strong>흡수 법칙</strong> : p ∨ (p ∧ q) ≡ p / p ∧ (p ∨ q) ≡ p</p>
</blockquote>
<p><strong>T</strong>는 <code>항진</code> 명제, <strong>F</strong>는 <code>모순</code> 명제</p>
<h3 id="동치로-논리-연산자-정의하기">동치로 논리 연산자 정의하기</h3>
<blockquote>
<p><strong>베타적 논리합</strong> : p⊕q ≡ (p ∨ q) ∧ ~(p ∧ q)</p>
</blockquote>
<blockquote>
<p><strong>조건문</strong> : p → q ≡ ~p ∨ q / p → q ≡ p ∧ ~q </p>
</blockquote>
<blockquote>
<p><strong>상호 조건문</strong> : p ↔ q ≡ (p→q) ∧ (q→p) </p>
</blockquote>
]]></description>
        </item>
    </channel>
</rss>