BINARY TREE

Ace your homework & exams now with Quizwiz!

- Every level must be completely filled - All the leaf elements must lean towards the left. - The last leaf element might not have a right sibling i.e. a complete binary tree doesn't have to be a full binary tree.

three major differences of a complete binary tree to a full binary tree

Height

· the distance from that node to the deepest node of that subtree.

Depth

· the distance from the root node to that particular node.

Height of the tree

· the maximum height of any node. This is same as the height of root node

Root

· the topmost node of the tree that has no parent node. There is only one root node in every tree.

Subtree

· the tree considering that particular node as the root node.

tree

- a popular data structure that is non-linear in nature. - represents a hierarchical structure. - contains nodes and 2 pointers. These two pointers are the left child and the right child of the parent node.

Perfect Binary Tree

- all the internal nodes have two children and all leaf nodes are at the same level. - every internal node has exactly two child nodes and all the leaf nodes are at the same level.

Full Binary Tree

- if every node has 0 or 2 children. - all nodes except leaf nodes have two children. - every parent node/internal node has either two or no children. -It is also known as a proper binary tree.

pointer

A Binary tree is represented by a _________ to the topmost node of the tree.

2h+1 - 1 node

A Perfect Binary Tree of height h (where the height of the binary tree is the number of edges in the longest path from the root node to any leaf node in the tree, height of root node is 0) has ____________.

Leaf

A node that has no child It is the last node of the tree.

· Finding the height of the tree · Find the level of the tree · Finding the size of the entire tree.

Auxiliary Operation On Binary Tree:

· Inserting an element. · Removing an element. · Searching for an element. · Traversing an element.

Basic Operation On Binary Tree:

· Data · Pointer to left child Pointer to right child

Binary Tree node contains the following parts:

Binary Tree

defined as a Tree data structure with at most 2 children. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.

Complete Binary Tree

if all the levels are completely filled except possibly the last level and the last level has all keys as left as possible.

null

If the tree is empty, then the value of the root is ____.

1. Manipulate hierarchical data. 2. Make information easy to search (see tree traversal). 3. Manipulate sorted lists of data. 4. As a workflow for compositing digital images for visual effects. 5. Router algorithms 6. Form of multi-stage decision-making (see business chess).

Main applications of trees include:

- store information that naturally forms a hierarchy - provide moderate access/search - provide moderate insertion/deletion - don't have an upper limit on the number of nodes as nodes are linked using pointers.

reasons to use trees:

Edge

acts as a link between the parent node and the child node.


Related study sets

Business Finance Chapter 6 Learnsmart

View Set

APUSH ch 12 quiz, APUSH Ch 13 quiz, APUSH Ch 14 quiz, APUSH ch 15 quiz

View Set

Autonomic Dysreflexia - Hyperreflexia

View Set