k.krishnakarthik
BAN USERMaintain tree like with argumented information which stores the information whether the node is locked or not ,while searching for a node in the given tree in recursive way if a node is locked , traverse back and update all the ancestors are locked. This can be done in log n time i think.
- k.krishnakarthik July 29, 2010I think while finding convex hull we generate such kind of line to partition the points can we use that approach?
- k.krishnakarthik July 28, 2010I think while finding convex hull we generate such kind of line to partition the points can we use that approach?
- k.krishnakarthik July 28, 2010Program Invoked like columnSum(root, columnSum[] , rootNode Position);
ColumnSum[] is array which stores the sum of the data in each column
public void columnSum(Node currNode ,int a[] ,int collevel){
if(currNode!=null){
a[collevel] = a[collevel]+currNode.getNodeData();
if(currNode.getLeftPointer()!=null){
columnSum(currNode.getLeftPointer(), a, collevel-1);
}
if(currNode.getRightPointer()!=null){
columnSum(currNode.getRightPointer(), a, collevel+1);
}
}
}
Check For Back edges while doing a DFS , Back Edges can be find out if a edge is pointing to a vertex which is Grey in the travesal of DFS.
- k.krishnakarthik July 28, 2010Congrats Nishant :)
- k.krishnakarthik July 28, 2010Code Invoked as below
bt.NLargestFromEnd(root, N, 0);
I did the In order but in reverse order right data and left.
public int NLargestFromEnd(Node x,int N,int count ) {
//System.out.println("inorder");
if (x != null) {
count = NLargestFromEnd(x.getRightPointer(),N,count);
count = count+1;
if(count ==N){
System.out.println("N Largest Node from End is"+x.getNodeData());
}
count = NLargestFromEnd(x.getLeftPointer(),N,count);
}
return count;
}
what would happen when a digit exceeds more than 10 times for example , if 1 runs for 12 times then we represent it as 112 , how can we decode it ?Is there a limit on number of times a character can occur ?
- k.krishnakarthik July 22, 2010how about calculating the height and using the formula n*n+1/2 to calculate sum .
public int heightOfTee(Node x) {
int h1 = 0, h2 = 0;
if (x == null) {
return 0;
}
if (null != x.getLeftPointer()) {
h1 = heightOfTee(x.getLeftPointer());
}
if (null != x.getRightPointer()) {
h2 = heightOfTee(x.getRightPointer());
}
return ((h1 > h2) ? h1 + 1 : h2 + 1);
}
This Problem can be solved by representing the all the rectangle co-ordinates in the form of "Augmenting Height Balanced Trees" and finding the intersections by moving a sweep line across.
- k.krishnakarthik July 21, 2010Can this problem be solved by using rotations ? Rotations that we generally use to balance a binary search tree
- k.krishnakarthik July 21, 2010How about a writing a hash function which finds the range when given a input , in that manner we can have hash table with range as key and value as card type .
The Hash Function must take care of returning the range given the Integer value. we can retrieve the card type in this manner in 0(1) time.
As the array currently is not sorted ,a direct Binary search will not give us the desired result. we know that sorted array is rotated based on a position of a element
1234567 after rotation on 3 becomes 3456712 . we calculate the distance from mid element to the rotation element , in our case its 1(Let it be X) .
so after rotation we increment/decrement by X to get the pivot element , form a binary tree from by choosing this element as pivot element.
Then we can search any node Log(n) order.
If the input array elements are with in a range 1<k<N then i think it can be easily done using counting sort technique
- k.krishnakarthik July 14, 2010
RepPatriciaNRowe, Consultant at ADP
Hi i am a Freelance Writer and Social Media Manager who helps finance professionals and Fin-tech startups build an audience ...
I started implementing the Queue , but after i have written the 80 % program he said u can use Java Queue , so to complete the program i took around 20-25 mins time , I feel interviewer felt i am writing the code slow....
- k.krishnakarthik September 04, 2010