diff --git a/.gitignore b/.gitignore
index e43b0f9..79b5594 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-.DS_Store
+**/.DS_Store
diff --git a/izzivi/.idea/vcs.xml b/izzivi/.idea/vcs.xml
index 94a25f7..288b36b 100644
--- a/izzivi/.idea/vcs.xml
+++ b/izzivi/.idea/vcs.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/izzivi/src/izziv3/Izziv3.java b/izzivi/src/izziv3/Izziv3.java
index 470a4c4..752cd67 100644
--- a/izzivi/src/izziv3/Izziv3.java
+++ b/izzivi/src/izziv3/Izziv3.java
@@ -4,8 +4,7 @@ import java.util.ArrayList;
public class Izziv3 {
public static void main(String[] args) {
-// int size = Integer.parseInt(args[0]);
- int size = 20;
+ int size = Integer.parseInt(args[0]);
StdDraw.setCanvasSize(1500, 800);
StdDraw.setXscale(-1, size);
@@ -13,7 +12,7 @@ public class Izziv3 {
CompleteBinaryTreeDrawer ctd = new CompleteBinaryTreeDrawer(size);
- ctd.drawLevelorder();
+ ctd.drawPreorder(0);
}
}
@@ -23,6 +22,8 @@ class CompleteBinaryTreeDrawer {
ArrayList inorder;
final int size;
+ double xScale, yScale;
+
public CompleteBinaryTreeDrawer(int size) {
this.size = size;
data = new char[size];
@@ -31,9 +32,12 @@ class CompleteBinaryTreeDrawer {
inorder = new ArrayList<>();
inorder(0);
+ xScale = size;
+ yScale = (int) (Math.log(size + 1) / Math.log(2)) + 1;
+
for (int i = 0; i < size; i++) {
data[i] = (char) ('A' + i);
- x[i] = inorder.indexOf(Integer.valueOf(i));
+ x[i] = inorder.indexOf(i);
y[i] = (int) (Math.log(i + 1) / Math.log(2));
}
}
@@ -42,14 +46,14 @@ class CompleteBinaryTreeDrawer {
if (2 * i + 1 < size) {
inorder(i * 2 + 1);
}
- inorder.add(Integer.valueOf(i));
+ inorder.add(i);
if (2 * i + 2 < size) {
inorder(2 * i + 2);
}
}
void drawNode(int i) {
- StdDraw.filledCircle(x[i], y[i], 0.1);
+ StdDraw.filledEllipse(x[i], y[i], xScale * 0.01, yScale * 0.02);
}
void drawEdgeToNode(int i) {
diff --git a/izzivi/src/izziv3/n13preorder.png b/izzivi/src/izziv3/n13preorder.png
new file mode 100644
index 0000000..73ae2c4
Binary files /dev/null and b/izzivi/src/izziv3/n13preorder.png differ
diff --git a/naloge/naloga1/.idea/vcs.xml b/naloge/naloga1/.idea/vcs.xml
index 35eb1dd..8fe5bdb 100644
--- a/naloge/naloga1/.idea/vcs.xml
+++ b/naloge/naloga1/.idea/vcs.xml
@@ -2,5 +2,6 @@
+
\ No newline at end of file