somjit{} 60 Junior Poster in Training Featured Poster

Your code is very hard to read . Not only are the names of the methods non-descriptive , but also , there aren't any comments for them. Also , your assignment speaks to implement recursion where-ever possible , but i dont see you doing that. Recursion is bad for a lot of things , but it really makes things simple when it comes to trees. As for example , in your printInOder() method , if you implemented that using recursion , here is what it can be changed to :

    public Iterable<Key> keys(){
        Queue<Key> q = new Queue<Key>(); // queue implements iterable , so contract is valid
        inorder(root, q); // call the recursion
        return q
    }

    private void inorder(Node x, Queue<Key> q) {

        if (x == null)
            return; // will signify the end of recursion , all the stacks starts
                    // returning hereonwards

        inorder(x.left, q);

        q.enqueue(x.key); // as stacks start evaluating , nodes will be put into
                            // the queue starting from the left most leaf , ie , the
                            // smallest node , ending with the root

        inorder(x.right, q); // and now enqueue all the nodes to the right
    }

So all you do is call print on keys() and it takes care of all the traversing and printing. Resulting in cleaner , better , lesser (amount of) inspection needed when something goes wrong. like now.

( comments are what i understand of the code , i can be wrong though. )

Also , reagrding your …

somjit{} 60 Junior Poster in Training Featured Poster

One thing that i find a bit hard , is that the use of "key" here. Key is generally accompanied by a corresponding value , but your node does not have a key-value pair , only a key. Perhaps you could make that change . Yes it may not directly solve your problem , but it clears things.

also , what is your new version for this : binRoot = delete(binRoot); ?

somjit{} 60 Junior Poster in Training Featured Poster

No problem. But can you explain the role of the two argument delete() as compared to the previous one ?

edit : i see that you implemented the pattern somewhat that i posted ,missed it at first. lets see whats happening...

somjit{} 60 Junior Poster in Training Featured Poster

regarding deletion , here are 4 steps to it

Save a link to the node to be deleted in t. (n in your case)
Set x to point to its successor min(t.right).
Set the right link of x (which is supposed to point to the BST containing all the keys larger than x.key) to deleteMin(t.right), the link to the BST containing all the keys that are larger than x.key after the deletion.
Set the left link of x (which was null) to t.left (all the keys that are less than both the deleted key and its successor).

probably you have implemented this , but your delete code looks a bit complicated.

The implementation for the above description is something like this :

    public void deleteMin() {
        root = deleteMin(root);
    }

    private Node deleteMin(Node x) {
        if (x.left == null)
            return x.right;
        x.left = deleteMin(x.left);
        x.N = size(x.left) + size(x.right) + 1;
        return x;
    }

    public void delete(Key key) {
        root = delete(root, key);
    }

    private Node delete(Node x, Key key) {
        if (x == null)
            return null;
        int cmp = key.compareTo(x.key);
        if (cmp < 0)
            x.left = delete(x.left, key);
        else if (cmp > 0)
            x.right = delete(x.right, key);
        else {
            if (x.right == null)
                return x.left;
            if (x.left == null)
                return x.right;
            Node t = x;
            x = min(t.right); 
            x.right = deleteMin(t.right);
            x.left = t.left;
        }
        x.N = size(x.left) + size(x.right) + 1;
        return x;
    }

    private Node min(Node x)
    {
        if (x.left == null) return …
somjit{} 60 Junior Poster in Training Featured Poster

its a lot of code to go through , lets see..

What if you put the elements in a sorted manner inside the BST ? does that comply with your assignment rules ?

if yes , you can use buffered reader , read a line , .split() it , sort the string array , and then put each entry in the order they come in the string. Its not realted to your question perhaps , but i feel having things sorted makes 'em easy.

somjit{} 60 Junior Poster in Training Featured Poster

Get an electronic drum kit

  1. expensive
  2. massive import duty on top of that

i wish guitars and lenses came as cheap as they do in US... i love schecters , especially the corsair and the hellraiser series , #$%@-ing import duties kill everything.

somjit{} 60 Junior Poster in Training Featured Poster

Ummm....

well , i meant you getting back your account after it got deleted mysteriously...

somjit{} 60 Junior Poster in Training Featured Poster

i'm currently developing a belly on a skinny body. i like to run when the weather is nice and i can get up early in the morning.

btw , congratz on getting resurrected ( i think i made a typo ... )

somjit{} 60 Junior Poster in Training Featured Poster

i have about 18 years of expirience banging tables :P only reason i dont have a drumkit at home is because of how quiet my neighborhood is , and how much the neighbors would like to keep it that way. I played guitar , until the neck bent and now tunes drop even with half-hours strumming. :(

somjit{} 60 Junior Poster in Training Featured Poster

How do I know to only pull the rest of the line that has draw in it though?

as your current txt stands , draw is always at the begining , so after split()-ing a line , check if the 1st entry equals draw , if so , you know that the rest will also be picture details.

somjit{} 60 Junior Poster in Training Featured Poster

there is a bit that you have justify here : will the "draw" tag be always followed by picture details , if so , the pass the following split()-ed tags to a drawing function that takes them in to draw a picture , instead of having switch cases for each picture description tag.

somjit{} 60 Junior Poster in Training Featured Poster

your text file looks pretty ordered to me. The only place where you might need scanner for input parsing purposes is when there may be unexpected lines in-between two valid lines , or a valid line has garbage in between two valid key words. split() works there too , but then you have to put in more checks. So unless you have a dirty , unordered file , go with the split-switch method.

Also , If you do decide on using scanner , (though its a bad idea if your file is always like this) , check more into the condition for hasNext() to return false. you can say that it knows there is a wall in front of it only after it has hit it ;)

somjit{} 60 Junior Poster in Training Featured Poster

thanks, but I am not looking for career advice from you.

  1. the statement was uncalled for. because
  2. your not even sure which one you want - run or review.
somjit{} 60 Junior Poster in Training Featured Poster

you want to do that ? or you want us to do that ? the later one isnt really an option here.

Also , this is two words , one english , and another java . You say copy and then you say this . that confuses me a bit.

somjit{} 60 Junior Poster in Training Featured Poster

if stack is empty , you should return some kind of error or throw some exceptions imo.

 revertStack.push(pop());

i dont know what those are , but assuming they do the work they are supposed to , AND its an in-place operation , you are returning a reversed version of stack , but its not a copy of the original stack , because the stack itself has been reversed. here is something you can do :

  1. make FancyStack iterable
  2. in your else() condition , have a for() loop that takes in each member of FancyStack() and put that in a new copy.
  3. apply revertStack.push(pop()) to this newly made copy , and return it.
somjit{} 60 Junior Poster in Training Featured Poster

This thread is a bit old , but i'm having the same questions (under different circumstances) as the OP. Googling for "CLR versions for Mac and Linux" led me to mono and wine ( can i say respectively here ? ). Now in one stackoverflow thread , i read that the MSIL is only a part of an EXE for a windows program , and the other parts include native windows stuff , and MONO will just take the MSIL and do that part. So it doesn't work the other native stuff inside the EXE ? What does it all mean ?

apologies for being vague , but i really do not know enough to be more specific.

somjit{} 60 Junior Poster in Training Featured Poster

google up "sieve of eratosthenes" . the algorithm results in a small but powerful code for finding primes.

somjit{} 60 Junior Poster in Training Featured Poster

@diafol : what i agree upon is that the education system here is quite bad.

Theres nothing to hide regarding that. As AncientDragon had mentioned , a phd can be bought in the US as well as in India. These things hardly change in any part of the world. I'v seen people assume that indian student learning C must be programming with Turbo-C , I'v read words like "code-monkeys" in low wage countries , and many others . code-monkeys exist in any place where there's programming getting done. statements like

It's overall cultural as well, unwillingness to admit lack of knowledge to foreigners leading to misinterpreted specs, bugs that could have been avoided by asking a few questions,

really ? i mean it all made sense untill you add the cultural part. Even then , are there are no arogant know-it-all programmers in the west ?

It was sad to see such ideas about us developing amongst people from other countries. And though i would love to be angry on those who say such stuff, i cant because i know some "dumbasses" are always out there , making a bad name for more than just themselves.
In this case , the OP , and because of this and what i wrote above , i hoped that the thread could be deleted if possible. But i understand that its a bit too late for that.

somjit{} 60 Junior Poster in Training Featured Poster

I feel sad that for a few dumbass people with no sense of what they are saying , students from india get such a bad rep. Unfortunately , the rotting education system in the country keeps feeding off peoples hopes that getting their child to an engineering institution would guarantee a better future , and keeps churning out more such dumbasses by the year.

what is more unfortunate is that , these people get heard the most.

i would request the mods to delete this thread.

somjit{} 60 Junior Poster in Training Featured Poster

and while you do all this , dont touch the ide.
make your memory and fingers work a little on that favourite text editor of yours.

somjit{} 60 Junior Poster in Training Featured Poster

i see . :)

somjit{} 60 Junior Poster in Training Featured Poster

Coz i have tried this and it works swiftly.

so something that you have tried and works swiftly is lame ? ;)

lame would be something that is slow , takes a lot of memory etc etc etc.

lookup table may not necessarily be the fastest way to do things. what is fast and what is lame needs actual benchmarking. and a thorough understanding of exactly what it is that your doing.

somjit{} 60 Junior Poster in Training Featured Poster

Am aware of mathematical algorithm for binary to octal conversion, that you have to group binary digits into 3 from right and subsitute respective octal digit.

so your thinking of a lookup table. but i dont see any such code in what you have posted , also this is a shortcut in some sense . An actual algorithm is a generic process that always works , lookup tables are specific to the two bases that are being consedered.

the actual "algorithm" is this :

any base to dec :   sum: ith-num*(base^i) 
dec to any base :   succ div by required base

default way to convert from base A to base B :
convert A to dec , take that dec and convert to B.
this will work with all bases.

ps :
i post this generic method because you mentioned about "an algorithm from scratch". This might not be the most efficientway to convert between two bases, but thats a different topic.

somjit{} 60 Junior Poster in Training Featured Poster

1st of all , your goto's make it not only uncomfortable to read the code , but also , if you get into a habit of using them , i dont think thats gonna be a good idea.

2nd , give this a read.

somjit{} 60 Junior Poster in Training Featured Poster

see this
until the eof mark is set , the last entry will be repeatedly fetched . its better to use an array i feel , and in the while loop at the end , apply index < length of array condition.

somjit{} 60 Junior Poster in Training Featured Poster

my bad , my brain must had gone totally bonkers , i thought i+1 was incrementing i !!

somjit{} 60 Junior Poster in Training Featured Poster
printf("Enter Height of Student %d : ",i+1);
scanf("%d",&height);
fwrite(&height,2,1,fp);
i++;

your incrementing i twice in the same loop . i havent run your code yet , but i dont think thats how it should work.

somjit{} 60 Junior Poster in Training Featured Poster

the suggestion i gave included a flaw in it. and i provided a hint for it also. why do you think you got an auto-return after "enter replacement character" part ?

on a different topic : whyare you giving 1 as the character to be replaced ??? where is 1 in that string you wrote ??

somjit{} 60 Junior Poster in Training Featured Poster

in java or c , if you want \ in your string , you have to give another \ before it. its the holy rule of the blackslashes . ;)

somjit{} 60 Junior Poster in Training Featured Poster

in c , passing an array is by default pass-by-reference , you dont need the char * . char s[] in both the declaration and definition would do well enough i think.

did you try what i said above there ?

edit : whats with the getch() ? if your running from the default windows cmd, you wont need getch() . if your using a modern IDE , they provide the getch() facilty built in. if your using something old like turbo c , i suggest its time you make a shift. :)

somjit{} 60 Junior Poster in Training Featured Poster

ok.
try replacing the 1st scanf() , the one that reads a line , with fgets() , then replace the two scanf()'s that come after that with getchar()'s.
then youll see that it also wont work , but it should give you an idea regarding scanf()s and getchars() and stdin.
HINT : its about stuff that gets left behind in the input stream.

also , a question : in the function declaration , you mention char * but in the definition ( that is waht they are called if i remember correctly ) below the main , you write char s[] . why so ?

somjit{} 60 Junior Poster in Training Featured Poster

why do i have to put 4 '\' in the Pattern.compile??

because you have 2 \ in your string , and so , one extra \ for each.

somjit{} 60 Junior Poster in Training Featured Poster

yo !

somjit{} 60 Junior Poster in Training Featured Poster

ps : Click Here

:D

somjit{} 60 Junior Poster in Training Featured Poster

writing regex pattern for all of them would be impossible

complicated ? yes , impossible : no.
example : <[^>]*> can be used in conjuction with a replace by "" to remove non nested html tags.

.i need to convert the escaped hex values into their corresponding ascii.

i hope you dont plan to check them one by one after that ? thats gonna be quite slow.

somjit{} 60 Junior Poster in Training Featured Poster

try this regex pattern
H\w+,\s+W\w+ this is tailor made to get "Hello, World".

it starts with H , looks for all word characters from H (the \w+ part), this stops at the first comma , then include one or many whitespace (via \s+ ) , then do what you did in case of H but with W.

somjit{} 60 Junior Poster in Training Featured Poster

i think i have an idea of whats happening , but when you say awkward output , posting the awkwardness here would help tame it :)

note : scanf() to read a character is a very bad idea.
read more from here

somjit{} 60 Junior Poster in Training Featured Poster

you can use methods of the java String class to extract hello world out of the string above. the methods are all listed there. i dont know much about web stuff , but feed the above into a string , and apply the methods you think will be best from the list.

your best bet will be regexes imo , if you're familiar with them. if not , and you want to try them out , this may help you.

somjit{} 60 Junior Poster in Training Featured Poster

this might help... the part about converting the encoding standard to UTF-8. unless of course you have already tried that.

somjit{} 60 Junior Poster in Training Featured Poster

i saw php being discussed here , as is other languages.. so i thought maybe it wont hurt if i ask about one more language.

somjit{} 60 Junior Poster in Training Featured Poster

the OP asks something i have pondered over myself a number of times , but didnt ask anywhere feeling i might be tagged as vague and asking something without any objective. but regarding php , i would like to know how node.js stands against it. also, when it is said python speeds up development , development of what of things exactly ? pardon my ignorance as im just a few months old java programming student.

somjit{} 60 Junior Poster in Training Featured Poster

??? Nobody has any such method! There is a toDate(String str) method, and it's obvious where that gets its String.

the static part was troubling me a bit , so i posted. it works im sure , but i felt a little more info would have been more helpful.

somjit{} 60 Junior Poster in Training Featured Poster

godzab : from where will your toDate() method get its string? from a constructor? if that is so , then this will not work. the static will run before the constructor , so it will not know from where to get the string the code mentions.

else , if you wish to do something like

    public static void main(String args[]) {
        String s = "2013/april/27"; // the input string
        Date.toDate(s); // no "new" here , just calling the static directly and calling the constructor from within it
        .
        .
        .

imo , the toString() method becomes redundant , as you no longer can do something like this

System.out.println("output : " + DateObject); // DateObject would be the instance created in main through the "new" keyword

im not saying it wont work , but you provided too little information on how that code should be implemented.

somjit{} 60 Junior Poster in Training Featured Poster

in java , if you dont provide a constructor , java provides one for you , but if you do give one , then java will follow that constructor only. you have a constructor for objectView , but you dont put anything inside it. plus , i dont think i saw any main method in your code, that would have helped in understanding your problem. also , line 45 , whats with the new FileObject ?

somjit{} 60 Junior Poster in Training Featured Poster

if you dont understand the problem yourself... it would be better to first clear it out from your teacher.
As it stand now , its hard for us to help out as the problem itself isnt clear. you can post back here after you clear that part out , or mark it solved , 'cause none of us know what to solve in the first place.

somjit{} 60 Junior Poster in Training Featured Poster

i ran your code , seems to work...

perhaps i didnt get your problem. by the way ,

The largest row index : 2
The largest column index : 2,3

i know i didnt understand that part...

somjit{} 60 Junior Poster in Training Featured Poster

@spowel4 : i apologise for my 1st post, as i google , i see that i didnt comprehend a lot of stuff , and made the post with simple file parsing ideas running in my mind. this is a problem more advanced members.. sorry.

somjit{} 60 Junior Poster in Training Featured Poster

you can pass the level of the shooter to the enemy class , then do a switch case statement like :

        shooting = true;
        switch(level){ // the shooters level

            case 1:
                counter = 20;// reset
                break;
            case 2:
                counter = 10;
                break;
            case 3:
                counter = 5;
                break;
            default:
                break;

        }
somjit{} 60 Junior Poster in Training Featured Poster

what do you want the delimiters to be? how do you want to parse it? these are important factors when u decide to parse something, and im unable to get much information regarding these from your code.
personally, iv always used bufferedReader and string split methods for parsing with good results in good timing too , and the file you provided , shouldnt be too hard to parse either. but , need to know about the above two factors.

somjit{} 60 Junior Poster in Training Featured Poster

if your problem's solved , please do mark the thread as solved too :)