Search:

Type: Posts; User: ueg1990

Search: Search took 0.09 seconds.

  1. Replies
    11
    Views
    2,196

    Re: Lowest Common Ancestor in Binary Tree

    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?
  2. Replies
    11
    Views
    2,196

    Re: Lowest Common Ancestor in Binary Tree

    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...
  3. Replies
    11
    Views
    2,196

    Re: Lowest Common Ancestor in Binary Tree

    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??
  4. Replies
    11
    Views
    2,196

    Re: Lowest Common Ancestor in Binary Tree

    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...
  5. Replies
    11
    Views
    2,196

    Re: Lowest Common Ancestor in Binary Tree

    doesnt bottom-up mean, i will need a parent pointer??
  6. Replies
    11
    Views
    2,196

    Lowest Common Ancestor in Binary Tree

    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...
  7. Replies
    2
    Views
    1,561

    Height of a node in a binary tree

    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...
  8. Replies
    0
    Views
    1,841

    Quicksort with median-of-3 partitioning

    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...
  9. Replies
    3
    Views
    2,777

    Re: swapping nodes in a linked list

    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...
  10. Replies
    3
    Views
    2,777

    swapping nodes in a linked list

    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...
  11. Replies
    11
    Views
    9,638

    Re: permutations of a string using iteration

    if u have a string "abc" then the output should be: abc, acb,bac,bca,cba,cab
  12. Replies
    11
    Views
    9,638

    Re: permutations of a string using iteration

    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++) {...
  13. Replies
    11
    Views
    9,638

    permutations of a string using iteration

    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...
  14. Replies
    2
    Views
    1,343

    Increment operators on char

    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;
Results 1 to 14 of 14