shivkalra1
BAN USER
Questions (1)
Comments (4)
Reputation 20
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
recursive:
rev(node* c, node *n)
{
if n== null
return;
rev(n, c->next);
n->next = c;
}
complexity => O(n)
- shivkalra1 December 19, 2013Comment hidden because of low score. Click to expand.
0
of 0 vote
2^n exponential..since at every 2n places there are 2 choices to be made.
- shivkalra1 December 03, 2013Comment hidden because of low score. Click to expand.
0
of 0 vote
Python code below:
def R(n, buf=''):
if len(buf) == 2*N:
print buf
if n > 0:
buf += ')'
R(n-1, buf)
buf=buf[:-1]
if 2*N - (n+len(buf)) >= 2:
buf += '('
R(n+1, buf)
buf=buf[:-1]
N = 4
R(0)
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- shivkalra1 December 19, 2013