Skip to content

Commit 97ae2d1

Browse files
author
Jane Liu
committed
数据结构第一周作业
1 parent 88144c6 commit 97ae2d1

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

group10/364298692/article.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 每周文章链接
2+
## week01 计算机的组成
3+

group10/364298692/cs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

group10/364298692/cs/src/com/coding/basic/BinaryTreeNode.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ public void setRight(BinaryTreeNode right) {
2626
}
2727

2828
public BinaryTreeNode insert(Object o){
29-
return null;
29+
BinaryTreeNode node = new BinaryTreeNode();
30+
node.data = o;
31+
if(data.hashCode() > o.hashCode()){
32+
this.right = node;
33+
}else{
34+
this.left = node;
35+
}
36+
return this;
3037
}
3138

39+
40+
3241
}

group10/364298692/cs/src/com/coding/basic/Queue.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
public class Queue {
44

5-
public void enQueue(Object o){
5+
private LinkedList linkedList;
6+
7+
public void enQueue(Object o){
8+
linkedList.addLast(o);
69
}
710

811
public Object deQueue(){
9-
return null;
12+
Object obj = linkedList.removeFirst();
13+
return obj;
1014
}
1115

1216
public boolean isEmpty(){
13-
return false;
17+
return linkedList.size() == 0;
1418
}
1519

1620
public int size(){
17-
return -1;
21+
return linkedList.size();
1822
}
1923
}

group10/364298692/cs/src/com/coding/basic/Stack.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@
33
public class Stack {
44
private ArrayList elementData = new ArrayList();
55

6-
public void push(Object o){
6+
public void push(Object o){
7+
elementData.add(elementData.size(), o);
78
}
89

910
public Object pop(){
10-
return null;
11+
Object obj = elementData.remove(elementData.size()-1);
12+
return obj;
1113
}
1214

1315
public Object peek(){
14-
return null;
16+
Object obj = elementData.get(0);
17+
return obj;
1518
}
1619
public boolean isEmpty(){
17-
return false;
20+
return elementData.size()==0;
1821
}
1922
public int size(){
20-
return -1;
23+
return elementData.size();
2124
}
2225
}

0 commit comments

Comments
 (0)