diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..79b5594
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+**/.DS_Store
diff --git a/naloga1/.idea/vcs.xml b/naloga1/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/naloga1/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/.gitignore b/naloga2/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/naloga2/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/naloga2/.idea/.gitignore b/naloga2/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/naloga2/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/naloga2/.idea/inspectionProfiles/Project_Default.xml b/naloga2/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..581c216
--- /dev/null
+++ b/naloga2/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/.idea/misc.xml b/naloga2/.idea/misc.xml
new file mode 100644
index 0000000..eeb80f7
--- /dev/null
+++ b/naloga2/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/.idea/modules.xml b/naloga2/.idea/modules.xml
new file mode 100644
index 0000000..46d59f0
--- /dev/null
+++ b/naloga2/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/.idea/vcs.xml b/naloga2/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/naloga2/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/naloga2.iml b/naloga2/naloga2.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/naloga2/naloga2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/naloga2/src/AlphabeticalComparator.java b/naloga2/src/AlphabeticalComparator.java
new file mode 100644
index 0000000..5e0952a
--- /dev/null
+++ b/naloga2/src/AlphabeticalComparator.java
@@ -0,0 +1,8 @@
+import java.util.Comparator;
+
+class AlphabeticalComparator implements Comparator {
+ @Override
+ public int compare(String s1, String s2) {
+ return s1.compareTo(s2);
+ }
+}
\ No newline at end of file
diff --git a/naloga2/src/Main.java b/naloga2/src/Main.java
new file mode 100644
index 0000000..ba6517c
--- /dev/null
+++ b/naloga2/src/Main.java
@@ -0,0 +1,22 @@
+public class Main {
+ public static void main(String[] args) {
+ AlphabeticalComparator comparator = new AlphabeticalComparator();
+
+ TabelaTabel tabelaTabel = new TabelaTabel(comparator);
+
+ tabelaTabel.izpisi();
+
+ tabelaTabel.vstavi("1");
+ tabelaTabel.vstavi("12");
+ tabelaTabel.vstavi("123");
+
+ tabelaTabel.izpisi();
+
+ tabelaTabel.vstavi("321");
+ tabelaTabel.vstavi("6383");
+ tabelaTabel.vstavi("43");
+ tabelaTabel.vstavi("023");
+
+ tabelaTabel.izpisi();
+ }
+}
diff --git a/naloga2/src/TabelaTabel.java b/naloga2/src/TabelaTabel.java
new file mode 100644
index 0000000..afc1352
--- /dev/null
+++ b/naloga2/src/TabelaTabel.java
@@ -0,0 +1,109 @@
+import java.util.Comparator;
+
+class Item {
+ String value;
+ int count;
+
+ Item(String value) {
+ this.value = value;
+ this.count = 1;
+ }
+}
+
+public class TabelaTabel {
+ Comparator comparator;
+ Item[] array = new Item[32];
+ int size = 0;
+
+ TabelaTabel(Comparator comparator) {
+ this.comparator = comparator;
+ }
+
+ private boolean isFull() {
+ return size >= array.length;
+ }
+
+ private void resize() {
+ Item[] tmp = new Item[array.length * 2];
+ System.arraycopy(array, 0, tmp, 0, array.length);
+ array = tmp;
+ }
+
+ private int getSubarrayCount() {
+ if (size == 0) {
+ return 0;
+ }
+ return (int) (Math.log(size) / Math.log(2)) + 1;
+ }
+
+ private boolean isSubarrayFull(int i) {
+ return ((size >> i) & 1) != 0;
+ }
+
+ void vstavi(String element) {
+ Item[] tmp = {new Item(element)};
+ boolean success = false;
+ int k = getSubarrayCount();
+ for (int i = 0; i < k; i++) {
+ if (isSubarrayFull(i)) {
+ // Append subarray to tmp
+ int subArrLen = 1 << i;
+ Item[] newTmp = new Item[tmp.length + subArrLen];
+ System.arraycopy(tmp, 0, newTmp, 0, tmp.length);
+ System.arraycopy(array, subArrLen - 1, newTmp, tmp.length, subArrLen);
+ tmp = newTmp;
+ } else {
+ // Set subarray to tmp
+ System.arraycopy(tmp, 0, array, i, tmp.length);
+ success = true;
+ break;
+ }
+ }
+
+ if (!success) {
+ // Crate new subarray with size k and add tmp to it
+ if (isFull()) {
+ resize();
+ }
+ System.arraycopy(tmp, 0, array, k, tmp.length);
+ }
+
+ size++;
+ }
+
+ void najdi(String element) {
+
+ }
+
+ void izbrisi(String element) {
+
+ }
+
+ void izpisi() {
+ if (size == 0) {
+ System.out.println("prazen");
+ return;
+ }
+
+ for (int i = 0; i < getSubarrayCount(); i++) {
+ if (!isSubarrayFull(i)) {
+ System.out.println("...");
+ continue;
+ }
+
+ int startIndex = i == 0 ? 0 : 1 << (i - 1);
+ int subArrLen = 1 << i;
+ for (int j = startIndex; j < startIndex + subArrLen; j++) {
+ if (j > startIndex) {
+ System.out.print(", ");
+ }
+ if (array[j] == null) {
+ System.out.print("x");
+ } else {
+ System.out.printf("%s/%d", array[j].value, array[j].count);
+ }
+ }
+ System.out.println();
+ }
+ }
+}