Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java questions: Urgent

Reply
Thread Tools

Java questions: Urgent

 
 
Nikil Joshi
Guest
Posts: n/a
 
      01-31-2006
Hi All,

I was asked following questions in my interview so, I would appreciate
that if anyone of u would answer them:

1, how fast is hash map? explain in terms of time complexity?
2.how would u group multile statements as one transaction in JDBC?
3.how woould map inheritance to DB schema?
4.Which method do u overide in hashmap?something related to keys? I may
not be explaining it correctly.

Thanks!

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      01-31-2006
On 30 Jan 2006 20:08:31 -0800, "Nikil Joshi" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>1, how fast is hash map? explain in terms of time complexity?


It depends on how relatively full it is. If you keep it less that 3/4
full your chains will be short and it wont' take any more time to look
up in a big list as a small. But if you let it approach 100% full,
then chains can get very long. In the most pathological case when all
your hashes are equal the lookup time is proportional to N, the size
of the list since all item are one one chain.

See http://mindprod.com/jgloss/hashcode.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      01-31-2006
On 30 Jan 2006 20:08:31 -0800, "Nikil Joshi" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>4.Which method do u overide in hashmap?something related to keys? I may
>not be explaining it correctly.

you don't override methods in HashMap. You override Object.HashCode
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Luc The Perverse
Guest
Posts: n/a
 
      01-31-2006
"Roedy Green" <(E-Mail Removed) > wrote in
message news:(E-Mail Removed)...
> On 30 Jan 2006 20:08:31 -0800, "Nikil Joshi" <(E-Mail Removed)>
> wrote, quoted or indirectly quoted someone who said :
>
>>1, how fast is hash map? explain in terms of time complexity?

>
> It depends on how relatively full it is. If you keep it less that 3/4
> full your chains will be short and it wont' take any more time to look
> up in a big list as a small. But if you let it approach 100% full,
> then chains can get very long. In the most pathological case when all
> your hashes are equal the lookup time is proportional to N, the size
> of the list since all item are one one chain.
>
> See http://mindprod.com/jgloss/hashcode.html


Isn't the textbook answer an order 0?

Then as collisions develop . . .

--
LTP




 
Reply With Quote
 
Nikil Joshi
Guest
Posts: n/a
 
      01-31-2006
It is urgent so that I don't repeat same mistakes in my next interviews.

 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      01-31-2006
Nikil Joshi wrote:
>
> I was asked following questions in my interview so, I would appreciate
> that if anyone of u would answer them:


So why is it urgent?

> 1, how fast is hash map? explain in terms of time complexity?
> 2.how would u group multile statements as one transaction in JDBC?
> 3.how woould map inheritance to DB schema?
> 4.Which method do u overide in hashmap?something related to keys? I may
> not be explaining it correctly.


4. is probably asking which methods from Object would you override when
writing a class designed to be used as a key for a HashMap.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-31-2006
On Mon, 30 Jan 2006 21:28:51 -0700, "Luc The Perverse"
<(E-Mail Removed)> wrote, quoted or indirectly
quoted someone who said :

>
>Isn't the textbook answer an order 0?

no. It is somewhere between 0 and n depending on how ineptly you set
it up.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-31-2006
On 30 Jan 2006 20:33:52 -0800, "Nikil Joshi" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>It is urgent so that I don't repeat same mistakes in my next interviews.


You wont get the same questions. You should have answered "hashCode
and equals"
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      01-31-2006
Luc The Perverse wrote:
>
> Isn't the textbook answer an order 0?


You mean O(1)?

> Then as collisions develop . . .


Supposedly it remains O(1), with lumps. I haven't done or seen the
mathematics to check that.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
Paulus de Boska
Guest
Posts: n/a
 
      01-31-2006
You asked
2.how would u group multile statements as one transaction in JDBC?

This may help if your browser supports Java :
http://javalessons.com/cgi-bin/adv/j...=jdb&sid=ao789

In the Lesson Viewer lookup the paragraph that starts with :'If you
want a couple of update statements', etc.. this applies to the source
code lines 59-71

---
Paul Hamaker, SEMM
http://javalessons.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT RichA <rander3127@gmail.com> For rec.photo.digital MVP of all time. Vote now!! URGENT. Griffin Digital Photography 0 08-27-2010 08:18 AM
urgent help....need urgent help on say string task.. pooja Software 0 03-03-2009 06:16 AM
!!URGENT!! Tor Vulnerability Discovered !!URGENT!! Security Advisory Computer Security 1 08-11-2007 09:04 PM
URGENT !! QUEUE STL PROBLEM URGENT!! Sachin Jagtap C++ 4 04-29-2005 12:08 PM
Urgent problem, repeat, Urgent problem. Rob Javascript 3 05-18-2004 12:05 AM



Advertisments