Problem Detail: Can I use breadth-first search for topologicallly sort vertices and finding strongly connected components in a graph? If yes, how can I do that? If not, why? I tried with a simple acyclic graph of 3 vertices, gave the Read More …
Author: ignougroup
Why does the splay tree rotation algorithm take into account both the parent and grandparent node?
Problem Detail: I don’t quite understand why the rotation in the splay tree data structure is taking into account not only the parent of the rating node, but also the grandparent (zig-zag and zig-zig operation). Why would the following not work: Read More …
How many max heaps are there?
Problem Detail: How many different max-heaps can I form using a list of $n$ integers. Example: list [1,2,3,4] and max-heap is 4 3 2 1 or 4 / 3 2 / 1 other possible max-heap is 4 2 3 1 4 Read More …
What data structure would efficiently store integer ranges?
Problem Detail: I need to keep a collection on integers in the range 0 to 65535 so that I can quickly do the following: Insert a new integer Insert a range of contiguous integers Remove an integer Remove all integers below Read More …
Union and intersection of a regular and a non-regular language
Problem Detail: Lets say we have $L_1$, which is a regular language and $L_2$ which is not. Are $L_1 cap L_2$, $L_1 cup L_2$ , $L_1$ $L_2$ and $L_1 cdot L_2$ are always non-regular languages? We know that two regular languages Read More …
What is the purpose of using NIL for representing null nodes?
Problem Detail: In my Algorithms and Data Structures course, professors, slides and the book (Introduction to Algorithms, 3rd edition) have been using the word NIL to denote for example a child of a node (in a tree) that does not exist. Read More …
What is the time complexity of the following program?
Problem Detail: Please help me calculate the time complexity of the following program. int fun (int n) { if (n <= 2) return 1; else return fun(sqrt(n)) + n; } Please explain. There were four choices given. $Theta(n^2)$ $Theta(n log n)$ Read More …
k-ordered array problem
Problem Detail: An array $A[1…n]$ is said to be k-ordered if $$A[i – k] leq A[i] leq A[i + k]$$ for all $i$ such that $k < i leq n – k$. For example, the array $A = [1, 4, Read More …
Finding maximum and minimum of consecutive XOR values
Problem Detail: Given an integer array (maximum size 50000), I have to find the minimum and maximum $X$ such that $X = a_p oplus a_{p+1} oplus dots oplus a_q$ for some $p$, $q$ with $p leq q$. I have tried this Read More …
Finding the grammar type of the programming language
Problem Detail: How can someone find what type of grammar for a given programming language? Formerly I’m looking for a grammar type for most popular programming languages: C, C++, C#, Java, List, OCaml, Haskell etc. Asked By : m0nhawk Answered By : Gilles Read More …