This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| algorithm:algorithm [2022/10/24 15:32] – ledyx | algorithm:algorithm [2022/10/24 15:32] (current) – ledyx | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| [[binary search|참조]] | [[binary search|참조]] | ||
| - | |||
| - | = Dynamic Programming = | ||
| - | <sxh java> | ||
| - | private TreeSet< | ||
| - | if (!srcDir.isFile() && srcDir.listFiles() == null) | ||
| - | throw new FileNotFoundException(" | ||
| - | |||
| - | // 파일 이름순 정렬 | ||
| - | TreeSet< | ||
| - | public int compare(File o1, File o2) { | ||
| - | return o1.getPath().compareToIgnoreCase(o2.getPath()); | ||
| - | } | ||
| - | }); | ||
| - | |||
| - | Stack< | ||
| - | directories.push(srcDir); | ||
| - | |||
| - | // DFS | ||
| - | while(!directories.isEmpty()) { | ||
| - | File directory = directories.pop(); | ||
| - | |||
| - | for(File composite : directory.listFiles()) { | ||
| - | if(composite.isDirectory()) { | ||
| - | directories.push(composite); | ||
| - | } | ||
| - | else if(composite.isFile()) { | ||
| - | files.add(composite); | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | |||
| - | return files; | ||
| - | } | ||
| - | </ | ||