forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request onlyliuxin#81 from onlyliuxin/master
update-2017-04-24
- Loading branch information
Showing
52 changed files
with
1,645 additions
and
124 deletions.
There are no files selected for viewing
30 changes: 29 additions & 1 deletion
30
liuxin/data-structure/answer/src/com/coding/basic/queue/CircleQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
package com.coding.basic.queue; | ||
|
||
public class CircleQueue { | ||
public class CircleQueue <E> { | ||
|
||
private final static int DEFAULT_SIZE = 10; | ||
|
||
//用数组来保存循环队列的元素 | ||
private Object[] elementData = new Object[DEFAULT_SIZE] ; | ||
|
||
//队头 | ||
private int front = 0; | ||
//队尾 | ||
private int rear = 0; | ||
|
||
public boolean isEmpty() { | ||
return false; | ||
|
||
} | ||
|
||
public int size() { | ||
return -1; | ||
} | ||
|
||
|
||
|
||
public void enQueue(E data) { | ||
|
||
} | ||
|
||
public E deQueue() { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
liuxin/data-structure/answer/src/com/coding/basic/stack/Tail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.coding.basic.stack; | ||
|
||
public class Tail { | ||
|
||
} |
30 changes: 26 additions & 4 deletions
30
liuxin/data-structure/answer/src/com/coding/basic/stack/expr/InfixToPostfix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
package com.coding.basic.stack.expr; | ||
|
||
import java.util.List; | ||
import java.util.Stack; | ||
|
||
public class InfixToPostfix { | ||
|
||
public static List<Token> convert(String expr) { | ||
return null; | ||
return null; | ||
} | ||
|
||
public static void main(String[] args) { | ||
Stack<Character> stack = new Stack<Character>(); | ||
String expr = "1+((2+3)*4)-5"; | ||
for(int i=0;i<expr.length(); i++){ | ||
char c = expr.charAt(i); | ||
if(c == '+'){ | ||
stack.push(c); | ||
} | ||
else if(c == '*'){ | ||
stack.push(c); | ||
} | ||
else if(c == ')'){ | ||
System.out.print(stack.pop() + " "); | ||
} | ||
else if(c == '('){ | ||
System.out.print(" "); | ||
} else{ | ||
System.out.print(c +" "); | ||
} | ||
} | ||
System.out.println(""); | ||
} | ||
|
||
|
||
|
||
} |
36 changes: 35 additions & 1 deletion
36
liuxin/data-structure/assignment/src/com/coding/basic/queue/CircleQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
package com.coding.basic.queue; | ||
|
||
public class CircleQueue { | ||
/** | ||
* 用数组实现循环队列 | ||
* @author liuxin | ||
* | ||
* @param <E> | ||
*/ | ||
public class CircleQueue <E> { | ||
|
||
private final static int DEFAULT_SIZE = 10; | ||
|
||
//用数组来保存循环队列的元素 | ||
private Object[] elementData = new Object[DEFAULT_SIZE] ; | ||
|
||
//队头 | ||
private int front = 0; | ||
//队尾 | ||
private int rear = 0; | ||
|
||
public boolean isEmpty() { | ||
return false; | ||
|
||
} | ||
|
||
public int size() { | ||
return -1; | ||
} | ||
|
||
|
||
|
||
public void enQueue(E data) { | ||
|
||
} | ||
|
||
public E deQueue() { | ||
return null; | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
liuxin/data-structure/assignment/src/com/coding/basic/queue/Josephus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.