How to find a shortest distance in a tree from one node to another node

Hi
my question is same as above.. there are many algorithms which i had come across but they are mainly for graphs or weighted trees. i want to traverse through a binary tree... how is it possible.. any link to the solution or source code sample will work...
Thanks

Rastogha wrote:
redfalconf35 wrote:
[http://en.wikipedia.org/wiki/Tree_traversal|http://en.wikipedia.org/wiki/Tree_traversal]
that is good link. but . given a node is it possible for me to find all is ancestors or parents so that i can traverse up the hierarchy.....Most simple tree implementations just have references from each node to its children. You either want:
1. the tree data structure to maintain back pointers -- from each child back to its parent, OR
2. a bread crumb trail: as you traverse the tree or otherwise pick a node, you need to have built a list of references from the root down to the node in question.

Similar Messages

  • How can I transfer my iTunes library and playlists from one computer to another?

    How can I transfer my iTunes library and playlists from one computer to another?

    Copy the iTunes folder (Mac: Home\Music or PC: My Music) to the same location on the new computer. If an iTunes folder already exists on the new computer (it will on a Mac) replace it with one you copied.

  • How do I copy the same app folder layouts from one device to another? We have a several iphones and ipads.

    how do I copy the same app folder layout from one device to another. We have several apple devices.
    It's a challenge when syncing a device for the first time to go through all the apps and apply them back to the same folders as on your other iphone.
    I've seen suggestions of taking pictures of the correct layout, then manually applying it to the new device. Big time waister.
    What's the work around?
    Thank you

    I'm afraid there is no short workaround. One thing that you could do if you were REALLY desperate is reset your device to factory settings and then restore it from your other device's backup, but that is rather risky and you probably don't want to take your chances just for folder layouts. I would just do it manually.

  • HT4878 How do i share my pictures, music and videos from one user to another on the same computer?

    How do i share my pictures, music and videos from one user to another on the same computer?

    lots of ways... you could use a thumb drive, you could drag files to the users public folder drop box, you could send it through email, you could use the internet servic called drop box (not to be confused with Apple's user public foldelr drop box).

  • How can I transfer entire contents of Mail mailbox from one Mac to another?

    I've long wondered how to do this:
    I have two Macs - an iMac and a MacBook Pro.
    I have categorized several hundred emails on the MacBook into a separate "mailbox" by itself. Let's just call it "Project XYZ emails" for the sake of discussion.
    I need to transfer ALL of those emails +en masse+, hopefully still categorized together into a separate "Project XYZ emails" mailbox file, from the MacBook to the iMac. How is this done?
    In the old days, when I used to use Eudora, this was quite simple -- one could physically locate the separate desired "mailbox" file in the Finder and just copy it from one hard drive to the other, and then place the mailbox into the appropriate place of Eudora's file structure on the second computer. Relaunch Eudora and voila, the new mailbox is there for viewing, etc.
    But in Mail, I can't find any tangible "file" on my hard drive that represents a "mailbox" in the Mail program. And that includes control-clicking the application file itself and choosing "Show Package Contents." When I do that, I can see, after burrowing into the folders, a single large file called "Mail" which I think contains ALL mailboxes lumped together. But I can't see a way to separate them for individual manipulation.
    Any suggestions or ideas on how to copy entire mailboxes in Mail from one Mac to another?

    Thanks! Seems to have worked.
    Once I imported tham, I had to fiddle around renaming mailboxes and "moving" the emails to the desired locations, but that only took a minute. So overall, seems like that's the solution! I only wish that the steps to do this were made clearer by Apple in the Mail "help" menu -- where I couldn't find any mention of how to do this.
    A happy ending, in any event.
    In case anyone reads this in the future, let me add in the missing steps, to make it perfectly clear:
    In Mail, choose 'archive mailbox' from the mailbox menu.
    +Copy the newly created archived mailbox file, which will probably be a file with the suffix ".mbox," from the original machine to the second machine.+
    On the second machine: In Mail choose 'import mailbox' from the file menu.
    +The emails will now appear in a new mailbox in Mail listed under the name "imported" or "import." If desired, either rename the mailbox, or create a new mailbox with the correct name, and "move" all the emails into it.+
    Done!

  • HOW TO GET THE SELECTED VALUE IN A ROW FROM ONE VIEW TO ANOTHER VIEW?

    hi all,
    I  have a small issue.
    i have created two views.In the table of the first view i'm selecting a row and pressing the button it will move to next view.
    i am adding some fields manually in the table of the second view and pressing the save button.Here all the values should get updated corresponding to the field which i have selected in the first view.
    I want to know how to get the particular field in the selected row from one view to another view.
    Kindly help me.

    Hi,
            Any data sharing accross views can be achiveved by defining CONTEXT data in COMPONENT CONTROLLER and mapping it to the CONTEXT of all the views. Follow the below steps.
    1. Define a CONTEXT NODE in component controller
    2. Define same CONTEXT NODE in all the views where this has to be accessed & changed.
    3. Go to CONTEXT NODE of each view, right click on the node and choose DEFINE MAPPING.
    This is how you map CONTEXT NODE and same can be accessed/changed from any VIEW or even from COMPONENT CONTROLLER. Any change happens at one VIEW will be automatically available in others.
    Check the below link for more info regarding same.
    [http://help.sap.com/saphelp_nw04s/helpdata/EN/48/444941db42f423e10000000a155106/content.htm]
    Regards,
    Manne.

  • URGENT: How to selectively migrate composite instances and task data from one env to another

    Gurus,
    We've come across a situation whereby we need to migrate instance data (including Human Task related) of some specific composites from one environment to another.
    (Environment is equivalent here to a different domain installation on different physical server.)
    Is this possible in some standard way like using Oracle import-export utility or script?
    If not, how can this be achieved?
    Thanks in advance for any help you can provide on this.
    With regards-
    Ashish

    Hi,
    If your SharePoint environment supports InfoPath Forms, then you can customize the form and add rules to make the list items as read only when user A submits the form.
    you can then write a form load event to check the logged in user using username() function. This logic can be implemented in variety of ways, like setting a flag when User A submits the form, or storing user A username in a form variable etc., else comparing
    User A and User B values within form Load event.
    Another way of doing this is using Views or grouping all of the User A fields within a section etc.,
    The above would take care of Form logic, and for the workflow, you can use SharePoint designer to create a custom workflow, where it will run on onItemCreate and onItemChange events.
    The logic for workflow would be if the form Submitted for the first time, the workflow will start and send an email to User B, and when User B submits the Data then onItemChange change event will start the workflow to send an email to approver to approve
    the data.
    here are some links for your reference -
    http://office.microsoft.com/en-us/infopath-help/add-formulas-and-functions-in-infopath-2010-HA101821255.aspx
    http://office.microsoft.com/en-us/videos/video-create-an-approval-workflow-in-sharepoint-designer-2010-VA101897477.aspx
    http://blogs.technet.com/b/meacoex/archive/2010/11/01/get-manager-approval-in-sharepoint-designer-2010-step-by-step.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • How do I move all the apps and podcasts from one mac to another mac?

    What is the best way to move all the apps and iTunes content (songs, podcasts, etc) from one Mac to another Mac?  I am switching to a newer computer.  I connect (with cables) an iPhone 4 and an iPad 2 to the old computer for syncing.

    Take a look at this.
    iTunes: How to move your music to a new computer
    When I recently got a new MacBook, I set it up with Times Machine using a backup of the old computer. It could not have been easier. If you use Time Machine - that will copy the contents of the old Mac to the new Mac - iTunes library included. You will have to authorize the new Mac in iTunes - Store>Authorize this computer.
    There are ways of copying the purchased contents from the iPad to the new iTunes library as well if you need to do that. But as long as you have the old Mac - copying the library and putting it on the new Mac makes the most sense.

  • How to reference a Textbox or a Grid object from one tile to another tile

    Hello All
    How do i reference a Textbox of a Grid object from one tile to another tile? I've 6 tiles in a tileset.
    Tile-1 has a "Complete" button when that button is clicked i want to loop through a values in a Grid object from Tile-3. Is that possible? I'm using Mobile Application Studio 4.0
    Thanks in advance,
    Hetal

    Hi,
    then I would implement sth like the following:
    dim myBO as businessobject
    dim i as integer, sValue as string
    for i = aMyAnchor.bcol.count to 1 step -1
      sValue = aMyAnchor.bcol.GetAttribute(i, "myProperty")
      if sValue = "" then
        aMyAnchor.bcol.item(i).delete
      end if
    next
    Please note that the deletion needs to be done bottom-up because of a refresh of the
    indexing after deleting of objects in the collection.
    The refresh of the grid is done automatically because of the data binding.
    Regards,
    Wolfhard

  • How do you transfer Several files and numerous photos from one Mac to another.

    I have a Mac Book Pro (late 2011) and a Mac Air (2013).   I know I can airdrop but I would be doing that for days - is there any way to transfer file from one computer to another. 

    If you want to transfer a large amount of files, the best way would be to use an external drive. If you do not have one, consider the option of using Target Disk mode, so you just have to get a Thunderbolt cable; this is the fastest option.
    To use Target Disk mode, connect the Thunderbolt to the MacBook Air and the MacBook Pro. Then, start up your MacBook Pro and hold the T key while it is starting up until you see the Thunderbolt icon in the display. Now, go to the MacBook Air, open a Finder window and you will see the MacBook Pro hard drive in the sidebar, so access to them and transfer the files you want to.

  • How can I swap or cut & paste a head from one photo into another for a holiday photo using aperture or photoshop?

    I've got an almost perfect family photo that I need to swap one face in as my son was not looking at the camera and I can't redo the shoot.  Anyone know how to take a headshot from one pic and swap it into another using Aperture or Photoshop?  Thanks!

    select the head with one of Photoshop's selection tools
    When doing this, I find it quite helpful to create an intermediate image with a transparent background that contains only the head to be pasted into the second image. First I paste the head onto this transparent background, scale it, rotate it or skew it to make it fit into the other image, adjust the lighting, then select it.
    To be able to paste the head seemlessly into the second image (and without aliasing effects), I make the border of the selection soft (⌥⌘D); my Photoshop has a german interface, so I am not sure about the english localization, this command must be something like "selection -> modify selection -> soft border".
    I would not bother to get the lighting and color excactly right in Photoshop, that is  far easier with the "dodge" and "burn" brushes and color adjustments in Aperture.
    To do this completely in Aperture, you would have first to combine both images into one (for example by creating a book page), then use the retouche->clone tool to stamp the head from one image to the other. I use this occasionally to stamp a face into a flower bud or for  similar effects. However, for this to work you need a plain background and nearly circular shapes to be pasted.
    Léonie

  • How do I transfer files on the same iMac from one user to another?

    I recently transferred files from my Macbook Pro to my iMac.  Now I have two user profiles on my iMac.  How do I transfer files from one user to the other user on the same iMac?

    Choose Go to Folder from the Finder's Go menu, provide /Users/Shared/ as the path, drag them there, and then to the desired location.
    (115866)

  • How to remove cached images in html whe going from one page to another page

    can anybody help how to remove cached images in html pages.i tried with response.setHeader("no-cache") but it is not working

    thanks,
    can u tell me how to make the browser not to cache images.since iam moving from one page which has images, into another page which having few more images both gets overlaped so how to remove images of previous page.
    thanks in advance

  • How do I drag an image icon or image from one panel to another panel?

    Please help.
    I know to need how to drag an image icon from one panel to the other. For example, the first panel would shows the image files that is inside my folder. How can i code it so that I can drag the image that appear on the first panel into the second panel which will hold the images that I want to embed my barcode inside?
    The thumbnail size of the image and showing all the image files in my folder was done already, I only need to know how can I make the image icon to be able to drag from one panel to the other.
    Thanks.

    I found this code in some websites:
    public class ImageSelection extends TransferHandler {
         private static final DataFlavor flavors[] = {DataFlavor.imageFlavor};
         public int getSourceActions(JComponent c) {
              return TransferHandler.COPY;
         public boolean canImport(JComponent comp, DataFlavor flavor[]){
              if (!(comp instanceof JLabel)){
                   return false;
              for (int i=0, n=flavor.length; i<n; i++){
                   for (int j=0, m=flavors.length; j<m; j++){
                        if (flavor.equals(flavors[j])){
                             return true;
              return false;
         public Transferable createTransferable(JComponent comp) {
              if (comp instanceof JLabel) {
                   JLabel label = (JLabel)comp;
                   Icon icon = label.getIcon();
                   if (icon instanceof ImageIcon){
                        final Image image = ((ImageIcon)icon).getImage();
                        final JLabel source = label;
                        Transferable transferable = new Transferable(){
                             public Object getTransferData(DataFlavor flavor){
                                  if (isDataFlavorSupported(flavor)){
                                       return image;
                                  return null;
                             public DataFlavor[] getTransferDataFlavors(){
                                  return flavors;
                             public boolean isDataFlavorSupported(DataFlavor flavor){
                                  return flavor.equals(DataFlavor.imageFlavor);
                        return transferable;
              return null;
         public boolean importData(JComponent comp, Transferable t){
              if (comp instanceof JLabel){
                   JLabel label = (JLabel)comp;
                   if (t.isDataFlavorSupported(flavors[0])){
                        try {
                             Image image = (Image)t.getTransferData(flavors[0]);
                             ImageIcon icon = new ImageIcon(image);
                             label.setIcon(icon);
                             return true;
                        catch (UnsupportedFlavorException ignored){
                        catch (IOException ignored) {
              return false;
    What this codes does is to get the image from the imageicon and replace the image to the imageicon that you drag the source from. However, I had no clue how I can get the source's file name. Anyone can teach me how?
    Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How will Time Machine react? Moving iPhoto Library from one HDD to another

    Hi,
    I had to move my iPhoto library from one external drive to another. The iPhoto library was backed up via time machine.
    Is there a way that I can "teach" Time Machine that the iPhoto-Backup from the old hard drive now belongs to the new drive???
    Greetings from Austria!
    EDIT:
    I haven't made a backup since moving the iphoto library. But now I wonder, maybe: Will time machine automatically recognize that the iphoto library just has been moved? And that it's not a "new" library?

    If you have any problems with the library in the new account you might have to download and run BatChmod on the library to reset the ownership and permissions to the new account owner for all of the files in the library.  User the settings shown in the screenshot below:
    Click to view full size
    For Owner use the owner name for that account.  If the account uses a different Group then use it also.  You can find the group name by seleting a file in your other account and typing Control+i to bring up the Info window.  The ownership and group will be shown near the bottom.
    OT

Maybe you are looking for