Solving Problems With Graphs
Can we find a graphical representation of gallons lost to the leak from the basin over time?
Can we determine how long it will take before the basin is halfway empty?
First thing’s first, try to implement Breadth-First Search and Depth-First Search, respectively, on a graph.
These are, arguably, the most important graph algorithms, since a ton of graph algorithms are just modified versions of these.
After you’ve implemented those, you can try your hand at a few simple problems.Let's take the function y=x As we see, these x and y-values match those given for the points above.Furthermore, we can now be certain that two such points exist at (-1, 1) and (-3, 9).If given enough points for an unknown function in an xy-plane, we can plot the points and make a line through them to aid in figuring out other points in this unknown function.If provided with enough points, we can also infer an equation of the function (keeping in mind that this unknown function may or may not be linear).We can make y = gallons lost to leak over time and x = to time in hours. By merely plugging points into y and solving for corresponding x-values, we find that the basin is completely emptied at x = 25 hrs.In other words, after precisely 25 hours elapsing, the oil in the basin is completely emptied -having lost 30 gallons. This will yield our intersection point (or positive-root) at x = 2.39.Can we determine how long it will be before it is completely emptied?It might be helpful to develop a function to represent these gallons lost in basin to the leak over time.In the very least, we might see if the line drawn through these points corresponds with any familiar functions.At first glance, the graph above appears to be of a parabolic function.