Document Details

HonestIrony1328

Uploaded by HonestIrony1328

Ayala National High School

Tags

binary trees data structures algorithms computer science

Summary

This document is a collection of review material on data structures, specifically binary trees, heaps, and binary search trees. It covers definitions, properties, and operations of these structures. It also details various applications and time complexities.

Full Transcript

Review Material Which of the following is true about a binary tree? - Each node can have up to two children A general tree is defined as: - A tree with an arbitrary number of children per node. In a binary tree, what is the height of an empty tree? - -1 The degree of a node in a tree is defined...

Review Material Which of the following is true about a binary tree? - Each node can have up to two children A general tree is defined as: - A tree with an arbitrary number of children per node. In a binary tree, what is the height of an empty tree? - -1 The degree of a node in a tree is defined as: - The number of its children nodes. Which of the following is NOT an application of binary trees? - Storing relational data Huffman coding uses which type of tree? - Binary tree Decision trees are mainly used for: - Machine learning The operation of finding the height of a general tree can be performed by: - Iterative traversal & Recursive traversal. To count the total number of nodes in a general tree, which traversal can be used? – Any type of Traversal In a binary tree, the traversal order “Left, Root, Right” is called: - Inorder Deleting a node in a binary tree involves: - Replacing the node with its inorder successor or predecessor. Which traversal would you use to print the leaves of a binary tree first? – Postorder In a pointer-based binary tree ADT implementation, the primary components of a node are: - Data and left/right child pointers. What is the time complexity of inserting an element into a binary tree? – O(n) A Binary Search Tree (BST) satisfies which property? - Left subtree contains nodes with keys less than the root & Right subtree contains nodes with keys greater than the root Which of the following is a real-world application of BSTs? - Database indexing Searching for an element in a balanced BST has a time complexity of: - O(log n) Which traversal order would produce a sorted sequence of elements in a BST? – Inorder To delete a node with two children in a BST: - Replace it with its inorder successor or predecessor. In a pointer-based implementation of a BST, which operation is crucial for insertion? - Recursively comparing the key to find the correct position. An expression tree evaluates: - Numerical operations & Logical operations Decision trees are used in: - Decision-making in AI. A MaxHeap stores the maximum element at: - The root. Which of the following is true about heaps? - They must be complete binary trees. The main difference between heaps and BSTs is: - Heaps are unordered while BSTs are ordered. - Heaps always have a complete structure. - BSTs can be unbalanced, while heaps cannot. To restore the heap property after insertion, we use: - Percolate up The time complexity of extracting the maximum element from a MaxHeap is: - O(log n) Which statement is true about MinHeaps? - Root has the smallest value & All leaves have larger values than the root The formula to find the parent of a node in a heap stored as an array is: - (i - 1) / 2 Which operation can be optimized using heap properties? - Sorting an array A heap can be represented as: - A complete binary tree The minimum number of nodes in a heap of height h is: - 2^(h-1) The advantage of heaps over BSTs is: - Predictable structure & Easy insertion and deletion What is the purpose of heapify: - To build a heap from an array To remove the largest element from a MaxHeap, the process involves: - Removing the root and reheapifying Which operation is more efficient in a heap compared to an array? - Inserting a new element What ensures that a MinHeap has the smallest element at the root? - The heap property In a heap array, the index of the left child of a node at index i is: - 2i + 1 The main advantage of implementing a heap using an array is: - Compact storage without pointers What is the time complexity of building a heap from an unsorted array? - O(n)

Use Quizgecko on...
Browser
Browser