Does binary search have any similarities compared to heaps? Both Binary – at most 2 children Comparison – max heap parent>children, BST leftnode Heap is balanced (almost complete ) BST unbalanced(we cannot control) maxHeap – max at root, BST Max is rightmost nonNone child max heap min hard to find, BST min leftmost nonNone child heap – hard to find an individual value, BST easy

Linkedlist? Instead of a linear connection of pointers, there are tree pointers (left and right child)

Will binary tree search works if the values on the left subtrees are greater than and less than on the right subtrees? No, BST are defined as go left for smaller go right for bigger

Does binary tree search have a certain type of order it follows like stacks and queue? Stacks (one end access) queues (both end access) are different from BST (any item access)

For a BST can you do it as a with nodes, that point to left and right, and is it any more efficient or take up less memory? Yes BST use left and right pointer nodes, there is not another way

Again for BST is it primarily used for just searching since it’s easy to go through maxes and mins? Or is it also used for other things? Dictionary operations – add, delete, search, max, min, iterate. All just as fast as linked list (if BST balanced, faster than linked list)

For the searches at the end, it may need to also look at other branches I assume since it cants just look it the greater or less than of the current branch it’s on, what if the number falls under the min of one branch, and max of other? Not founds end on None, if found it must be on the search path

With heaps, I saw online that they are called binary trees? I understand since it is in a tree structure with roots and child nodes it is called a tree but why binary? Heaps are almost complete binary trees. The binary helps us get lgN height. Heaps are usually implemented with an array an index arithmetic to get to left and right child, or back up to parent (instead of using pointers)

When would it be more appropriate to use a Queue instead of a Stack structure in an algorithm? FIFO or LIFO

What is under the hood for Pythons hash function? Calculate has based on the value being hashed and its location in memory

With recursion it's easy to get into an infinite loop, so how would we work in a function that ends the loop if the runtime is too long? setrecursionlimit()

When it comes to problems that require testing every possibility, it sounds like a lot of brute force and long run times. For large data sets, are there some common advanced techniques to reduce that runtime even when we're still required to test every case? I'm talking like in our change example, reducing which numbers we can use by initially using modulus and so on. You would not test every case, there may be infinite possibilities.

If we were to use recursion to move through a doubly linked list, would we be able to pass the current node positions as parameters? yes

Unrelated to recursion, but just something I've noticed compared to other languages, is there a reason why there are no two dimensional nxm arrays formatted like list(n,m)? The only examples I've seen are lists of lists, like list(n(m)) which seems to be a little more complicated. Just a syntax preference, in python a 2D array is a list of lists. You do access positions using a[row][col]

How BS tree is different from heaps? How is a BS Tree different from the Heaps we worked with previously? They seem to organize their data very similarly BST(go left smaller, go right bigger) – good for searching Heap (parent > children) – good for find max If both are similar how different is the time complexity of BS tree and heaps? BSTs not necessarily balanced, Heaps are O(lg n)

What are some of the real world uses of BS tree? Dictionary operations – add, delete, search, max, min, iterate.

Can we use stacks for programming BS trees? If so how does it work? Instead of recursion, use a loop with a stack

Are there tree structures with more that 2 children? If so, would they be more efficient than a binary tree? Yes ternary, quandary, etc. but more complex programming if balanced, height is O(lg3n) O(lg4n) etc

Is it required to handle binary trees recursively? Or can we use a normal loop to handle them? Recursion is not required, there are iteration approaches (some will need a stack, like inorder traversal)

How would the min/max be found for a binary tree that isn't balanced. (Ex: 12 => (9,15). 9 => (3,6). 6 => 1) Here's a pic that might explain it better.

Not a valid BST

For this tree, why wouldn't it be easier for 2 to be the successor?

Successor is defined as next largest item

Can a contain negative values? Yes, the value can be anything that is comparable

Do balanced trees provide better method performance than unbalanced trees? Yes, we will see AVL O(lgn). BST O(height) but the height may be n

When is it desirable to use a BS Tree over a Heap? Is one generally better than the other in terms of runtime or ease of use? Different functions. BST for looking up items, Heap for max

Are BS Trees backed by a list or are they more like a linked list with each node being able to connect to 2 links instead of 1? Or are they something entirely different? Pointers, left and right child. Not a python List

How do you check if a binary tree is balanced or not? We will see with AVL trees

When would you use a over a hash‐table . BST memory efficient, Hashtable not always. BST allow range searches efficiently. BST traversal easier (regular is not in any order)

Is it possible to create an AVL tree with any given of numbers Yes, anything comparable

Is there a method for how to add each binary tree position consecutively, or does it not matter as long as the lower left, higher right trend is followed? You must follow this lower left, higher right. But we do not know if it will be balanced

How does this sorting system reflect on sorting times and considering the (key, value) tree format in binary search trees? Build O(nlgn) AT BEST, inorder traversal O(n)

If you were trying to add a value to a binary tree and it turns out that the value was already in the binary tree, what happens then? Are duplicates allowed in binary trees or is it just never added? How does python treat multiple same‐key entries for search trees? Replace or store duplicates in a list at the node, or allow duplicates (< left >= right make methods more complex)

Is it possible to convert a binary search tree to a double linked list? You will lose the O(height) runtime for methods, everything would be O(n)

Why is it so important to balance a binary search tree? I know it has to do with it's runtime but I'm confused as to how balancing affects the runtime. O(height) runtime for methods, if balanced height = lg(n) Lg(n) <= BSTheight <=n

What is the difference between a complete and a full binary tree? Could you possibly provide a visual reference to their difference? Full – every level full complete – all levels full except maybe the last level Almost complete – last level filled left to right

Is it possible to construct a binary search tree iteratively, with no recursive methods? If so, what are the time‐complexities between the two (recursive and iterative)? Some methods can be easily done with iteration, others need iteration and a stack or very complex iteration. Same runtimes

How are the performances of the put, get, in and del methods limited by the height of the tree? Worst case you need to go to a leaf node from the root. In a BST the height of tree is between n and lg n

It was mentioned in class that anything done recursively could be done iteratively NOT TRUE, how is the determination made. Other way around, anything done iteratively can be done recursively. Just convert the loop to a recursive call with base case catching the loop termination control

Assuming a list and a bs tree have the same elements would searching for an element be faster using a bs tree? Depends on height of BST, in general BST will be no worse than list. However if prob of searching for an items is not equally likely (skewed), the expected search time on a list may be faster)