Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Anayonkar Shivalkar wrote:Hi Andy,
Logic wise, I don't see anything odd in your code.
However, if I were the interviewer, I would ask below questions:
1) How are you getting value of isSorted? That is - how are you deciding that the array is sorted? And more importantly, why are you deciding it? By default, binary search works only on sorted arrays; and deciding if an array is sorted or not might take more time in case of very large arrays.
Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
fred rosenberger wrote:There's really no reason to ever do
Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Andy Jack wrote:
Pat Farrell wrote:If I were asking the question, I'd expect you to not write a binary search algorithm, but rather to use one of the Java Collections framework structures. The Collections framework are robust, fast, and well tested.
The goal should not be to re-write the wheel, but to pick the right wheel and use it.
Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Andy Jack wrote:
fred rosenberger wrote:There's really no reason to ever do
I am not able to understand why we should not do that ?
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Anayonkar Shivalkar wrote:
Andy Jack wrote:
fred rosenberger wrote:There's really no reason to ever do
I am not able to understand why we should not do that ?
I missed this
The main reason you are not supposed to do this is - if by mistake you write something like:the code will compile, and will assign false value to isSorted (needless to say, it will never enter inside 'if' condition).
Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|