From 5a297dc7246e116d7df95b7cfddc360edb2e5d7e Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Sat, 19 Dec 2015 16:40:53 +0100 Subject: [PATCH] Uklonjen primer stabala za alternativni test --- Stabla/Primeri za test/StabloIO.java | 14 -- Stabla/Primeri za test/StabloIOClassic.java | 90 -------- Stabla/Primeri za test/StabloIOIndent.java | 78 ------- Stabla/Primeri za test/StabloIOPretty.java | 230 ------------------- Stabla/Primeri za test/StabloIORandom.java | 79 ------- Stabla/Primeri za test/StabloProgram.java | 242 -------------------- Stabla/Primeri za test/classic.txt | 50 ---- Stabla/Primeri za test/indent.txt | 99 -------- Stabla/Primeri za test/pretty.txt | 49 ---- 9 files changed, 931 deletions(-) delete mode 100644 Stabla/Primeri za test/StabloIO.java delete mode 100644 Stabla/Primeri za test/StabloIOClassic.java delete mode 100644 Stabla/Primeri za test/StabloIOIndent.java delete mode 100644 Stabla/Primeri za test/StabloIOPretty.java delete mode 100644 Stabla/Primeri za test/StabloIORandom.java delete mode 100644 Stabla/Primeri za test/StabloProgram.java delete mode 100644 Stabla/Primeri za test/classic.txt delete mode 100644 Stabla/Primeri za test/indent.txt delete mode 100644 Stabla/Primeri za test/pretty.txt diff --git a/Stabla/Primeri za test/StabloIO.java b/Stabla/Primeri za test/StabloIO.java deleted file mode 100644 index f0cab85..0000000 --- a/Stabla/Primeri za test/StabloIO.java +++ /dev/null @@ -1,14 +0,0 @@ -import org.svetovid.io.SvetovidReader; -import org.svetovid.io.SvetovidWriter; - -/* - * Ovaj interfejs i klase koje ga implementiraju sluze za ucitavanje i - * snimanje stabala. Nije potrebno znati ih, i bice dati, prilikom izrade - * prakticnih zadataka. - */ -public interface StabloIO { - - public Stablo readStablo(SvetovidReader in); - public void printStablo(SvetovidWriter out, Stablo stablo); - -} diff --git a/Stabla/Primeri za test/StabloIOClassic.java b/Stabla/Primeri za test/StabloIOClassic.java deleted file mode 100644 index d6b0445..0000000 --- a/Stabla/Primeri za test/StabloIOClassic.java +++ /dev/null @@ -1,90 +0,0 @@ -import java.util.NoSuchElementException; - -import org.svetovid.io.SvetovidReader; -import org.svetovid.io.SvetovidWriter; - -/* - * Ova klasa sluzi za ucitavanje i snimanje stabala. Nije potrebno znati je, - * i bice data, prilikom izrade prakticnih zadataka. - * - * Ocekivani format fajla je sledeci: - * - * br - * id leviId desniId vrednost (x br) - * - * Primer fajla je classic.txt - */ -public class StabloIOClassic implements StabloIO { - - @Override - public Stablo readStablo(SvetovidReader in) { - int br = in.readInt(); - Stablo stablo = null; - for (int i = 0; i < br; i++) { - int id = in.readInt(); - int leviId = in.readInt(); - int desniId = in.readInt(); - String vrednost = in.readLine(); - Stablo levi = leviId == -1 ? null : new Stablo(leviId); - Stablo desni =desniId == -1 ? null : new Stablo(desniId); - Stablo element = new Stablo(id, vrednost, levi, desni); - stablo = insert(stablo, element); - } - return stablo; - } - - private static Stablo insert(Stablo stablo, Stablo element) { - if (stablo == null) { - return element; - } - Stablo found = find(stablo, element.getId()); - if (found == null) { - throw new NoSuchElementException("id: " + element.getId()); - } - found.setVrednost(element.getVrednost()); - found.setLevi(element.getLevi()); - found.setDesni(element.getDesni()); - return stablo; - } - - private static Stablo find(Stablo stablo, int id) { - if (stablo == null) { - return null; - } - if (stablo.getId() == id) { - return stablo; - } - Stablo rezultat = find(stablo.getLevi(), id); - if (rezultat != null) { - return rezultat; - } - return find(stablo.getDesni(), id); - } - - @Override - public void printStablo(SvetovidWriter out, Stablo stablo) { - int br = count(stablo); - out.println(br); - iterate(out, stablo); - } - - private static int count(Stablo stablo) { - if (stablo == null) { - return 0; - } - return 1 + count(stablo.getLevi()) + count(stablo.getDesni()); - } - - private static void iterate(SvetovidWriter out, Stablo stablo) { - if (stablo == null) { - return; - } - int id = stablo.getId(); - int leviId = stablo.getLevi() == null ? -1 : stablo.getLevi().getId(); - int desniId = stablo.getDesni() == null ? -1 : stablo.getDesni().getId(); - String vrednost = stablo.getVrednost(); - out.println(id, leviId, desniId, vrednost); - iterate(out, stablo.getLevi()); - iterate(out, stablo.getDesni()); - } -} diff --git a/Stabla/Primeri za test/StabloIOIndent.java b/Stabla/Primeri za test/StabloIOIndent.java deleted file mode 100644 index dede26b..0000000 --- a/Stabla/Primeri za test/StabloIOIndent.java +++ /dev/null @@ -1,78 +0,0 @@ -import org.svetovid.SvetovidFormatException; -import org.svetovid.io.SvetovidReader; -import org.svetovid.io.SvetovidWriter; - -/* - * Ova klasa sluzi za ucitavanje i snimanje stabala. Nije potrebno znati je, - * i bice data, prilikom izrade prakticnih zadataka. - * - * Ocekivani format fajla je sledeci: - * - * id vrednost - * levi - * desni - * - * Primer fajla je indent.txt - */ -public class StabloIOIndent implements StabloIO { - - protected String nullSymbol; - protected String indent; - - public StabloIOIndent() { - this("-", " "); - } - - public StabloIOIndent(String nullSymbol, String indent) { - this.nullSymbol = nullSymbol; - this.indent = indent; - } - - public String getNullSymbol() { - return nullSymbol; - } - - public void setNullSymbol(String nullSymbol) { - this.nullSymbol = nullSymbol; - } - - public String getIndent() { - return indent; - } - - public void setIndent(String indent) { - this.indent = indent; - } - - @Override - public Stablo readStablo(SvetovidReader in) { - try { - int id = in.readInt(); - String vrednost = in.readLine(); - Stablo levi = readStablo(in); - Stablo desni = readStablo(in); - Stablo stablo = new Stablo(id, vrednost, levi, desni); - return stablo; - } catch (SvetovidFormatException e) { - return null; - } - } - - @Override - public void printStablo(SvetovidWriter out, Stablo stablo) { - write(out, stablo, nullSymbol, indent, ""); - } - - protected void write(SvetovidWriter out, Stablo stablo, String nullSymbol, String indent, String prefix) { - if (stablo == null) { - out.println(prefix + nullSymbol); - return; - } - int id = stablo.getId(); - String vrednost = stablo.getVrednost(); - out.print(prefix); - out.println(id, vrednost); - write(out, stablo.getLevi(), nullSymbol, indent, prefix + indent); - write(out, stablo.getDesni(), nullSymbol, indent, prefix + indent); - } -} diff --git a/Stabla/Primeri za test/StabloIOPretty.java b/Stabla/Primeri za test/StabloIOPretty.java deleted file mode 100644 index 2df3c03..0000000 --- a/Stabla/Primeri za test/StabloIOPretty.java +++ /dev/null @@ -1,230 +0,0 @@ -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.svetovid.io.SvetovidReader; -import org.svetovid.io.SvetovidWriter; - -/* - * Ova klasa sluzi za ucitavanje i snimanje stabala. Nije potrebno znati je, - * i bice data, prilikom izrade prakticnih zadataka. - * - * Ocekivani format fajla je sledeci: - * - * /-- desni - * -(id) vrednost - * \-- levi - * - * Primer fajla je pretty.txt - */ -public class StabloIOPretty implements StabloIO { - - protected static final String EMPTY_SYMBOL = " "; - protected static final String RIGHT_SYMBOL = "/"; - protected static final String VERTICAL_SYMBOL = "|"; - protected static final String LEFT_SYMBOL = "\\"; - protected static final String HORIZONTAL_SYMBOL = "-"; - - protected String nullSymbol; - protected boolean separated; - protected int length; - - public StabloIOPretty() { - this(null, false, 7); - } - - public StabloIOPretty(String nullSymbol, boolean separated, int length) { - this.nullSymbol = nullSymbol; - this.separated = separated; - this.length = length; - } - - public String getNullSymbol() { - return nullSymbol; - } - - public void setNullSymbol(String nullSymbol) { - this.nullSymbol = nullSymbol; - } - - public boolean isSeparated() { - return separated; - } - - public void setSeparated(boolean separated) { - this.separated = separated; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - if (length < 3) { - throw new IllegalArgumentException("length"); - } - this.length = length; - } - - @Override - public Stablo readStablo(SvetovidReader in) { - return parseStablo(in, nullSymbol, length); - } - - protected Stablo parseStablo(SvetovidReader in, String nullSymbol, int length) { - List elements = new ArrayList<>(); - List levels = new ArrayList<>(); - Pattern levelPattern = Pattern.compile("[\\Q" + LEFT_SYMBOL + HORIZONTAL_SYMBOL + RIGHT_SYMBOL + "\\E]"); - String line = in.readLine(); - while ((line != null) && !line.isEmpty()) { - Matcher matcher = levelPattern.matcher(line); - int level = -1; - if (matcher.find()) { - level = matcher.start(); - } - if (level != -1 && (nullSymbol == null || !line.endsWith(nullSymbol))) { - Stablo stablo = parseStablo(line); - elements.add(stablo); - levels.add(level); - } - line = in.readLine(); - } - Stablo stablo = formStablo(0, elements.size(), levels, elements); - return stablo; - } - - private Stablo parseStablo(String line) { - int id = -1; - String vrednost = null; - int beginIndex = line.indexOf('('); - int endIndex = line.indexOf(')'); - if ((beginIndex != -1) && (endIndex != -1) && (beginIndex < endIndex)) { - vrednost = line.substring(beginIndex + 1, endIndex); - try { - id = Integer.parseInt(vrednost); - } catch (NumberFormatException e) { - throw new NumberFormatException(line); - } - vrednost = line.substring(endIndex + 2); - } else { - throw new NumberFormatException(line); - } - Stablo stablo = new Stablo(id, vrednost); - return stablo; - } - - private Stablo formStablo(int beginIndex, int endIndex, List levels, List elements) { - if (beginIndex >= endIndex) { - return null; - } - int minIndex = beginIndex; - int minLevel = levels.get(minIndex); - for (int i = beginIndex + 1; i < endIndex; i++) { - int level = levels.get(i); - if (level < minLevel) { - minLevel = level; - minIndex = i; - } - } - Stablo stablo = elements.get(minIndex); - Stablo levi = formStablo(minIndex + 1, endIndex, levels, elements); - Stablo desni = formStablo(beginIndex, minIndex, levels, elements); - stablo.setLevi(levi); - stablo.setDesni(desni); - return stablo; - } - - @Override - public void printStablo(SvetovidWriter out, Stablo stablo) { - StringBuilder builder = new StringBuilder(); - appendTree(builder, stablo, nullSymbol, separated, length); - out.print(builder.toString()); - } - - protected void appendTree(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, int length) { - String[] buildingBlocks = generateBuildingBlocks(length); - appendRight(builder, stablo, nullSymbol, separated, buildingBlocks, true, buildingBlocks[5]); - appendNode(builder, stablo, nullSymbol != null ? nullSymbol : "|", buildingBlocks[4]); - appendLeft(builder, stablo, nullSymbol, separated, buildingBlocks, false, buildingBlocks[5]); - } - - protected void appendNode(StringBuilder builder, Stablo stablo, String nullSymbol, String prefix) { - builder.append(prefix); - if (stablo == null) { - builder.append(nullSymbol); - } else { - builder.append("("); - builder.append(stablo.getId()); - builder.append(") "); - builder.append(stablo.getVrednost()); - } - builder.append("\n"); - } - - protected void appendRight(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) { - if (stablo == null) { - return; - } - if ((nullSymbol != null) || (stablo.getDesni() != null)) { - appendSubtree(builder, stablo.getDesni(), nullSymbol, separated, buildingBlocks, true, prefix); - if (separated) { - appendEmpty(builder, buildingBlocks, prefix); - } - } - } - - protected void appendLeft(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) { - if (stablo == null) { - return; - } - if ((nullSymbol != null) || (stablo.getLevi() != null)) { - if (separated) { - appendEmpty(builder, buildingBlocks, prefix); - } - appendSubtree(builder, stablo.getLevi(), nullSymbol, separated, buildingBlocks, false, prefix); - } - } - - protected void appendEmpty(StringBuilder builder, String[] buildingBlocks, String prefix) { - builder.append(prefix); - builder.append(buildingBlocks[2]); - builder.append("\n"); - } - - protected void appendSubtree(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) { - String mojPrefix = prefix; - if (isRight == true) { - mojPrefix = mojPrefix + buildingBlocks[1]; - } - if (isRight == false) { - mojPrefix = mojPrefix + buildingBlocks[3]; - } - String noviPrefix = prefix + (!isRight ? buildingBlocks[2] : buildingBlocks[0]); - appendRight(builder, stablo, nullSymbol, separated, buildingBlocks, isRight, noviPrefix); - appendNode(builder, stablo, nullSymbol, mojPrefix); - noviPrefix = prefix + (isRight ? buildingBlocks[2] : buildingBlocks[0]); - appendLeft(builder, stablo, nullSymbol, separated, buildingBlocks, isRight, noviPrefix); - } - - private String[] generateBuildingBlocks(int length) { - String[] blocks = new String[6]; - blocks[0] = generateBlock(EMPTY_SYMBOL, EMPTY_SYMBOL, EMPTY_SYMBOL, length - 2); - blocks[1] = generateBlock(EMPTY_SYMBOL, RIGHT_SYMBOL, HORIZONTAL_SYMBOL, length - 2); - blocks[2] = generateBlock(EMPTY_SYMBOL, VERTICAL_SYMBOL, EMPTY_SYMBOL, length - 2); - blocks[3] = generateBlock(EMPTY_SYMBOL, LEFT_SYMBOL, HORIZONTAL_SYMBOL, length - 2); - blocks[4] = HORIZONTAL_SYMBOL; - blocks[5] = EMPTY_SYMBOL; - return blocks; - } - - protected String generateBlock(String emptySymbol, String startSymbol, String repeatSymbol, int repeatCount) { - StringBuilder builder = new StringBuilder(); - builder.append(emptySymbol); - builder.append(startSymbol); - for (int i = 0; i < repeatCount; i++) { - builder.append(repeatSymbol); - } - return builder.toString(); - } -} diff --git a/Stabla/Primeri za test/StabloIORandom.java b/Stabla/Primeri za test/StabloIORandom.java deleted file mode 100644 index f5880c4..0000000 --- a/Stabla/Primeri za test/StabloIORandom.java +++ /dev/null @@ -1,79 +0,0 @@ -import java.math.BigInteger; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; - -import org.svetovid.io.SvetovidReader; -import org.svetovid.io.SvetovidWriter; - -/* - * Ova klasa sluzi za generisanje random stabala. Nije potrebno znati je, - * i bice data, prilikom izrade prakticnih zadataka. - */ -public class StabloIORandom implements StabloIO { - - protected long seed; - protected int length; - protected int depth; - - public StabloIORandom() { - this(System.currentTimeMillis()); - } - - public StabloIORandom(long seed) { - this(seed, 5, 10); - } - - public StabloIORandom(long seed, int length, int depth) { - this.seed = seed; - this.length = length; - this.depth = depth; - } - - public long getSeed() { - return seed; - } - - public void setSeed(long seed) { - this.seed = seed; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length = length; - } - - public int getDepth() { - return depth; - } - - public void setDepth(int depth) { - this.depth = depth; - } - - @Override - public Stablo readStablo(SvetovidReader in) { - Random random = new Random(seed); - AtomicInteger sequence = new AtomicInteger(); - Stablo stablo = readStablo(random, sequence, length, depth); - return stablo; - } - - private Stablo readStablo(Random random, AtomicInteger sequence, int length, int depth) { - if (depth <= 0) { - return null; - } - int id = sequence.addAndGet(1 + random.nextInt(9)); - String vrednost = new BigInteger(length, random).toString(36); - Stablo desni = readStablo(random, sequence, length + random.nextInt(5), depth - random.nextInt(5)); - Stablo levi = readStablo(random, sequence, length + random.nextInt(5), depth - random.nextInt(5)); - return new Stablo(id, vrednost, levi, desni); - } - - @Override - public void printStablo(SvetovidWriter out, Stablo stablo) { - throw new UnsupportedOperationException(); - } -} diff --git a/Stabla/Primeri za test/StabloProgram.java b/Stabla/Primeri za test/StabloProgram.java deleted file mode 100644 index ee70ace..0000000 --- a/Stabla/Primeri za test/StabloProgram.java +++ /dev/null @@ -1,242 +0,0 @@ -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -// Tip podataka koji predstavlja binarno stablo -// ID svakog cvora je tipa int a vrednost sadrzana u njemu tipa String -// Na velikom testu, studenti ce dobiti ovu klasu -class Stablo { - - private final int id; - private String vrednost; - private Stablo levi; - private Stablo desni; - - public Stablo(int id) { - this(id, null); - } - - public Stablo(int id, String vrednost) { - this(id, vrednost, null, null); - } - - public Stablo(int id, String vrednost, Stablo levi, Stablo desni) { - this.id = id; - this.vrednost = vrednost; - this.levi = levi; - this.desni = desni; - } - - public int getId() { - return id; - } - - public String getVrednost() { - return vrednost; - } - - public void setVrednost(String vrednost) { - this.vrednost = vrednost; - } - - public Stablo getLevi() { - return levi; - } - - public void setLevi(Stablo levi) { - this.levi = levi; - } - - public Stablo getDesni() { - return desni; - } - - public void setDesni(Stablo desni) { - this.desni = desni; - } - - @Override - public String toString() { - return "(" + id + " \"" + vrednost + "\"" + (levi == null ? "" : " " + levi) + (desni == null ? "" : " " + desni) + ")"; - } - - @Override - public int hashCode() { - final int prostBroj = 31; - int rezultat = 1; - rezultat = rezultat * prostBroj + id; - rezultat = rezultat * prostBroj + ((vrednost == null) ? 0 : vrednost.hashCode()); - rezultat = rezultat * prostBroj + ((levi == null) ? 0 : levi.hashCode()); - rezultat = rezultat * prostBroj + ((desni == null) ? 0 : desni.hashCode()); - return rezultat; - } - - @Override - public boolean equals(Object obj) { - - // Objekat je jednak ako je identican - if (this == obj) { - return true; - } - - // Null je razlicit od svih objekata - if (obj == null) { - return false; - } - - // Ako su klase objekata razlicite, onda su i objekti razliciti - if (getClass() != obj.getClass()) { - return false; - } - - // Pretvorimo prosledjeni objekat u stablo - Stablo that = (Stablo) obj; - - // Razlicit ID znaci da su objekti razliciti - if (this.id != that.id) { - return false; - } - - // Takodje i vrednost - if (Objects.equals(this.vrednost, that.vrednost)) { - return false; - } - - // Potom levo podstablo - if (Objects.equals(this.levi, that.levi)) { - return false; - } - - // Pa desno podstablo - if (Objects.equals(this.desni, that.desni)) { - return false; - } - - // Sva polja se poklapaju - return true; - - } -} - -// Glavni program -// Na velikom testu ce biti dat kostur koji ucitava potrebno stablo -// Od studenata ce se ocekivati da implementiraju neki algoritam poput -// statickih metoda koje se pozivaju u ovoj klasi -public class StabloProgram { - - public static void main(String[] args) { - - // Ucitavanje stabla iz fajla u "pretty" formatu - // StabloIO inIO = new StabloIOPretty(); - // Stablo stablo = inIO.readStablo(Svetovid.in("pretty.txt")); - - // Generisanje random stabla - StabloIO inIO = new StabloIORandom(12345); - Stablo stablo = inIO.readStablo(null); - - // Ispisivanje stabla na ekran - StabloIO outIO = new StabloIOPretty(); - outIO.printStablo(Svetovid.out, stablo); - Svetovid.out.println(); - - // Broj nivoa - int brojNivoa = brojNivoa(stablo); - Svetovid.out.println("Broj nivoa:", brojNivoa); - Svetovid.out.println(); - - // Broj elemenata - int brojElementata = brojElementata(stablo); - Svetovid.out.println("Broj elementata:", brojElementata); - Svetovid.out.println(); - - // Najduza String vrednost u stablu - String najduzaVrednost = najduzaVrednost(stablo); - Svetovid.out.println("Najduza vrednost:", najduzaVrednost); - Svetovid.out.println(); - - // Svi Putevi od korena do listova - sviPutevi(stablo, new ArrayList<>(brojNivoa)); - Svetovid.out.println(); - - // Obrnuto stablo - Stablo obrnuto = obrni(stablo); - outIO.printStablo(Svetovid.out, obrnuto); - Svetovid.out.println(); - - // Implementacije ovih algoritama su date ispod kao staticki metodi - // Za veliki test, od studenata ce se ocekivati da na isti nacin - // implementiraju algoritam koji se bude trazio u zadatku. - // - // Pored ovde implementiranih algoritama, sledi i par ideja za vezbanje: - // - Ispisati vrednosti cvorova sa parnim IDom - // - Ispisati sve vrednosti cvorova na nivou koji se ucitava sa tastature - // - Utvrditi da li postoji postoji putanja od korena do lista koja sadrzi - // string duzine 5 - // - Napraviti novo stablo iste strukture ali sa svim vrednostima ALL CAPS - // - Proveriti da li je dato stablo binarno stablo pretrazivanj, tj. da - // su sve vrednosti u levom podstablu leksikografski pre vrednosti u - // korenu, svi elementi u desnom leksikografski posle, i ovo takodje - // vazi za oba podstabla - // - Koliko ima cvorova na nivou 7 - // - Koliko se puta string "abc" javlja u stablu - - } - - // Vraca ukupan broj elemenata u stablu - private static int brojElementata(Stablo stablo) { - if (stablo == null) { - return 0; // Prazno stablo ima 0 elemenata - } - return 1 + brojElementata(stablo.getLevi()) + brojElementata(stablo.getDesni()); - } - - // Vraca visinu stabla - private static int brojNivoa(Stablo stablo) { - if (stablo == null) { - return 0; // Prazno stablo je visine 0 - } - return 1 + Math.max(brojNivoa(stablo.getLevi()), brojNivoa(stablo.getDesni())); - } - - // Vraca najduzi string sadrzan kao vrednos u nekom od cvorova - private static String najduzaVrednost(Stablo stablo) { - if (stablo == null) { - return null; // Prazno stablo ne sadrzi vrednosti - } - String rezultat = stablo.getVrednost(); - String levaVrednost = najduzaVrednost(stablo.getLevi()); - String desnaVrednost = najduzaVrednost(stablo.getDesni()); - if (rezultat == null || (levaVrednost != null && rezultat.length() < levaVrednost.length())) { - rezultat = levaVrednost; - } - if (rezultat == null || (desnaVrednost != null && rezultat.length() < desnaVrednost.length())) { - rezultat = desnaVrednost; - } - return rezultat; - } - - // Ispisuje sve puteve od korena do listova - private static void sviPutevi(Stablo stablo, List put) { - if (stablo == null) { - return; - } - put.add(stablo.getVrednost()); - if ((stablo.getLevi() == null) && (stablo.getDesni() == null)) { - Svetovid.out.println("Put: " + put); - } - sviPutevi(stablo.getLevi(), put); - sviPutevi(stablo.getDesni(), put); - put.remove(put.size() - 1); - } - - // Vraca obrnuto stablo od datog - private static Stablo obrni(Stablo stablo) { - if (stablo == null) { - return null; - } - Stablo levi = obrni(stablo.getLevi()); - Stablo desni = obrni(stablo.getDesni()); - Stablo obrnuto = new Stablo(stablo.getId(), stablo.getVrednost(), desni, levi); - return obrnuto; - } -} diff --git a/Stabla/Primeri za test/classic.txt b/Stabla/Primeri za test/classic.txt deleted file mode 100644 index 8afb799..0000000 --- a/Stabla/Primeri za test/classic.txt +++ /dev/null @@ -1,50 +0,0 @@ -49 -5 94 10 h -94 136 97 a -136 214 143 54 -214 219 -1 3g -219 226 -1 ph -226 -1 229 y4 -229 -1 230 515 -230 237 -1 mo0 -237 251 245 1adr -251 -1 -1 a5f1 -245 -1 -1 2jl1 -143 -1 147 ak -147 161 152 4a0 -161 182 165 14 -182 189 -1 50f5 -189 192 -1 2uh8 -192 193 -1 27r6 -193 194 -1 1ol4m -194 209 201 2a3aq -209 -1 -1 7aa8b -201 -1 -1 2l3k6 -165 171 167 4ac3 -171 173 -1 1g7an -173 -1 -1 8deri -167 -1 -1 fe2n -152 -1 -1 2p7 -97 106 -1 1m -106 134 109 81 -134 -1 -1 1pu -109 117 -1 1by -117 129 123 iu0 -129 -1 -1 8tl8 -123 -1 -1 3bds -10 67 18 9 -67 72 71 e6 -72 85 76 6n -85 87 -1 km1 -87 -1 -1 2u0n -76 -1 -1 1nm -71 -1 -1 36 -18 29 26 1m -29 58 32 67 -58 -1 -1 32 -32 51 41 mg -51 -1 52 14y -52 -1 -1 7uq -41 44 -1 h1 -44 -1 -1 1ec -26 -1 -1 19 diff --git a/Stabla/Primeri za test/indent.txt b/Stabla/Primeri za test/indent.txt deleted file mode 100644 index caecf7a..0000000 --- a/Stabla/Primeri za test/indent.txt +++ /dev/null @@ -1,99 +0,0 @@ -5 h - 94 a - 136 54 - 214 3g - 219 ph - 226 y4 - - - 229 515 - - - 230 mo0 - 237 1adr - 251 a5f1 - - - - - 245 2jl1 - - - - - - - - - - - 143 ak - - - 147 4a0 - 161 14 - 182 50f5 - 189 2uh8 - 192 27r6 - 193 1ol4m - 194 2a3aq - 209 7aa8b - - - - - 201 2l3k6 - - - - - - - - - - - - - 165 4ac3 - 171 1g7an - 173 8deri - - - - - - - 167 fe2n - - - - - 152 2p7 - - - - - 97 1m - 106 81 - 134 1pu - - - - - 109 1by - 117 iu0 - 129 8tl8 - - - - - 123 3bds - - - - - - - - - 10 9 - 67 e6 - 72 6n - 85 km1 - 87 2u0n - - - - - - - 76 1nm - - - - - 71 36 - - - - - 18 1m - 29 67 - 58 32 - - - - - 32 mg - 51 14y - - - 52 7uq - - - - - 41 h1 - 44 1ec - - - - - - - 26 19 - - - - diff --git a/Stabla/Primeri za test/pretty.txt b/Stabla/Primeri za test/pretty.txt deleted file mode 100644 index 5f1b623..0000000 --- a/Stabla/Primeri za test/pretty.txt +++ /dev/null @@ -1,49 +0,0 @@ - /-----(26) 19 - /-----(18) 1m - | | /-----(41) h1 - | | | \-----(44) 1ec - | | /-----(32) mg - | | | | /-----(52) 7uq - | | | \-----(51) 14y - | \-----(29) 67 - | \-----(58) 32 - /-----(10) 9 - | | /-----(71) 36 - | \-----(67) e6 - | | /-----(76) 1nm - | \-----(72) 6n - | \-----(85) km1 - | \-----(87) 2u0n --(5) h - | /-----(97) 1m - | | | /-----(109) 1by - | | | | | /-----(123) 3bds - | | | | \-----(117) iu0 - | | | | \-----(129) 8tl8 - | | \-----(106) 81 - | | \-----(134) 1pu - \-----(94) a - | /-----(152) 2p7 - | /-----(147) 4a0 - | | | /-----(167) fe2n - | | | /-----(165) 4ac3 - | | | | \-----(171) 1g7an - | | | | \-----(173) 8deri - | | \-----(161) 14 - | | \-----(182) 50f5 - | | \-----(189) 2uh8 - | | \-----(192) 27r6 - | | \-----(193) 1ol4m - | | | /-----(201) 2l3k6 - | | \-----(194) 2a3aq - | | \-----(209) 7aa8b - | /-----(143) ak - \-----(136) 54 - \-----(214) 3g - \-----(219) ph - | /-----(230) mo0 - | | | /-----(245) 2jl1 - | | \-----(237) 1adr - | | \-----(251) a5f1 - | /-----(229) 515 - \-----(226) y4 -- 2.25.1