#### Study sets matching "binary trees"

#### Study sets matching "binary trees"

Binary Trees

Implementation Strategies

Node-and-link based

Array based

Order of 2

Node-and-link based; Array based

Implementation matches our conceptual picture of what a tree l…

Implementation could use far too much space; store the root at…

Binary Trees

Order of 2

Implementation Strategies

Node-and-link based; Array based

Test a Binary Tree

Heap

Removal of item in Heap

Insert in a Heap

use In order traversal... after several deletions and insertions…

is a complete Binary Tree... it's root holds the Minimum element…

Remove Root node... replace Root with LIH(last in heap)... while(LIH…

Insert into last space in heap or bottom... while (Node > parent…

Test a Binary Tree

use In order traversal... after several deletions and insertions…

Heap

is a complete Binary Tree... it's root holds the Minimum element…

LT and RT

Struct of Binary tree node

Height of a binary tree

Copy tree

Subtree names

Template <class elemType>... {... elemType info;... Struct binaryTreeNo…

Count the nodes from the root to the lowest child

Shallow Copy of binary tree

LT and RT

Subtree names

Struct of Binary tree node

Template <class elemType>... {... elemType info;... Struct binaryTreeNo…

public class BinaryTree<E> {

BinaryTree(){

BinaryTree(E item){

BinaryTree(E item, BinaryTree<E> left,…

protected E data;... protected BinaryTree<E> left,right;

data = null;... left = right = null;... }

data = item;... left = new BinaryTree<E>();... right = new BinaryT…

data = item;... this.left = left;... this.right = right;... }

public class BinaryTree<E> {

protected E data;... protected BinaryTree<E> left,right;

BinaryTree(){

data = null;... left = right = null;... }

Binary Tree

Root

Left subtree

Right subtree

Finite set of nodes that is either empty and consists of a roo…

The first node in a binary tree which contains two trees linke…

A subtree on the left of its parent and has to be less than or…

A subtree that is larger than its parent tree.

Binary Tree

Finite set of nodes that is either empty and consists of a roo…

Root

The first node in a binary tree which contains two trees linke…

Binary Search Tree

Root

Smaller

Larger

(what) are linked structures that are designed to address some…

The BST has a (what) node analogous to the head pointer in a l…

Data in the BST is ordered such that the data in all children…

Data in the BST is ordered such that the data in all children…

Binary Search Tree

(what) are linked structures that are designed to address some…

Root

The BST has a (what) node analogous to the head pointer in a l…

Tree

Binary Tree and it's major operations

preorder

postorder

empty, or it has a node called the root, followed by zero or m…

preorder, inorder, postorder, level-order, height, and Size (n…

left child, root, right child

children, then root

Tree

empty, or it has a node called the root, followed by zero or m…

Binary Tree and it's major operations

preorder, inorder, postorder, level-order, height, and Size (n…

binary trees

binary search trees

binary search trees time complexity

binary tree node

a nonlinear linked data structure in which each node may point…

binary tree whose data is ordered to simplify searches... search…

worst: O(n)... average: O(log2(n))... time slows down- searching fo…

holds:... 1. the data (value field)... 2. a pointer to its left chil…

binary trees

a nonlinear linked data structure in which each node may point…

binary search trees

binary tree whose data is ordered to simplify searches... search…

root

children

leaf

subtree

The first node in a binary tree is called the _______.

A binary tree node's left and right pointers point to the node…

A node with no children is called a(n) _____.

A(n) _______ is an entire branch of the tree, from one particu…

root

The first node in a binary tree is called the _______.

children

A binary tree node's left and right pointers point to the node…

Binary Tree

Internal Nodes vs. Leafs

Full Tree

Complete Tree

-Made up of Nodes... -Nodes root together to form subtrees

-Internal Nodes have node children... -Leafs have no node children

each node is internal w/ 2 children or leaf

All levels except d-1 are full

Binary Tree

-Made up of Nodes... -Nodes root together to form subtrees

Internal Nodes vs. Leafs

-Internal Nodes have node children... -Leafs have no node children

B. binary search tree

A. length

B. depth

C. height

A __________ (with no duplicate elements) has the property tha…

The ________ of a path is the number of the edges in the path.

The _______ of a node is the length of the path from the root…

The _______ of a nonempty tree is the length of the path from…

B. binary search tree

A __________ (with no duplicate elements) has the property tha…

A. length

The ________ of a path is the number of the edges in the path.

Tree

Nodes

edges

hierarchical structure

structure consist of nodes and edges that organize data in a h…

where the data elements are stored

connects the nodes represents the relationship between the nod…

resembles an upside down tree complete with branches leaves an…

Tree

structure consist of nodes and edges that organize data in a h…

Nodes

where the data elements are stored

The element at the top of the hierarchy…

Elements after a root node in the hiera…

Elements after a child node in the hier…

Nodes that have no children are _______…

root

children

grandchildren

leaves

The element at the top of the hierarchy…

root

Elements after a root node in the hiera…

children

False

root pointer

True

nodes in a binary tree have two success…

True/False: The number of nodes in a binary tree is the number…

The ________ in a binary tree is analogous to the head pointer…

True/False: A subtree is the collection of some node, together…

The main difference between a binary tree and a linked list is…

False

True/False: The number of nodes in a binary tree is the number…

root pointer

The ________ in a binary tree is analogous to the head pointer…

Advantage over Hash tables

How to represent an ordered map

Ordered map: Advantages = access

Ordered map: Disadvantages = insertions…

Hash tables are fast (on average) and quite useful, but they h…

Two obvious choices are a sorted array (or arraylist) and a so…

Either representation will implement the operations (firstEntr…

Unfortunately, put and remove are O(n) time, because you need…

Advantage over Hash tables

Hash tables are fast (on average) and quite useful, but they h…

How to represent an ordered map

Two obvious choices are a sorted array (or arraylist) and a so…

BST Operations:

Preorder Traversal:

Inorder Traversal:

Postorder Traversal:

contains... get... remove... add... reset... getNext... isEmpty... size

Root then Left then Right

Left then Root then Right

Left then Right then Root

BST Operations:

contains... get... remove... add... reset... getNext... isEmpty... size

Preorder Traversal:

Root then Left then Right

What kind of search is swift built-in f…

What's the performance of binary search?

What's the downside of binary search?

What is the key property of binary sear…

In Swift, .indexOf() is linear search.

O(logn)

The array needs to be sorted.

Sorted. Left child always smaller than right child.

What kind of search is swift built-in f…

In Swift, .indexOf() is linear search.

What's the performance of binary search?

O(logn)

Binary Tree

Children

Complete Tree

Full Tree

A data structure that consists of nodes, with one root node at…

The term used in binary trees to indicate a node that extends…

A binary tree in which there are no missing nodes when looking…

A binary tree in which every level of the tree is completely f…

Binary Tree

A data structure that consists of nodes, with one root node at…

Children

The term used in binary trees to indicate a node that extends…

There are n nodes in a tree. How many e…

Run time for in order tree walk

Describe in order tree walk

Run time for tree search

n-1

theta(n). Every node is traversed once.

Print left subtree, node, and right subtree

order(h), where log(n) <= h <= n

There are n nodes in a tree. How many e…

n-1

Run time for in order tree walk

theta(n). Every node is traversed once.