sumeet.kukkar
BAN USERNumber of one' s present in 'n'
- sumeet.kukkar January 26, 2014Code: this is not very elegant code but it works.
static void findPivot()
{
int low = 0;
int index = 3;
int high = index + 1;
int []input = { -2, 3, 5, 0, -3, 7, -1};
while(low < index && high < input.length)
{
while(input[low] < 0 && low < input.length)
low++;
while(high < input.length && input[high] > 0)
high++;
if(low < high && high <input.length)
{
int temp = input[low];
input[low] = input[high];
input[high] = temp;
}
}
for(int i =0; i < input.length; i++)
{
System.out.println(input[i]);
}
}
Using the idea of quick sort but with small tweak. In order to maintain the order, starting low pointer from 0th element and high pointer from index of element with value zero + 1. And doing normal partition of quicksort.
- sumeet.kukkar January 25, 2014'n' is number of children of root.
- sumeet.kukkar November 19, 2012@Anjana, We can introduce another parameter like while calculating hash-function by Abhishek.
New function hash-count look like:
h = 31*h*count+ascii(char(i));
for calculating h1 -> increment count from 1 to half of the list i.e. 6 in this case.
And for calculating h2-> decrease count from 6 to 1. This way hash function will start considering order of the character in the string.
I think the answer is segment trees... a segment tree is a tree data structure for storing intervals, or segments. It allows querying which of the stored segments contain a given point. It is, in principle, a static structure; that is, its content cannot be modified once the structure is built
- sumeet.kukkar October 15, 2012
RepJamesDeal, Animator at Absolute Softech Ltd
My name is JamesDeal. I am working at Integra Investment Service as a Library aide . It's been almost 5 ...
RepDavidJohaan, Digital marketing Experinced at Abs india pvt. ltd.
I am David , a scanner operator for seven years in the industry Paearb. Six months ago , I’d an injury ...
RepTheresaHudson, IC3 at Broadsoft
I am Theresa , a Packer with a strong determination to finish all assignments in a timely manner. Inspected and ensured ...
RepDorothySanders, Accountant at Amazon
Hello, I am an Engineering manager. I love my work. I also love to read news articles related to the ...
RepBertMusi, Consultant at Accenture
I am a service technician working at Parade of Shoes . It's been almost 5 years since I have been ...
RepAnnetteOwens, Email Customer Service at Axiom Sources
Hi , I am Annette, a Data Processor with a comprehensive knowledge of data management and analysis. As I am a ...
Approach: It is stated that node has child and parent properties. We can make use of parent property.
- sumeet.kukkar January 27, 20141. Start traversing from both the nodes using parent pointers'
2. For any one node, start pushing the nodes traveled in a hashtable. For another node traversal, keep check the node is present or not in hashtable. If node is present the found which is LCA of two nodes.
Probably have to work out the details where one traversal finishes before the other one but that can be easilly handled in the code.
If we want to avoid using any extra memory, we can treat this two list with one merging point. Which can be easily solved in O(h).