• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data structure - when some element is put then we can get different element?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I was asked this question in recent interview ?

"Create a data structure named “Magic box” in it when some element is put then we can get different element"

Any Idea ?
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's quite vague.

What was your answer?
 
Vishal Bhadur Verma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:That's quite vague.

What was your answer?



I answered him : That for getting a different element we need to perform some data manipulation while storing the value or we need to give out a different element on enquiring of some other element. Which will be wrong as per implementation.
So what I can do for above requirement is just manipulate the value while insertion. He then moved to another question.
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea I'm not sure you could be any more specific than that. It's quite an abstract question, so invites an equally abstract answer.

Given that he suggested you read up on Spring autowire after answering that other question, and this time he said nothing, I reckon he was happy enough. But who can say, interviewers can be hard to read.
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, the requirement that 'in it when some element is put then we can get different element' sounds vague. I'm guessing either the interviewer didn't frame the question well or perhaps the OP hasn't stated exactly what was asked.

The idea of adding an element and getting a different element as a result of adding an element sounds uncommon, if not weird. However if the interviewer just meant that the data structure should allow you to return an element at random ( any element -- in no specific order ) from the data structure, you could use a randomization logic for returning the element from any datastructure based on the linked lists ( the general term ) / arrays. You could even use a shuffling operation.

Why do you think you might require data manipulation for returning an item?
 
Vishal Bhadur Verma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chan Ag wrote:Yea, the requirement that 'in it when some element is put then we can get different element' sounds vague. I'm guessing either the interviewer didn't frame the question well or perhaps the OP hasn't stated exactly what was asked.

The idea of adding an element and getting a different element as a result of adding an element sounds uncommon, if not weird. However if the interviewer just meant that the data structure should allow you to return an element at random ( any element -- in no specific order ) from the data structure, you could use a randomization logic for returning the element from any datastructure based on the linked lists ( the general term ) / arrays. You could even use a shuffling operation.

Why do you think you might require data manipulation for returning an item?




By Manipulation I meant while storing the element I would have change the inserting element into some random element.. Like if I am storing integers in array and while inserting I would have multiplied the inserting integer with a random number and would have stored it. So if in case it will return a different number.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Data manipulation would be inconsistent with the question as I see it; you are not returning a different element, but the same element.
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I would have asked the interviewer to clarify the question.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is of course the correct thing to do in an interview. Interview questions are different from real‑life questions.
 
Vishal Bhadur Verma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:That is of course the correct thing to do in an interview. Interview questions are different from real‑life questions.



I was terrified with few question , SO never asked him for clarification. In addition to this he asked me this :

"How we can create jars from the client stubs?" and I was like why I will do that. I nodded my head as no to this.
I don't know how to create jars from the client stubs...
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For which I would have answered: What are 'the client stubs'?
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic