martin.mathew.2k11
BAN USERusing maps we can achieve the functionality
- martin.mathew.2k11 May 02, 2014(average rain on the planet*surface of the planet)/volume of rain drop
- martin.mathew.2k11 April 24, 2014We can have two separate Hierarchy
1. types of Data Source.
2. For Handling the format.
A controller entity which would read from the datasource and depending on the format would assign the respective format handler.
For serialization each format handler can decide how to write in their formats
using partition, till we pivot index is equal to 1000
public static int partition(int arr[], int left, int right) {
int pivot = arr[(left+right)/2];
int j = 0;
int y = 0;
int pivotIndex = (left+right)/2;
for (j = left, y = right; j < y;) {
if (arr[j] >= pivot && arr[y] <= pivot) {
if (j == pivotIndex) {
pivotIndex = y;
} else if (y == pivotIndex) {
pivotIndex = j;
}
int temp = arr[j];
arr[j] = arr[y];
arr[y] = temp;
}
if (arr[j] < pivot) {
j++;
}
if (arr[y] > pivot) {
y--;
}
}
return pivotIndex;
}
public static void finKthIndex(int[] arr,int k)
{
int pivotIndex =-1 ;
int left =0;
int right = arr.length-1;
do
{
pivotIndex = partition(arr, left, right);
if(pivotIndex==k)
{
System.out.println("Got it");
} else if(pivotIndex > k)
{
right = pivotIndex;
} else
{
left = pivotIndex;
}
}
while(pivotIndex!=k);
}
Node startNode = head;
Node midNode = getMidNode(head);
while(startNode!=null&&midNode!=null)
{
Node startTemp = startNode.getNext();
Node midTemp = midNode.getNext();
startNode.setNext(midNode);
mideNode.setNext(startTemp);
startNode = startTemp;
midNode = midTemp;
}
here is an iterative approach,let me know what u guys think
public void parrallelInorder(Node root_1, Node root_2) {
Stack<Node> stack_1 = new Stack<Tree.Node>();
Stack<Node> stack_2 = new Stack<Tree.Node>();
Node current_1 = root_1;
Node current_2 = root_2;
boolean done_1 = false;
boolean done_2 = false;
while (!done_1 && !done_2) {
done_1 = iterativeInporder(stack_1, current_1);
done_2 = iterativeInporder(stack_2, current_2);
}
}
public boolean iterativeInporder(Stack<Node> stack, Node current) {
if (current != null) {
stack.push(current);
current = current.leftChild;
return true;
}
else {
if (!stack.isEmpty()) {
Node node = stack.pop();
System.out.println(node.val);
current = current.rightChild;
return true;
}
return false;
}
}
Repcrystalblibby, Analyst at Achieve Internet
By professional i am teacher. Successfully supervised and assisted students, grade artwork, encouraged creativity and new technique.Familiar with art ...
- martin.mathew.2k11 January 13, 2015