Binary Search Flashcards

1
Q

Hints of BS:

A

Sorted and target makes it directly Binary Search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the raw binary search algorithm?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is binary search called?

A

half-interval search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is binary search?

A

It is an algorithm used to find the position of a value in a sorted array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does BS work?

A

the list is split in half and then searched in each half. The list must be sorted before running the algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What loop is must in binary search?

A

While loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Binary search while loop format

A

while left<=right; return the formula

then make the if statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is inorder traversal?

A
  1. Traverse the left subtree
  2. Visit the root.
  3. Traverse the right subtree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Does traversing by inorder traversal, and the elements being in the true order means the tree is actually in order?

A

IDK yet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens if the binary search tree has duplicate elements?

A

It must be on the left side if it is allowed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

flip the logic of BST

A

Validate the left tree node’s value to make sure that it is less than the current root value(the roots change every node)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

BST recursive function with (min,max) range

A

initially, the range is infinite. At left side, the min is negative infinity and the max is root.value. The recursive function needs to be implemented and properly adjusted the ranges as traversed through the tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly