Again a noob question about parameterizing

Im setting up an insert() for a binary tree. when i try to actually preform the setLeft or setRight command i get an error. My code is posted below.
my node class
public class BTreeNode<T extends Comparable<T>> implements Position<T> {
     public BTreeNode<T> _left;
     public BTreeNode<T> _right;
     public BTreeNode<T> _parent;
     public T            _data;
     public T element() {
          return _data;
     public BTreeNode(T c) {
          _data = c;
          _parent = null;
          _left = _right = null;
     public void setLeft(BTreeNode<T> n) {
          _left = n;
          if (n!=null) n.setParent(this);
     public void setRight(BTreeNode<T> n) {
          _right = n;
          if (n!=null) n.setParent(this);
     }my binary tree class
public class BasicBTree<T extends Comparable<T>> implements BinaryTree<T> {
     public void insert(T obj) {
     if (_root != null) {
          BTreeNode<T> runner;
          runner = _root;          
         if
                  (obj.compareTo (runner.element()) == 0){
                     System.out.println ("Object was found in tree and will not be inserted");
          else if     
             ( obj.compareTo(runner.element()) < 0 ) {
                        if (runner.hasLeft() == true){
                             runner = runner._left;
                             return;}
                        else {
                             runner.setLeft(obj); // ERROR IS HERE
          else if
               ( obj.compareTo(runner.element()) > 0 )
                         if (runner.hasRight() == true){                   
                                  runner._right = runner;
                                  return;}
                        else {
                             runner.setRight(obj); // ERROR IS HERE
     else{
          _root = new BTreeNode<T>(obj);
     return;}   
     the error i am getting says that
"The method setRight(BTreeNode<T>) in the type BTreeNode<T> is not applicable for the
arguments (T)"
or "The method setLeft(BTreeNode<T>) in the type BTreeNode<T> is not applicable for the
arguments (T)"
I had a similar question before and someone showed me where i had forgotten to parameterize my runner variable. I am thinking that this will be along the same lines although i cant imagine what it could be. The runner is already said to be part of BTreeNode<T> and setLeft and setRight are defined in the BTreeNode class so i wouldnt think that would be the problem. Anyway thanks for the time hopefully someone can help me with this.
-peter

Im setting up an insert() for a binary tree. Ceci already posted a solution to your problem, but may I suggest a different approach to your insert method? Trees are made for recursion!
public class BasicBTree< T extends Comparable <T> > implements BinaryTree<T> {
    private BTreeNode<T> root;
    public BasicBTree() {
        this.root = null;
    public void insert(T item) {
        BTreeNode<T> newNode = new BTreeNode<T>(item);
        if(root == null) {
            root = newNode;
        else {
            insert(root, item);
    // private "helper" method
    private void insert(BTreeNode<T> currentNode, T item) {
        int difference = currentNode._data.compareTo(item);
        if(difference < 0) {
            // IF 'currentNode' has a left node
            //    Recursively call this method using the
            //    left node of 'currentNode' and 'item'
            //    as parameters.
            // ELSE
            //    Set the left node of 'currentNode' here.
        else if(difference > 0) {
        else {
            System.out.println ("Object was found in tree and will not be inserted");
}

Similar Messages

  • 2 noob questions about speaker settin

    . What if I don't sync the Creative speaker settings with windows control panel speaker settings?
    2. What if I the speaker settings(both Creative and windows) don't match my speaker type?For example, I have only headphone connected to my Audigy 2 ZS but I set the speaker setting to 5. or whatever else. Will this improve my sound quality in games such as Battlefield 2? Am I?supposed to get the virtual 5. surround sound effect? Because I've heard that cmss upmixes stereo sound in?games to virtual 5. or 7. surround sound for headphones.
    Thanks.
    Message Edited by jermin on 06-24-2008 02:09 PM

    Re: 2 noob questions about speaker settings?slightlys I have a slightly different set up.
    I have 5. speakers that I use for movies and some games. For BF242 I use headphones because they give you an advantage as you can hear people creeping up behind. The virtual surround sound is really good with my XFi xtremeMusic.
    First I don't think it matters what you select under Windows Control Panel as the Creative Console Launcher updates speaker settings in Windows. Second if you want virtual 3d with CMSS on headphones just select headphones and enable CMSS3D. Then click the 'headphone' button on the CMSS3D tab and you can test the sound - a helicopter pans around in 360 degrees.
    Then in games set the software to output 5. - AFAIK. Battlefield seems to do this automatically but I can't speak for other games. I'm assuming the Audigy has the same CMSS3D tech that the XFi has.

  • Noob question about launching apps

    Greetings all,
    Just made the switch to a Powerbook with OS X Tiger, and have a question about launching applications; specifically how to do so without using the mouse. On my Linux boxes (one at home, one at work), I do most of my work from the keyboard, without resorting to the mouse, even in Gnome or KDE.
    In Tiger, I can select applications on the desktop, but haven't been able to figure out how to launch them without "clicking"... I've Googled and searched these forums, but no luck so far. Under Linux, it's the Enter key. I assume in Tiger it's some key combination...
    I know there's probably a simple answer, but I've not been able to happen upon the appropriate key combo it at random, so I thought I'd ask the experts.
    Be gentle, I've only had my PB a week!

    To help you in your quest to keep your hands on the keyboard you should check out apps like LaunchBar and Quick Silver. Your hands will never (well... rarely) leave the keyboard again.

  • Noob question about hyperlinks again?

    I have been making a website on i web and when i publish the website to a folder to view in safari, all the hyperlinks that go from page to page worked ok, now i do it again after adjusting and saving it, non of the hyperlinks work? i have tried everything to resolve this problem, im sorry if this is a common problem but i have really done all i can think of including deleting the folder where it was previusly published and try again, but the problem still persists,
    A big thanks i advance!!
    Jim

    i have solved the problem sorry, it was a shaped boarder which must have been hiding the links, under a visible layer like photoshop i would imagine, sorry to bother you all!!!

  • A noob question about precedence...

    Ok, here's the question.
    let's say:
    int a=0;
    a=a++;
    when a is evaluated, 0 is returned.
    isn's that expression like this?
    a=a=0;
    a=a+1;
    apparently I'm wrong.
    so if i forced a parentheses on it
    a=(a++);
    but again, a is evaluated as 0,
    I know how ++a would work, but i'm really curious about the suffix one.
    can any one explain to me?

    i mean how no matter what u do to
    a=a++
    i know in this case that a is evaluated first b4 it is added to 1,
    but it's gona add that 1 eventually right? so the evaluation of
    a in the en should be 1.
    Ah, I'm so confused, help

  • Noob question about trying to duplicate rows in a table

    Simplification of problem is I've got a table with user_id, name, year where user_id is pk. I would like to take all the rows that match year=2008 and insert them into the same table, but start the user_id at a certain number and set year=2009.
    I know this doesn't work, but it's what I want to do in noob-code:
    INSERT into TABLE (
    user_id, name, year
    ) VALUES (
    SELECT user_id_seq.nextval after starting at 3500, name, 2009 from same table doing insert to where year = 2008
    I've contemplated using a temporary table, I've also seen mention of cursors, but don't quite understand what they are. I'm really, really new to Oracle and SQL in general, but am familiar with programming and shell scripts. I know more in depth searching might land me what I want, but I think my search syntax would be just as weak as my knowledge of the material. I'm just thinking this is something so basic and easy that my searches aren't using the right terms to catch a hit.

    Hi,
    Welcome to the forum!
    You can INSERT all the results of a query by substituting the query where you otherwise would have "VALUES (list)".
    For example:
    INSERT into TABLE_X
           (user_id,              name,  year)
    SELECT  user_id_seq.NEXTVAL,  name,  2009
    FROM    table_x
    WHERE   year = 2008;This assumes that the sequence user_id_seq exists and is ready to issue the correct value. (It's unclear if that's part of the problem.)
    Temporary tables and cursors (which are a way of getting query results in PL/SQL) are only useful for inserting in rare situations, where you have to do very odd, convoluted things. Think (at least) twice about how to do what you need to in SQL, and if you can't think of a way, then ask.
    Yes, basic things often are hard to search for, especially if you don't know the right terms.
    There are several good teach-yourself SQL books that explain this kind of thing. Getting one would be a good investment.
    [All the Oracle manuals|http://www.oracle.com/pls/db111/portal.all_books] are on line. There's an example of this in the SQL Reference manual, under THE INSERT command.
    Edited by: Frank Kulash on Nov 26, 2008 12:59 PM
    Clarified usefulness of cursors. They have a lot of good, common functions, but helping with INSERTs is not one of them.

  • Uber-Noob Question about automounting USB hard drives

    First, let me say I'm not just new to Arch, but new to Linux as well.  Been playing with it off & on for years, but mostly 'off'.  In the last 3 weeks I've installed 10-12 different distros between my 2 home PC's and VMware on my laptop.  I've installed Arch probably 5 times now, and have got the process down pretty good.  I've probably learned more about linux from installing and configuring Arch than any other distro, book, web site, etc.  So now I've got it up and running again in VMware on an Ubuntu 7.10 install on my old pc.  I've got gnome working, sound is fine, samba is fine, really no problems.  Except mounting USB drives.  I've read several posts here and the wiki, but nothing seems to be clear really. 
    I think it may be a problem in the VM environment, but I want to be sure.  I'm planning to replace my Sidux install on my main PC with Arch later today or tomorrow.  Assuming I get it installed, and get gnome installed, will the gnome volume manager work like it does in other distros?  I don't mind doing the config by hand, but I do a lot with USB flash drives and USB hard drives, and it seems like it just doesn't work very well in Arch.  I actually replaced my ubuntu install last week with Arch, but got tired of trying to access my music on my USB drive, never could get it to mount.  So I just re-installed Ubuntu (shame on me, I know). 
    So any help in getting some understanding in what needs to be done would be greatly appreciated.  (forgot to mention, I did follow the wiki steps for autofs, as well as the usb drive wiki stuff). 
    Thanks.

    it's all working fine now, the problem was in the VM.  I installed Arch on my main PC, and except for being an idiot, all went well.  My USB drives automount in gnome, as does my CD.  Haven't tried the ipods yet, but I'm sure there won't be a problem.  Key for me:  add my user to the storage group and reboot (logging off would of done the trick too I'm guessing).  Had the same problem with setting up X, needed to reboot and all was well.  Great distro, a helluva lot of fun to install and configure, and I've only done so little:) 

  • Noob question about Airport

    I have one of the early G5 PowerMacs (single 1.6 gHz). It currently doesn't have an Airport card, but I'd like to install one or an equivalent. Here's my two questions:
    1.) Are all G5s compatible with Airport Extreme cards?
    2.) Are there good third party alternatives out there?
    I wish Apple would be clearer about what systems are "Airport Extreme Ready".
    Thanks in advance!

    The Airport "Extreme" card for your G5 is here
    http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wo/1.RSLID?mco=3 93BD37&nplm=M8881LL%2FA
    An alternative here but no cheaper
    http://www.macwireless.com/html/products/11g11bcards/11gPCI.php

  • Noob question about JWT and saving/loading midlet states

    Hi,
    I am currently playing with a midlet in JWT - it's actually a Java game. I want to "save" particular states of the midlet and then load them. For example, while playing the game, a multiple choice question appears. I want to save the exact progress up until that point in time, choose one of the answers, view the feedback and then load the saved state and try again with another answer.
    I used a lot of game console to PC emulators, and almost all of them support saving and loading states. Does JWT have such a feature? If not, do you know of any Java ME emulator that has it?
    Cheers,
    Tiberiu

    Yes, I am aware. But that does not answer my question.

  • Noob question about HDR images

    hi everybody! i am reading this book about photoshop hoping to understand a lot more than i already know about pixels and colors and image dinamics and such..i got to the chapter about HDR images and here's what i dont get. as i understand, given a HDR image it has 32 bit depth meaning its file contains much more information about contrast and brightness than any existing monitor can output, so when u open it in photoshop u will never see its true quality. my question is( and i admit it may seem pointless to some, but i am committed to understand the cause and purpose), when converting it to 8 or 16 bit depth this window pops up asking me to tweak gamma, exposure, shadows and highlights, etc., but why is this linked to the conversion process? why not simply convert it, maintain the same appearance as before and then if needed manually adjust using all the image controls from the photoshop menus? i have CS6, if that matters.

    I don't know if this will help, but I've heard about HDR monitors (still very expensive), which supposedly very accurately display the HDR values. If you hang one on the wall in your house, people might think it's a window, since it is literally a source of light, in the same way a window to the outside world is.
    Possibly the most surprising use of HDR imagery is in 3D apps where global illumination models are used. HDR imagery literally is the only source of light for these images. There are no lights in the scene, only HDR imagery. This is because of the great dynamic range of HDR.
    A more practical (to me) use of HDR is when resurrecting antique images. If you scan multiple exposures from old prints, then create HDR, sculpting values in 16-bit becomes a very powerful tool, only due to the HDR value range.
    Photoshop, although it can edit very well in 16-bit, can only show 8-bit representations of HDR imagery, since almost all monitors are 8-bits per channel. Because of the monitors, we can only see a small part of what is actually present in the HDR file.
    I've never done it, but I imagine that if we all had HDR monitors, we'd need to wear protective glasses (like you wear driving in your car when the sun is out) most of the time to do our work.  :+)

  • Noob question about DIV tags

    Learning DW and CSS so patience is in order .
    I've being reading numerous posts here and on the web about avoiding tables for laying out web pages. I can see the advantages in terms of cleaner codes and easiness of updating and changing sites at a later time. So I started learning about DIV tags (although tables is very easy for me) and have practice a few times with fairly good results, love the absolute positioning with it. Having said that, for the love of me, can't find a way of centering horizontally a page designed with DIV tags (due to ignorance), for example, 1 column/three rows page, after defining styles, size and colors I enclosed everything in another DIV tag, wrapper I think is called, but have not found a way of centering it on the page, text-aligment on the DIV tag only centers the text not the DIV itself, how to go about this? Help is appreciated.

    love the absolute positioning with it.
    Get over it.  It's a trojan horse.  Absolute positioning is not a general layout method.
    To center ANY block (non-absolutely positioned) element, use CSS to give it a width and left/right margins of 'auto'.  For example -
    <div id="foo">...</div>
    That div will be centered with this CSS -
    #foo { width:300px; margin:0 auto; }
    I think you are on the wrong path already, though.  Stick with tables (which you say are very easy for you) UNTIL you a) understand CSS well enough to understand what absolute positioning is and why I say it's bad, and b) understand how to use float, margin, and padding to place things on the page.  Then you are ready to move away from tables.

  • [SOLVED Noob question about web server permissions

    Hi I have setup up succesfully my web server. Now I am having some permission's questions/problems.
    First of all, I want the /home/httpd/home folder not to be show to the other machine users and only to root.
    I have created a user www-data and I have conf the apache file.
    This is my settings:
    My server directory is: /home/httpd and the permissions I have set:
    home dir:
    ~edited because solved~
    I have set .htaccess to some folders. I don't know If the permissions are safe or not. Can you help me?
    I think that I have different permissions to files and different to the folders...
    Thank you!
    Edited:
    And an example of my permission (phpMyAdmin):
    ~edited because solved~
    Last edited by k3rn31 (2008-02-28 22:26:09)

    This is more of a chat item for me, if you feel like it you can find me most of the time here at http://zaxter.org/xmpp.html if you have flash you can join via a simple click on connect.
    Sorry I've not been of much help to you.

  • Ultra-noob question about creating clips

    Sorry if this is answered elsewhere - I don't even know where to look.
    I'm working on a simple editing project. I've sucked in (I forget the proper term) an entire DV tape of material into one big file. Now I'm trying to pick out the good shots and save them as separate clips - about 50 of them. These clips will then be converted to a different format and reassembled using some special software outside of FCE to create an interactive web video.
    There seem to be about a gajillion ways of doing this. Master clips, independent clips, sub-clips. Right now I'm having a problem with clip names because of the master/associate business. I want to organize individual clips into folders (Folder A -> Clips A1, A2, A3, etc). But when I try to name a clip, ALL the names change. And no amount of setting the clip as Independent seems to affect it. Not only that, but I'm so green I still can't figure out what to highlight - the clip in the timeline or the clip in the folder or both.
    Can someone point me in the right direction? I don't even know what to ask.

    G'Day ap0110,
    Welcome aboard the FCE forum.
    Here is another method:
    Double click the long clip in the Browser and it opens in the Viewer.
    Mark an In and Out point in the Viewer. You will have two black triangles facing one-another in the Viewer scrubber bar when completed. Notice the bit in between the triangles is lighter in color than the rest. This bit can be made into a re-namable Sub-Clip.
    Go to Modify> Make Subclip. Command-U (keyboard shortcut).
    The modified clip now appears in the Browser ready to be re-named. Enter new name.
    Do this as many times as required.
    Right click in the Browser and a pop up appears with an option to create a _New Bin_.
    Drag the newly named Sub Clips into a Bin of your choice.
    Al

  • Noob question about the docking adapter

    Sorry guys, a real stoopid question... (but i would like a sensible answer)
    How on earth do i use the little plastic docking adapter that comes with the classic iPod? I guess the power cord goes through the bottom of it but is that it? I dont understand the point of it...
    Surely its just as quick to plug the power lead into the bottom of the ipod

    The little plastic "tray" you get with ipods are only for use with docking stations like Apple's or an iPod compatible radio with a dock/cradle that the iPod sits in. It just helps the iPod sit better in a the dock.
    For normal use with just the sync cable, you don't use the plastic adapter.
    Patrick

  • Super noob questions about cs6 and air project

    Hi, I'm trying to pass a complicated game I developed few months ago with CS5.0 for desktop and I wanted to try, at least, how it worked in a android/ios simulator... but it's becoming something harder than I though.
    1) How I know if I'm developing in flash or flex? I only see "flash" or "air"; should I try with flash builder instead? is it better for games development?
    2) Why do we have the option to publish as swc if it's a mobile app? If it's IOS is supposed to created a IOS compilated file... so... swc??
    3) I'm having really bad times with all the swf and swc I had before. Seems like it doesn't read the sfw in runtime, publish them as swc and add them in the as3 project's configuration doesn't work either. Any sort of known issue?
    4) Can I ask you about tutorials or any sort of information? not about creating animations and launch them in the simulator, that's fine. About managing project and this sort of "more advanced" stuff. I don't find any sort of information anywhere!
    thank you!!!

    Sorry, I misinterpreted that part of the qustion. Yes, Colin is of course correct. Apple won't allow you to run any non-compiled code (C compiled, not AS-compiled) on IOS. So you can neither bundle a swf with the ipa nor call to a server to load a swf, if that swf contains any code whatsoever (even something as simple as a stop() action or a linkage identifier).
    What you can do is embed a swf into your project, or link to your swc and use its assets in that way. This results in a single swf that gets compiled into your ipa, thus satisfying Apple's requirement.
    Oh, and a little more on #1: You asked if you should use Flash Builder, and if it's better for games development. The answer is: "it depends". Most every "serious" dev I know develops in some sort of dedicated coding environment: FB, FDT (this is what I use principally), IntelliJ, FlashDevelop, emacs, etc. That said, I worked quite successfully in Flash for many years and its coding tools are adequate (arguably). If you start building large systems, though, you will probably rapidly get tired of the limited toolset and want to graduate to something with a bit more firepower.
    <edit>
    BTW...I'm talking about my experience, not passing judgement. Anyone who considers themselves a serious dev and yet codes in the Flash IDE, I respect your preference. If you consider yourself a serious dev and haven't *tried* working in another environment, I still respect you; but I also suggest you look at the advantages of other work environments.
    </edit>

Maybe you are looking for

  • How can I setup a Deskjet 3050a/J611 to my updated MAC OSX 10.9

    SInce updating my MAC with OSX 10.9 (Maverick) I have not been able to add my printer to my computer as wireless.  I can add by USB cable but I am not being given the option to "convert a USB connected printer to Wireless".  I can print when connecte

  • Can't Open PDF Package In Adobe Acrobat Reader 9.3

    Yesterday, I created a PDF Package of about 30 documents. When I attempt to open the package using Adobe Acrobat Reader 9.3, I get the Data Execution Prevention pop-up message saying that the file cannot be opened. Does anyone have any thoughts on wh

  • Lync 2013 Client Not Display Numbers in Contact Card

    Hi I have a problem where Lync 2013 client connecting to Lync 2010 backend appears not download the contact list completely. Lync 2010 clients are all operating normally.  On Lync 2010 client, you can view all contact details including Enterprise Voi

  • Temporary tables

    i am trying to create a temporary table in PL/SQL and want to insert rows. create procedure temp as xsql varchar2(1000); begin vsql := 'create global temporary table t1 (n1 varchar2(50))'; execute immediate vsql; insert into t1 values ('abc'); select

  • Extracting text from flash player to c++ program

    i was wondering if there was any way to read text from a window open in  firefox (or any web browser) and use that text as a variable in a c++  program.  for a specific example, i am trying to create a poker  statistics program.  there are poker play