supratim.sengupta
BAN USERpublic int NewFibo(int cnt, int n1, int n2, int sum)
{
sum+=n1;
if (cnt == 1)
{
return sum;
}
else {
return NewFibo(--cnt, n2, (n1 + n2),sum);
}
}
// you can call this function like this NewFibo(5,0,1,0)
Traverse each node using BFS
If CurrentNode.HasChildren() == false then // leaf node
Add_Node_To_Array_After_Level_Check(CurrentNode)
End If
Print all elements in the NodeList as they have a level difference more than 1
function Add_Node_To_Array_After_Level_Check(Node)
{
for(index = NodeList.Length-1 to 0)
{
if(Node.Level - NodeList[index].Level>1)
{
NodeList.Add(Node);
break;
}
}
}
- supratim.sengupta October 29, 2012for(index=1;index<=n;index++)
{
index_of_nth_largest = getIndexOfNthLaargest(index);
if(i==0)
{
reverseArray(index_of_nth_largest);
}
else
{
reverseArray(index_of_nth_largest-1);
reverseArray(index_of_nth_largest);
}
}
- supratim.sengupta October 29, 2012
Take 2 arrays at a time
- supratim.sengupta November 09, 2012merge them
perform quicksort on them
space complexity remains o(n) and worst case time complexity will be o(n^2) avg case time complexity will be O(n log n)