Question Detail: When implementing a dictionary (‘I want to look up customer data by their customer IDs’), the typical data structures used are hash tables and binary search trees. I know for instance that the C++ STL library implements dictionaries (they Read More …
Category: Uncategorized
Floyd’s Cycle detection algorithm | Determining the starting point of cycle
Question Detail: I am seeking help understanding Floyd’s cycle detection algorithm. I have gone through the explanation on wikipedia (http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare) I can see how the algorithm detects cycle in O(n) time. However, I am unable to visualise the fact that once Read More …
Find the longest path from root to leaf in a tree
Question Detail: I have a tree (in the graph theory sense), such as the following example: This is a directed tree with one starting node (the root) and many ending nodes (the leaves). Each of the edge has a length assigned Read More …
How are statistics being applied in computer science to evaluate accuracy in research claims?
Question Detail: I have noticed in my short academic life that many published papers in our area sometimes do not have much rigor regarding statistics. This is not just an assumption; I have heard professors say the same. For example, in Read More …
How does one know which notation of time complexity analysis to use?
Question Detail: In most introductory algorithm classes, notations like $O$ (Big O) and $Theta$ are introduced, and a student would typically learn to use one of these to find the time complexity. However, there are other notations, such as $o$, $Omega$ Read More …
How do O and Ω relate to worst and best case?
Question Detail: Today we discussed in a lecture a very simple algorithm for finding an element in a sorted array using binary search. We were asked to determine its asymptotic compelxity for an array of $n$ elements. My idea was, that Read More …
Detecting cycles in undirected graph
Question Detail: I want to detect cycles in an undirected graph such that I get a list of all edges/vertices which form each cycle. For a graph G({a,b,c,d}, {a-b, b-c, c-d, d-a, b-d}) this would be {a, b, c, d}, {a, Read More …
Is a push-down automaton with two stacks equivalent to a turing machine?
Question Detail: In this answer it is mentioned A regular language can be recognized by a finite automaton. A context-free language requires a stack, and a context sensitive language requires two stacks (which is equivalent to saying it requires a full Read More …
Why is binary search faster than ternary search?
Question Detail: Searching an array of $N$ elements using binary search takes, in the worst case $log_2 N$ iterations because, at each step we trim half of our search space. If, instead, we used ‘ternary search’, we’d cut away two-thirds of Read More …
Why does Dijkstra’s algorithm fail on a negative weighted graphs?
Question Detail: I know this is probably very basic, I just can’t wrap my head around it. We recently studied about Dijkstra’s algorithm for finding the shortest path between two vertices on a weighted graph. My professor said this algorithm will Read More …