Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

praveen kumaar

Ranch Hand
+ Follow
since Apr 10, 2016
praveen likes ...
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
i am 23 and a batchlor.presently i am learning .i have left my studies in 2011 after a school completion due to some personal reasons but in the gap years i usally think what i like to do and what i am doing..i felt boring all the day and then i decided to start again because i think to make a end of something you must start..and now a days i am practicing java (and doing b.c.a,to complete graduation) to grow more on it..atleast i am satisfied because i am doing the thing i like to do..somehow and someday maybe the samething make me to earn..
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by praveen kumaar

Hi folks.
i have tried to implement a generic data structure called Tournament with c language.
i have kept the documentation in the header file and done a unit test with CUnit framework however i am not attaching the test code here in this post as it gets too long, i am attaching the github link though.
I have used the Doxygen standard for the documentation.
here is the code:


Here is the test code with CUnit.
please share any improvements that can be done.

kind regards
6 months ago
well thanks again rob. i caught the mystery of qsort. the author has just utilize some pointer arithmetics. what they have done is: since in qsort the the original data type is unknown, they have moved(or manipulate) the item(to be sorted) whose size is known through moving bytes(or whatever is the size of char).
so casting a pointer merely changes the policy for its arithmetics(i learnt something i do not know or skipped). please correct me if i am wrong anywhere.

6 months ago

Bear Bibeault wrote:
...Please don't change the question in the middle of a topic

okay i got it bear, i will mind it for the next time. anyway thanks for moving the question to a new topic.
6 months ago

Rob Spoor wrote:To use any void *, you'll need to cast it to X * where X is the actual type. You can then de-reference the cast result. For instance:

Thanks for the help rob but i know all those things about casting.
for the time being lets forget about my original problem.
can you give me some  details or elaborate about the implementation logic of the library quick sort function, i have attached a link for the source code of the function. i do not understand how it sorts the collection of items of any data type, it internally operates on char pointers where in my opinion it is casting the pointers to data type to be sorted to char pointers, isn't look strange....

please help!

6 months ago
I am trying to implement a data structure traditionally called a 'tournament tree' in 'C language'. the prime problem that i experience is the dereferencing the void pointers, i know its not possible in c and the reason being quite intuitive but i need to figure out the alternative. lets see my code first, its not compiling due to the same problem:

what i am trying to do is something similar to the standard library function qsort. but when i see the source code of this function-qsort, the author has internally used char pointers. this function
is capable of sorting any data type then how can they cast all of them to char type.

please help me to figure it out!!

For those who need to know about tournament data structure here it is -> Tournament Tree.

6 months ago
but you can design your own. do use of greatest common divisor. write your own method.
8 months ago

Campbell wrote:...Integer multiplication in done modulo 2³² in Java®
...I have probably got that wrong...

might be!
since even the jvm specs had not involve any such details regarding it. however it just mentions some instruction sets or mnemonics for its assembly like imul which might get delegate to different instruction set for your and mine computers processor. there is a chance that it will use modulo 2³² on yours and some other algorithm on mine. however since implementation matters here i would like to keep my hands away from it in view of the standards main aim.
8 months ago

Liutauras wrote:Just simply as: Arrays.sort(new int[]{3, 1, 4, 2})

still here the argument has a name from the inside of the sort method which is 'a' however the reference is unreachable for the user still the fact remains the same which is that array has name.

for me the author uses those terms just for introducing their readers that programmers have just made their own nomenclature and that gots famous. nevertheless they should atleast say something like the standard doesn't call it anything like so.

another similar example is in the same book i reffered in my previous post, the authors use the term modulus operator which is indeed ambigous according to what the modulus means java has already named it remainder operator but they had not even introduced this term. modulus is always non-negative as per euclidean division identity however % is well known to give -ve results.
if jeanne is reading this post their is my request to her for these changes. that would make the concept and the content  more powerful, appealing and simple and straight forward. i hope she will read it.
8 months ago

Liutauras wrote:First of all, that code wouldn't compile (assuming you have someObject in place). But anyway...

yes that wouldn't compile. i wrote it just for clarifying some point, don't take it that way.

Liutaurus wrote:Can you specificy exact book name and page number, please.

Again my fault, i am sorry, i just forget the rule to quote the source or tell the details.
The book name is OCA Oracle certified assosciate java se 8 programmer I study guide by Jeanne Boyarsky and Scott Selikoff. in my edition the page number is 120 chapter 3(Core java api's) under the section creating an array of primitives.
8 months ago

Campbell Ritchie wrote:Interesting point. You mean that from the view of the code I wrote there is no name for the array, but from inside the toString method it does have a name.
Good point. Maybe we shou‍ld stop saying anonymous for anything other than local/nested classes.

i wish i could meet you, not for gaining some insights from your knowledge and experience(ranch is already providing that platform) but for feeling the moment when you deliver your sentences. believe me you do it very smart way with mixing some fun there. still i wish i could have that moment.
you are a genius!
for the same reason

I wrote:i would disagree here...

i waffled to wrote those words several times...

Anyway i would like to correct one thing for my previous post where i wrote that the size of the array is known at compile time. i think about it and had done some experiment. look at this code:
it will compile well which infact will throw exception during runtime but compiling well simply connotes that compiler doesn't know about the size of the array so size of an array is anonymous for compiler for every array.
now for the proof that the all the three arrays will be allocated the same way here is the proof. see this dis-assembled code created from javap instruction:
look at line 1, 17, 33 in main they are all instantiated the same way and array type is also int[] for each of them.
8 months ago
i agree with campbell.

campbell just for your information, jeanne and scott have also used the same term in their famous oca book for array initializer in the context that their type and size are not specified. in my opinion they must have used this term due to the fact that many other books and some online blogs had also used the same naming.

however according to the standard anonymous is used only for anonymous classes due to the fact that the implemented class do not have any name(compiler doesn't know about the name of class during compilation and it is created by jvm during runtime).
so literally if i have to use the term i would just use it in the same context(name).
for array initializers they all are just syntactic sugars. compiler well infers the type and size of even arrays created with array initializers(how, i would not worry about it). so the size and type are also known for arrays like {1, 2, 3} or new int[] {1, 2, 3} during compile time.

look at the method below:

sometimes it is argued that the array initializer like one in main is anonymous in the context that it has not any reference(they just confuse reference with name of the class) but in real their is a reference which is the method parameter 'a' for that array. so in this context also it is not anonymous.

Campbell wrote:You might call it anonymous if you use an initialiser like this:-
The array is here used once only and is never given a name, so it might be called anonymous there.

i would disagree here(please don't get me wrong) as if you will see in the Arrays api the method parameter "a" will be name of the array object so it should not be anonymous.
8 months ago
Hi Nayan!
Actually it will get too broad if i discussed it here.i am attaching two links below.thoroughly go though them,you will get the basic idea for your query.
How and where to apply for an internship in India?
Where can I get a summer internship on Core Java...

best of luck!

kind regards,
@Chris and Joney: And, Welcome to CodeRanch!
1 year ago
First of all congratulations for achieving such milestone.

I deeply salute you for everything regarding your post the quality, the way you organize it, the knowledge or content you put in it..everything.honestly i am a very big fan of your's.
IMO apart from the programmer you are a very good teacher(did you ever feel it).
adore to see you further on ranch.

1 year ago
What is a showArray(...),where it is?.please post your code in full or either put a link for your full code so that we can help you better.
did you have performed the insertion sort after the gap sorting.please show your full code.

1 year ago