null
US
Sign In
Sign Up for Free
Sign Up
We have detected that Javascript is not enabled in your browser. The dynamic nature of our site means that Javascript must be enabled to function properly. Please read our
terms and conditions
for more information.
Next up
Copy and Edit
You need to log in to complete this action!
Register for Free
12615130
Binary Search Trees 2
Description
Mind Map on Binary Search Trees 2, created by Eithne O'Sullivan on 04/03/2018.
No tags specified
tree
binary search tree
size
findmin
findmax
Mind Map by
Eithne O'Sullivan
, updated more than 1 year ago
More
Less
Created by
Eithne O'Sullivan
almost 8 years ago
6
0
0
Resource summary
Binary Search Trees 2
To Compare Objects of the same class ( needed to add to tree)
Steps
Define own class e.g. Student
Implement Comparable interface
Provide an implementation of interface method 'compareTo' in own class (criteria on which to compare) (e.g. age)
returns 0 if equal, returns 1 if current obj is > than argument obj,returns -1 if current obj is < than argument obj
to sort a list:
add objects to an arrayList in PVSM: e.g. students
invoke Collection.sort(students) to sort the collection ArrayList
implementation
int size(), int size(BTNode<T> current
uses recursion size(root)
IF current == null returns 0 (base) ELSE returns (1 + size(left-child node) + size(right-child node)
create BinaryTree interface
create BinarySearchTree class that implements BinaryTree interface
create BTNode
create BTTest
T findMin(), T findMin(BTNode<T> current)
uses recursion findMin(root)
if (current.left == null) return current.element; else return findMin(current.left);
always go left due to ordered structure as min value will be the last left node (down tru' left nodes until no left child)
non recursive method: while (current.left != null) { current = current.left; } return current.element;
T findMax(), T findMax(BTNode<T> current)
uses recursion findMax(root)
if (current.right == null) return current.element; else return findMax(current.right);
always go right due to ordered structure as max value will be the last right node (down tru' right nodes until no right child)
non recursive method: while (current.right != null) { current = current.right; } return current.element;
Show full summary
Hide full summary
Want to create your own
Mind Maps
for
free
with GoConqr?
Learn more
.
Similar
F453 Data Structures - Binary Trees
harvs899
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
Browse Library