Trees (OCR A-Level Computer Science): Flashcards

📚Flashcards
Trees
Sign up to keep revising.Create a free account to study more flashcards and track your progress.

Practise the cards

15 cards from this deck

Show

Tree data structure

Hierarchical structure consisting of nodes

Root node

Topmost node in tree

Leaf node

Node with no children

Binary tree

Each node has at most two children (left and right)

Binary Search Tree (BST) property

Left child < parent, right child > parent

BST time complexity (balanced)

O(logn)O(\log n)

Array tree: left child of index ii

2i+12*i + 1

Array tree: right child of index ii

2i+22*i + 2

Post-order traversal order

Left subtree → Right subtree → Root

Breadth-first traversal

Level by level, left to right

Adding node to BST process

Start at root, traverse left if smaller/right if larger, insert at leaf

Removing BST node with no children

Remove it directly

Removing BST node with one child

Replace it with its child

Removing BST node with two children

Replace with in-order successor (smallest in right subtree)

Unbalanced BST performance

Degrades to O(n)O(n)

Explore OCR A-Level Computer Science Revision Notes by Topics

Explore OCR A-Level Computer Science Model Answers by Topics

Explore OCR A-Level Computer Science Quizzes by Topics

Explore OCR A-Level Computer Science Exam Questions by Topics

Join 100,000+ A-Level students studying Flashcards with us.

Select your subjects, and get access to A+ resources today.