Skip to content

rolroralra/algorithm_java

Repository files navigation

jungol

Reference to "http://jungol.co.kr/"

TODO

  • Topology Sort
  • Articulation Point & Edge

문제 Web Site


Sample Code for Java

package problem;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.util.StringTokenizer;

public class Solution {

    public static void main(String[] args) throws Exception {
        long START_TIMESTAMP = System.currentTimeMillis();

        System.setIn(Solution.class.getResourceAsStream("sample_input.txt"));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringBuilder sb = new StringBuilder();
        StringTokenizer st = null;
        int T = Integer.parseInt(br.readLine().trim());
        for (int test_case = 1; test_case <= T; test_case++) {
            int result = 0;

            /*****************
             * Solution Code *
             *****************/



            System.out.println("#" + test_case + " " + result);
//            sb.append("#" + test_case + " " + result + '\n');
        }


        long END_TIMESTAMP = System.currentTimeMillis();
        MemoryMXBean mxBean = ManagementFactory.getMemoryMXBean();
        System.out.println("Spend Time: " + (END_TIMESTAMP - START_TIMESTAMP) + " ms");
        System.out.println("Usage Heap Memory: " + mxBean.getHeapMemoryUsage().getUsed() / 1024  + " KB");

//        System.out.println(sb.toString());
    }
}

Graph

Graph

G = (V,E)
(G: Graph, V: set of vertices, E: set of edges)

Graph Implementation

  1. Adjacency Matrix
  2. Adjacency List
  3. Edge List

Directed

directed edge (v1, v2) != (v2, v1)
undirected edge (v1, v2) = (v2, v1)

Adjacent

v1, v2 are adjacent
iff there exists an edge e such that e = (v1, v2)

Incident

some edge e is incident on v1 and v2
iff e = (v1, v2)

Parallel

e1, e2 are called parallel
iff e1 = (v1, v2), e2 = (v1, v2)

Loop (Self Loop)

Loop is an edge incident on a single vertex.
(loop = (v1, v1))

Isolated vertex

v is isaolated vertex in Graph G(V,E)
iff there are not exists any edges e such that are incident on v.

Simple Graph

A graph with neither loop nor parallel edges is called simple.

Weighted Graph

Weighted Graph is a graph with numbers(weight) on the edges.

Complete Graph with n vertices (Kn)

The complete graph (V,E) in n vertices is the simple graph with n vertices
satisfying that there exists some edge e in E
(e = (v, w) for any v,w in V)

Bipartite Graph (이분화 그래프)

Complete Bipartite Graph (Kn,m)

Path

A path from v0 to vn of length n
(v0, e1, v1, e2, v2, ..., en-1, vn)

Alternating sequence of V, E

Connected Graph

A graph G = (V, E) is connected
iff for any two vertex v, w, there exists some path from v to w.

SubGraph

G = (V, E)
G' = (V', E')
V' is subset of V
E' is subset of E
For any edge e in E', e = (v, w), then v, w is in V'

Simple Path

A simple path from v to w is a path with no repeated vertices.

Cycle

A cycle is a path from v to v with no repeated edge. (possible repeated vertices)

Simple Cycle

A simple cycle is a cycle from v to v with no repeated vertices except for v.

Euler Cycle

An Euler cycle is a cycle in a graph that includes all vertices and edges of G.

Degree


BFS


DFS


Backtracking


Greedy Algorithm


Divide & Conquer


Dynamic Programming (DP)

LIS (Longest Increasing Sequence)

https://dyngina.tistory.com/16

LCS (Longest Common String)

LCA (Longest Common Ancestor)


Binary Index Tree

Segment Tree

Fenwick Tree


최단 경로 구하는 알고리즘 (the shortest path problem)

  1. single source & single destination (distance)
  2. single source (distance[i] : c0 --> i) --> dijkstra algorithm, bellman ford
  3. single destination (distance[i] : i --> c0)
  4. all pairs (distnace[i][j] : i--> j) --> floyd-warshall

Dijkstra

Bellman-Ford

Floyd-Warshall

Union Find (Disjoin Set)

Topology Sort

  1. DFS로 구현 (DFS Spanning Tree)
  2. Queue with indgree 로 구현

MST 구현 (Minimal Spanning Tree)

  1. Kruskal Algorithm
  2. Prim's Algorithm

단절점, 단절선 (Articulation Point, Articulation Edge)

Line Sweeping, Plane Sweeping

https://www.acmicpc.net/problem/2170

LowerBound, UpperBound (wrt BinarySearch)


Git Proxy Setting

$ vi ~/.gitconfig
[user]
  name = rolroralra
  email = shyoung.kim@samsung.com
[http]
  proxy = http://70.10.15.10:8080
  sslVerify = false
[https]
  proxy = http://70.10.15.10:8080
[credential]
  helper = wincred
[filter "lfs"]
  clean = git-lfs clean -- %f
  smudge = git-lfs smudge -- %f
  process = git-lfs filter-process
  required = true
[core]
  autocrlf = true

About

Algorithm Problems by Java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages