GithubHelp home page GithubHelp logo

implementing-data-structure's Introduction

JavaProject

자료구조 및 알고리즘 구현

DFS

  • Graph

1 ---- 2
|\    |
| \   |
|  \  |
|   \ |
3 ---- 4

  1. 스택의 top에 있는 정점을 기준으로 간선이 연결되어있고 아직 방문하지 않은 정점을 찾는다.
  2. 조건에 맞는 정점을 찾는다면 해당 정점을 스택에 넣은 후 break를 건다.
  3. 연결된 간선이 없고, 방문하지 않은 정점을 찾지 못한다면 pop.

2번에서 break를 걸어줌으로써, 바로 DFS 탐색이 진행된다.

현재 정점을 기준으로 탐색 중 조건에 맞는 정점을 찾는다면 그 정점을 기준으로 다시 탐색을 한다.

이를 반복함으로써 위 DFS의 그림처럼 깊이 탐색을 할 수 있게 되는 것이다.

3번에서 경우는 DFS와 BFS를 비교하는 그림에서 보듯 1, 2, 3을 탐색한 후 더이상 탐색할 수 없다.

이런 경우를 다시 돌아가기 위해 pop을 하는 것이다.

implementing-data-structure's People

Contributors

donghyeon0915 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.