Posts

Showing posts from February, 2025

CST 370 - Module 7

 Week 7  This module's material covers different algorithms for solving problems with graphs, and sorting. For instance, we were introduced to non-comparison sorting such as the Counting Sort or Distribution Counting Sort, where we calculate the frequency of each value of a given list and determine distribution values via the sums of frequencies. What is interesting about Counting Sort is the fact that is stable, or the numbers with the same values stay in the same order as they do in the given list.  A technique introduced was Dynamic Programming. One problem about using a brute force technique is that sometimes, we would use a recursive function, which depending on the problem we want to solve, can induce too many overlapped functions. Dynamic Programming will allow us to avoid this by using an array to keep solutions of sub-problems. When the solutions to the sub-problems are recorded in the array, we solve the original problem with that array. The next two algorithms ...

CST 370 - Module 6

 Week 6, This week's module covered more material on tree structures. We previously talked about binary search trees, however, a problem with that is that it can become unbalanced, making the operation take linear time. To solve this problem, we just make sure we keep the binary search tree balanced. To do this, we make use of an AVL Tree, where we keep track of the levels below each node. In short, (and probably with lack of detail) we keep the number of children to each node equal from one side to the other as much as possible, within a difference of 1. If any of the nodes are unbalanced, we rotate the node with the first violation with its children, either left or right. Another way of keeping a tree balanced is by using a 2-3 tree. Using a 2-3 tree is different from your usual tree as each node can contain either 1 or 2 values, and either 2 or 3 children. You insert values in a binary fashion. However, if you insert a third value into a node, the value between moves to the pare...

CST 370 - Module 5

 Week 5, This module's material covered some more algorithms using divide and conquer. One of these algorithms is the quicksort algorithm. The goal of quicksort is to partition the array into two subarrays around a pivot. From there, we recursively sort the two subarrays, then combine the results. The Big Oh notation for quicksort is O(n*log(n)), which is similar to merge sort, however, when dealing with large sorting operations, quicksort beats merge sort by a small margin.  Next, we talk about a divide and conquer ready data structure called a binary tree. Data is usually inserted to the left or the right of a root node, typically by smaller numbers to the left of the node, and greater numbers to the right. This continues further and further down the tree creating what could be describe as... well... a tree. The main problem with using this data structure is how to traverse the binary tree. In short (got to leave some room for you to research), we talk about three methods, p...