Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Implement of some interesting algorithms

There have four interesting algorithms including LCSS, Floyd-Warshall, Dijkstra and 8-puzzle problem by BFS.
All of them were implemented by C++.

LCSS

  • Input:
  1. number of test data
  2. first string
  3. second string
  • Output:
    length of same substring.

  • Sample input:
    3
    aabbacd
    aabacab
    mississippi
    ispim
    1123123
    111233

  • Sample output:
    5
    4
    5

Floyd-Warshall

  • Input:
  1. (int) m, n where m is total edges and n is total vertices.
  2. m numbers of weight for edges, like (a b 3) means it needs three points from a to b.
  • Output:
    two dimensional metrix which contain weight from each vertice to others vertices.
    if vertice cannot connect to one vertices, represent it "INF".

  • Sample input:
    5 9
    a b 3
    a c 8
    b d 1
    a e -4
    c b 4
    b e 7
    d c -5
    d a 2
    e d 6

  • Sample output:
    0 1 -3 2 -4
    3 0 -4 1 -1
    7 4 0 5 3
    2 -1 -5 0 -2
    8 5 1 6 0

Dijkstra

  • Input:
  1. two vertices including stant and goal.
  2. (int) m which means numbers of edge.
  3. m numbers of weight for edges, like (a b 3) means it needs three points from a to b.
  • Output:
    length from start vertice to goal vertice.

  • Sample input:
    s d
    10
    s a 6
    s c 3
    a c 4
    a b 2
    b d 1
    c a 2
    c b 3
    c d 5
    d a 1
    d b 5

  • Sample output:
    7

8-puzzle problem by BFS

  • Input:
  1. three lines of numbers(0~8) which represent the original state.
  2. three lines of numbers(0~8) which represent the goal state.
  • Output:
    the procedure of searching goal by BFS.

  • Sample output:
    1 2 3
    7 8 4
    0 6 5
    1 2 3
    8 0 4
    7 6 5

  • Sample output:
    1 2 3
    7 8 4
    0 6 5
    1 2 3
    0 8 4
    7 6 5
    1 2 3
    7 8 4
    6 0 5
    0 2 3
    1 8 4
    7 6 5
    1 2 3
    8 0 4
    7 6 5

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages