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 …
Category: Uncategorized
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 …
Why does this automation accept the empty string?
Problem Detail: I am new to Automata Theory. I am studying the book thoroughly and understanding it well. I have got a confusion regarding NFA. Why does this automaton accept the empty string λ? What I think is that: implicitly δ(q,λ)=q Read More …
What’s Big O of $log(n+7)^{log(n)}$?
Problem Detail: As part of my continual improvement plans, I’m reviewing algorithm analysis and I’ve hit a roadblock. I cannot figure out how to determine the Big O complexity of $log(n+7)^{log(n)}$. I’ve spent the last few days rolling this over in Read More …
Complexity analysis of while loop with two conditions
Problem Detail: I am curious how to do a line by line analysis of this piece of code using the “Big O” notation. i = 0; j = 0; while ( ( i < n ) && ( j < m Read More …
Easy proof for context-free languages being closed under cyclic shift
Problem Detail: The cyclic shift (also called rotation or conjugation) of a language $L$ is defined as ${ yx mid xy in L }$. According to wikipedia (and here) the context-free languages are closed under this operation, with references to papers Read More …
Line separates two sets of points
Problem Detail: If there is a way to identify if two sets of points can be separated by a line? We have two sets of points $A$ and $B$ if there is a line that separates $A$ and $B$ such that Read More …
Guessing the smallest unique positive integer
Problem Detail: Let us consider the following game: there are some players and a computer. Each player inputs one positive integer and his name (player doesn’t know another’s numbers, just his own). When all the players made their moves, computer outputs Read More …