Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Binary Search Trees 2

Beschreibung

Mindmap am Binary Search Trees 2, erstellt von Eithne O'Sullivan am 04/03/2018.
Eithne O'Sullivan
Mindmap von Eithne O'Sullivan, aktualisiert more than 1 year ago
Eithne O'Sullivan
Erstellt von Eithne O'Sullivan vor mehr als 7 Jahre
5
0
1 2 3 4 5 (0)

Zusammenfassung der Ressource

Binary Search Trees 2
  1. To Compare Objects of the same class ( needed to add to tree)
    1. Steps
      1. Define own class e.g. Student
        1. Implement Comparable interface
          1. Provide an implementation of interface method 'compareTo' in own class (criteria on which to compare) (e.g. age)
            1. returns 0 if equal, returns 1 if current obj is > than argument obj,returns -1 if current obj is < than argument obj
            2. to sort a list:
              1. add objects to an arrayList in PVSM: e.g. students
                1. invoke Collection.sort(students) to sort the collection ArrayList
            3. implementation
              1. int size(), int size(BTNode<T> current
                1. uses recursion size(root)
                  1. IF current == null returns 0 (base) ELSE returns (1 + size(left-child node) + size(right-child node)
                2. create BinaryTree interface
                  1. create BinarySearchTree class that implements BinaryTree interface
                    1. create BTNode
                      1. create BTTest
                        1. T findMin(), T findMin(BTNode<T> current)
                          1. uses recursion findMin(root)
                            1. if (current.left == null) return current.element; else return findMin(current.left);
                              1. always go left due to ordered structure as min value will be the last left node (down tru' left nodes until no left child)
                            2. non recursive method: while (current.left != null) { current = current.left; } return current.element;
                            3. T findMax(), T findMax(BTNode<T> current)
                              1. uses recursion findMax(root)
                                1. if (current.right == null) return current.element; else return findMax(current.right);
                                  1. always go right due to ordered structure as max value will be the last right node (down tru' right nodes until no right child)
                                2. non recursive method: while (current.right != null) { current = current.right; } return current.element;
                              Zusammenfassung anzeigen Zusammenfassung ausblenden

                              0 Kommentare

                              There are no comments, be the first and leave one below:

                              ähnlicher Inhalt

                              Campus 1
                              Sage Pritchett
                              Kruskal's Algorithm
                              Ezra Dorland
                              my family tree
                              adriane cunningham
                              Apple Tree Quiz
                              maddymunden
                              NTP Redesign Decision Tree for Initial Analysis
                              kavita.batra
                              Scalars and vectors
                              Ezra Dorland
                              Bacterial Morphology + Gram Stains
                              Princess Banana Hammock
                              Rowena
                              siojo01
                              Peromyscus
                              dtijerina2
                              Test
                              sbosquez