Binary Search Trees

RefinedBowenite avatar
RefinedBowenite
·
·
Download

Start Quiz

Study Flashcards

Questions and Answers

Which of the following is a common property checked while using loop invariants to prove correctness?

Initialization

In a complete binary tree, how are the nodes filled?

Left to right

What is the worst-case time complexity of Quicksort?

O(n^2)

Which of the following functions is O(n^2)?

<p>f(n) = 2n^2 + 3n + 1</p> Signup and view all the answers

Which of the following statements about Binary Search Trees (BST) is true?

<p>C. They always provide O(log n) performance for totally sorted data.</p> Signup and view all the answers

What is the primary difference between a Binary Tree and a Binary Search Tree (BST)?

<p>B. In BST, all nodes in the left subtree are less than the root, and all nodes in the right subtree are greater than the root.</p> Signup and view all the answers

What is the height of a valid Binary Search Tree (BST) with 7 nodes, built with totally sorted data?

<p>B. 6</p> Signup and view all the answers

Which of the following trees is a self-balancing tree?

<p>AVL Tree</p> Signup and view all the answers

Which of the following statements about O-notation is true?

<p>O-notation provides an upper bound on the growth rate of a function.</p> Signup and view all the answers

What is the key subroutine in the Quicksort algorithm?

<p>Partition</p> Signup and view all the answers

In Radix Sort, the sorting begins with the digit at which position?

<p>Least significant digit</p> Signup and view all the answers

Which of the following statements about Binary Search Trees (BST) is true?

<p>None of the above.</p> Signup and view all the answers

What is the primary difference between a Binary Tree and a Binary Search Tree (BST)?

<p>In BST, all nodes in the left subtree are less than the root, and all nodes in the right subtree are greater than the root.</p> Signup and view all the answers

What is the height of a valid Binary Search Tree (BST) with 7 nodes, built with totally sorted data?

<p>6</p> Signup and view all the answers

Which of the following traversal methods visits the root node last, followed by the left and right subtrees?

<p>Postorder</p> Signup and view all the answers

What is the time complexity of Quicksort in the best case?

<p>O(n log n)</p> Signup and view all the answers

Which of the following is NOT a characteristic of a Max-Heap?

<p>The value of any node is greater than or equal to the values of its children</p> Signup and view all the answers

Which of the following is the correct formula to calculate the number of nodes in a complete binary tree of height h?

<p>$2^{h+1} - 1$</p> Signup and view all the answers

Which of the following trees is a self-balancing tree?

<p>AVL Tree</p> Signup and view all the answers

Which of the following sorting algorithms is NOT stable?

<p>Heap Sort</p> Signup and view all the answers

What is the time complexity of the BuildMaxHeap procedure?

<p>O(n)</p> Signup and view all the answers

What is the expected time complexity of searching in a randomly built Binary Search Tree (BST)?

<p>O(log n)</p> Signup and view all the answers

Which of the following statements about Binary Search Trees (BST) is true?

<p>D. None of the above.</p> Signup and view all the answers

What is the primary difference between a Binary Tree and a Binary Search Tree (BST)?

<p>B. In BST, all nodes in the left subtree are less than the root, and all nodes in the right subtree are greater than the root.</p> Signup and view all the answers

What is the height of a valid Binary Search Tree (BST) with 7 nodes, built with totally sorted data?

<p>B. 6</p> Signup and view all the answers

Which of the following is a characteristic of a Max-Heap?

<p>The value of the root node is the largest in the heap</p> Signup and view all the answers

What is the time complexity of the BuildMaxHeap procedure?

<p>O(n)</p> Signup and view all the answers

Which of the following statements about O-notation is true?

<p>O-notation represents the worst-case time complexity of an algorithm</p> Signup and view all the answers

In Radix Sort, the sorting begins with the digit at which position?

<p>Least significant digit</p> Signup and view all the answers

Which of the following trees is NOT a self-balancing tree?

<p>Splay Tree</p> Signup and view all the answers

Which of the following statements about O-notation is true?

<p>O-notation provides an upper bound on the growth rate of a function.</p> Signup and view all the answers

What is the FIRST step in the substitution method for solving recurrences?

<p>Guess the form of the solution.</p> Signup and view all the answers

The Master Method is applicable to recurrences of which form?

<p>T(n) = aT(n/b) + f(n)</p> Signup and view all the answers

Which of the following statements about Binary Search Trees (BST) is true?

<p>C. They always provide $O(\log n)$ performance for totally sorted data.</p> Signup and view all the answers

What is the primary difference between a Binary Tree and a Binary Search Tree (BST)?

<p>B. In BST, all nodes in the left subtree are less than the root, and all nodes in the right subtree are greater than the root.</p> Signup and view all the answers

What is the height of a valid Binary Search Tree (BST) with 7 nodes, built with totally sorted data?

<p>B. 6</p> Signup and view all the answers

Which of the following trees is a self-balancing tree?

<p>2-3 Tree</p> Signup and view all the answers

What is the time complexity of Quicksort in the worst case?

<p>O(n^2)</p> Signup and view all the answers

What does it mean for a sorting algorithm to be stable?

<p>It preserves the relative order of equal elements</p> Signup and view all the answers

In a Max-Heap, what is the value of the root node?

<p>Largest in the heap</p> Signup and view all the answers

Which of the following trees is a self-balancing tree?

<p>AVL Tree</p> Signup and view all the answers

Which of the following statements about Binary Search Trees (BST) is true?

<p>BSTs maintain a sorted order of elements.</p> Signup and view all the answers

What is the primary difference between a Binary Tree and a Binary Search Tree (BST)?

<p>Binary Trees can have any order of elements, while BSTs maintain a sorted order.</p> Signup and view all the answers

What is the time complexity of the BuildMaxHeap procedure?

<p>O(n)</p> Signup and view all the answers

Use Quizgecko on...
Browser
Browser