• 티스토리 홈
  • 프로필사진
    alpha brain
  • 방명록
  • 공지사항
  • 태그
  • 블로그 관리
  • 글 작성
alpha brain
  • 프로필사진
    alpha brain
    • 분류 전체보기 (93)
      • SOFTWARE DEVELOP (68)
        • REACT.JS (3)
        • WEBPACK (4)
        • HTML&CSS (2)
        • EXPRESS (0)
        • DATABASE (0)
        • NODE.JS (3)
        • JAVASCRIPT (24)
        • DOCKER (1)
        • Linux (3)
        • Git (6)
        • GRAPHQL (0)
        • Datastructure (7)
        • Development (6)
        • HTTP (1)
        • Programming Paradigm (1)
        • Algorithm log (5)
        • DEV log (1)
        • Project log (0)
        • I don't know yet (1)
      • 경제, 재무 (23)
      • 여행 (0)
      • 시사, 상식 (2)
  • 반응형
    250x250
  • 방문자 수
    • 전체:
    • 오늘:
    • 어제:
  • 최근 댓글
      등록된 댓글이 없습니다.
    • 최근 공지
        등록된 공지가 없습니다.
      # Home
      # 공지사항
      #
      # 태그
      # 검색결과
      # 방명록
      • [Datastructure] Tree / Binary Tree
        2020년 02월 10일
        • alpha brain
        • 작성자
        • 2020.02.10.:59
        728x90
        반응형

        Tree

        tree는 계층적인 트리 구조로, root value와 subtree(부모 노드와 자식을 가지는)를 가진다.

        Binary Tree

        A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.

        부모 노드가 자식노드 2개를 가진 자료구조를 Binary Tree(이진트리) 라고 한다. 엘리먼트들은 자식노드를 2개만 가져야 하며 보통 letf child와 right child로 불린다.

        Main applications of trees include:
        1. Manipulate hierarchical data.
        2. Make information easy to search (see tree traversal).
        3. Manipulate sorted lists of data.
        4. As a workflow for compositing digital images for visual effects.
        5. Router algorithms
        6. Form of a multi-stage decision-making (see business chess).

         

        Tree Traversals (Inorder, Preorder and Postorder)

        트리의 순회는 선형적인 자료구조(array, linked list, queue, stack) 과는 다르게 순회를 하게 된다.

        부모 노드와 자식노드를 하나의 depth로 한다면, 

        깊이 우선 탐색(dfs)은 3가지로 나눌수 있다.

        • (a) Inorder (Left, Root, Right) : 4 2 5 1 3
        • (b) Preorder (Root, Left, Right) : 1 2 4 5 3
        • (c) Postorder (Left, Right, Root) : 4 5 2 3 1

        순회 알고리즘을보면,

        Algorithm Inorder(tree)
           1. Traverse the left subtree, i.e., call Inorder(left-subtree)
           2. Visit the root.
           3. Traverse the right subtree, i.e., call Inorder(right-subtree)
        Algorithm Preorder(tree)
           1. Visit the root.
           2. Traverse the left subtree, i.e., call Preorder(left-subtree)
           3. Traverse the right subtree, i.e., call Preorder(right-subtree) 
        Algorithm Postorder(tree)
           1. Traverse the left subtree, i.e., call Postorder(left-subtree)
           2. Traverse the right subtree, i.e., call Postorder(right-subtree)
           3. Visit the root.

        순서의 차이만 가지고 있고 3가지 모두 재귀적인 방법을써서 순회를 하고 있다.

         

        728x90
        반응형

        'SOFTWARE DEVELOP > Datastructure' 카테고리의 다른 글

        [Datastructure] Time Complxity with Data Structure  (0) 2020.02.11
        [Datastructrue] Time Complexity  (0) 2020.02.11
        [Datastructure] Graph  (0) 2020.02.10
        [Datastructure]Hash Table  (0) 2020.02.07
        [Datastructure]Linked List  (0) 2020.02.07
        다음글
        다음 글이 없습니다.
        이전글
        이전 글이 없습니다.
        댓글
      조회된 결과가 없습니다.
      스킨 업데이트 안내
      현재 이용하고 계신 스킨의 버전보다 더 높은 최신 버전이 감지 되었습니다. 최신버전 스킨 파일을 다운로드 받을 수 있는 페이지로 이동하시겠습니까?
      ("아니오" 를 선택할 시 30일 동안 최신 버전이 감지되어도 모달 창이 표시되지 않습니다.)
      목차
      표시할 목차가 없습니다.
        • 안녕하세요
        • 감사해요
        • 잘있어요

        티스토리툴바