ok, i have one question abt bottom-up traversal, do it go uptill leaves and then up to the nodes i am calculating LCA for? and from there i go to the root?
ok, i have one question abt bottom-up traversal, do it go uptill leaves and then up to the nodes i am calculating LCA for? and from there i go to the root?
ok, so my findOrQueue function does that....it finds the node first and then as it does find it, it adds the others nodes in its path to a queue....which part r u referring to with respect to...
can u plz give an example of how to do bottom up traversal?? i dont understand how to build traversal bottom-up without knowing where the node is??
so lets stay i have a parent pointer, i still have to traverse to the two nodes whose LCA i am calculating...so how will bottom-up help me?? can u plz help me with this?
--- Update ---
or are...
doesnt bottom-up mean, i will need a parent pointer??
Following is my implementation of lowest common ancestor for a Binary Search tree. I have two question:
1) The time complexity is O(n) and space complexity is O(n) worse case but O(logn) average...
Hello,
I have a question regarding the height of a node in a binary tree other than the root node? In my height method, for the root i can pass the root as a parameter. But if i want to find the...
I was trying to understand quicksort with median-of-3 partitioning. After finding the median of the first, middle and last element in an array, a common practice is to swap median with the second...
im using my own code......lets say i have my function: swap(Node n1, Node n2);
since i want to swap nodes, how do i pass the nodes that i want to swap? if i want to pass node with content 5 and node...
i have a question regarding swapping nodes in a linked list. Suppose we have a linked list : 2->5->7->4->6
Suppose we want to swap node with value 5 and node with value 4. What do we pass as...
if u have a string "abc" then the output should be: abc, acb,bac,bca,cba,cab
public static void combString(String s) {
char[] a = new char[s.length()];
//String temp = "";
for(int i = 0; i < s.length(); i++) {
a[i] = s.charAt(i);
}
for(int i = 0; i < s.length(); i++) {...
im trying to find permutation of a given string but i want to use iteration. The recursive solution i found online and i do understand it but converting it to an iterative solution is really not...
i am trying to understand increment operators on char:
public class Ch8 {
public static void main(String[] args) {
char c = 'a';
c++;
c = c+1;