Briefly discuss how the color rules help with balancing the tree (write a bit about 2-4 trees). Compare the performance of this red black tree to a random binary search tree or treap. The four color rules of the red-black tree help the tree maintain a structure that is balanced. To understand more on red-blackContinue reading “Red-Black Trees”
Category Archives: Computer Science
A*
What difference is there between the A* algorithm and Dijkstra’s algorithm? (in terms of nodes explored) The difference between A* and Dijkstra’s algorithm in terms of nodes explored is that A* is less greedy and has a more educated guess h, the heuristic functions that helps us lessen the nodes explored. In Dijkstra’s, as itContinue reading “A*”
Random Trees
When would you use a binary search tree over a treap? I think I would use a binary search tree over a treap in terms of complexity in implementation. Binary search trees are simpler. However, practical-wise, I would use a binary search three if I have a set of numbers that are sorted randomly becauseContinue reading “Random Trees”
Heaps
Experiment with larger inputs; what can you observe from the number of swaps performed? With larger inputs, there will be more swaps performed, especially if the inputs are not sorted and are randomized. There will more bubble up and trickle down operations performed. However, if there will be less outputs, like what we have inContinue reading “Heaps”
Minimum Spanning Tree
Briefly discuss how calculating for an MST could be useful. Calculating for a minimum spanning tree (MST) is useful when we want to minimize cost / weight of nodes that are connected multiple points of each other. One application of this is when we want to construct roads that have multiple points, we want toContinue reading “Minimum Spanning Tree”
Graphs
Discuss how you relate a string vertex to an integer internally. Discuss how you relate a string vertex to an integer internally. (hint: USet) In python, there are what we call dictionaries, much like in hash tables, where we link a certain key to a value. This implementation of the adjacency list that I haveContinue reading “Graphs”
Tree-Walker
Talk about the different traversals you’ve done in your code; illustrate with a diagram, if you have to. There are three traversals I’ve done in my code. They are pre-order, in-order, and post-order. The three are kinds of depth-first traversals. They traverse the binary tree recursively. We’ll be using this binary tree below as anContinue reading “Tree-Walker”
Hash Tables
Do you think you could create a better hash function? I do think I could create a better and simpler hash function. However, I would need to think much with different mathematical equations and other things that would change one input to another form. Just like what we did with Horner’s Rule hash function. IContinue reading “Hash Tables”
Linked List
First of all, LinkedList was relatively harder to implement rather the ArrayDeque. This is because I had to keep track of the head, the tail, the size and all of the nodes using LinkedList. I was using more lines of code in LinkedList. As simple as adding in the first index, it was quite aContinue reading “Linked List”
Array Deque
Implementing an ArrayDeque wasn’t hard nor easy – it just required work. For me, I had to review once again what’s the abstract data type ArrayDeque and how basing on how it functions, I got an idea how to implement it. Coding it, was the challenging part. It was “How do I translate what IContinue reading “Array Deque”