rajdeeps.iitb
BAN USERI thought of this approach initially and found bug.
try with this example
{10, -3, -4, 7, 6, 5, -4, -1}
Cadene's Algo
- rajdeeps.iitb October 08, 2013The best approach I can think of is having o(n2) time and o(n) space complexity
- rajdeeps.iitb September 02, 2013I think minimum extra space required is o(mn)
- rajdeeps.iitb August 25, 2013//leftChild(i)=2*i,rightChild(i)=2*i+1,i starts from 1
void printInorderOfCompleteBinTreeFromLevelOrder(int[] levelOrder)
{
int[] arr=new int[levelOrder.length+1];
Stack<Node1> stk=new Stack<Node1>();
for(int i=0;i<levelOrder.length;i++)
{
arr[1+i]=levelOrder[i];
}
Node1 node=new Node1();
node.data=arr[1];
node.position=1;
node.childProcessed=false;
stk.push(node);
int leftC=0,rightC=0;
while(stk.size()>0)
{
node=stk.pop();
if(node.childProcessed)
{
System.out.println(".."+node.data);
}
else
{
leftC=node.position*2;
rightC=node.position*2+1;
if(rightC<=arr.length-1)
{
Node1 right=new Node1();
right.data=arr[rightC];
right.position=rightC;
right.childProcessed=false;
stk.push(right);
}
node.childProcessed=true;
stk.push(node);
if(leftC<=arr.length-1)
{
Node1 left=new Node1();
left.data=arr[leftC];
left.position=leftC;
left.childProcessed=false;
stk.push(left);
}
}
}
}
excellent logic EOF
- rajdeeps.iitb August 25, 2013bucket sort is the best option.quicksort would actually take o(nklogn) whre k:avd length of the strings
- rajdeeps.iitb August 23, 2013Dynamic Programming can be used in this scenario.
A B C D
----------------------
A
B
C
D
start filling up from bottom till you get a combination which satisfies the condition
HashMap<Integer,ArrayList<Threads>>
1-->list of un allocated threads
2-->list of allocated threads
tree cant be unique just by levwl order traversal
- rajdeeps.iitb August 13, 2013I think double link list can be a good implementation.copy,paste,search,insert everything can be done.
- rajdeeps.iitb August 10, 2013
sorry try with this
- rajdeeps.iitb October 09, 2013-1, 40, -14, 7, 6, 5, -4, -1