Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I had been reading two books on JAVA and while covering data structures, I started to do some online research with regards to "QUEUE" implementation. I have an extensive background in FLEX, however ACTIONSCRIPT isn't comparable to advance languages.
Lets say if I was on a job interview and asked to implement a Queue of Object, how should I pursue it as? I am not looking for code help here, I would like to what would you quick answer be? I have been to Java online docs and do understand there are 13 known implementing classes, and "LinkedList" is one of them.
Google search has return more results with "LinkedList" implementation code than any other.
My apologies if you find this question to be rubbish or pointless in anyway.
Oracle's Java online doc ref:
Do you know what the concept of a queue is and how it differs from a stack (closely related data structure)? If so, you should be able to think of multiple ways to implement it.
Which is best depends on the exact requirements of the task it's being used to address.
So the right response to that interview question is not to start coding but to ask them for more information about the requirements your implementation has to address. Performance? Memory size? Multitasking? Any limits on maximum queue depth, eg to guard against things like a DOS attack? What's being enqueued -- objects, primitives, other? Specific kinds thereof? Parameterized type? Are there any values which should be discarded (maybe null shouldn't be enqueued)?
Knowing the requirements, you should be able to judge which answer is appropriate. Starting coding without asking the requirements is immediately going to earn you a demerit.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I understand that this question is very vague, but I'm trying to figure out a thought process to find out which collection is better to use when it comes to managing data.
I guess I'm just wondering if there is anything that screams "USE THIS ONE!", such as:
Big Data sets, lots of insertion and searching for a specific value: Best Collection Type
Big Data sets, sorting and data manipulation: Best Collection Type
Big Data sets, sorted by last add: Best Collection Type
Big Data sets, delete or move an item after x about of time: Best Collection Type
etc...
Little research
Assuming you are asking for decision-support, rather than for an opinionated "best-practice", I did a little research to find guidelines, comparisons, or even decision-charts.
Articles explaining the benefits and usage of collections
Here you find each of the major Java Collections explained:
Java Collections Cheat Sheet.
Here you find a list of questions to ask in order to choose the right one, as well as best-practice for using collections and their methods:
18 Java Collections and Generics Best Practices
Articles containing flow-charts for collection decision
I also found some decision flow-charts at similar question Rule of thumb for choosing an implementation of a Java Collection?, e.g. originally from Sergiy Kovalchuk's Blog:
Or viewed from different perspectives in LogicBic's tutorial Java - Collection Interfaces and Implementations
Maybe some SO-members would like to share their most applied Collections, with practical use-cases or experience from the professional field.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
For practice I want to make my own lists and maps (like ArrayList, HashMap, HashSet etc.).
My goal is to have it as small and flexible as possible while still maintaining good performance. (long road...)
I have some questions:
1)
Unlike the sun, I don't have to take backwards compatibility into account.
So the first thing I wonder, is there any good reason to keep add and put?
Why not just one?
If I would name put > add would this give problems / complexity / unclearness down the road?
2)
Are there any languages known to have really good data structures? (For example, they could be really smart to avoid a concurrency exception).
3)
As last more a request then a question, if you have any tips our vision of how things could be done different then please post them.
There is no duplicated methods, Collection's have add method that returns a boolean, Map's have put method that returns type associated to Map.
There are plenty of examples of data structure, the point is, ¿what you need your data stucture do best? Avoid concurrency? sort? be fast? store securely?
The examples you need are directly in Java source code:
SOURCES
List
ArrayList
HashMap
and so on....
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please explain me the differences over time and space complexities in java for user defined and predefined functions in java. examples like, linked list, list, stack class. please explain this with valid example.
thank you.
There is nothing special in predefined function over user defined. The only thing is predefined has been written by somebody else for you. It depends on algorithm.
Crap code/implementation runs in a crap way. Doesn't matter if its user created or system/API provided. example at a high level is EJBs vs Spring.
Good written code runs pretty and sleek. Again doesn't matter who the hell wrote it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have noticed that the updateDocument method takes only one Term in its parameters.
I find it strange because the deleteDocument can take multiple terms or even a query to select the document(s) to be deleted...
Why does updateDocument not let us specify more than one Term ? Is there a technical reason behind it or is it just that it hasn't been implemented yet ?
Disclaimer: I did not write this code nor I know the exact reasons, so I can only guess.
First of all, update in Lucene has always meant combination of delete + insert whereas delete has always been single operation. Yes, update is now atomic but you still need to .commit() for changes to take effect.
Secondly, I guess it's hard to design clean API for updating multiple documents. For each document (which itself is a collection of fields) you would have to pass a collection of terms, so for multiple documents you would have to have a collection of collections (or a specially designed command object), yuck. And when in doubt, leave it out! What's wrong with asking a customer to have a loop? It's not that complex really.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am doing a project on social media slang identifier.I have to identify abbreviations from different comments.But the problem is that, suppose in a particular comment it's written GM (means Good Morning) and at the same time in some other comment it's written again GM (means General Manager).
So I need to differentiate between these two, although it shows same in both case (i.e. GM).
I am really confused in this problem.I am not getting any idea for this.
Can any one help me to overcome from this?
This is a hard problem. You need some semantic algorithm to make this distinction.
You cannot infer the meaning just from the syntax or just from the textual representation.
Google "disambiguation natural language processing". You will see lots of resources.
This is just to give you a hint. As said the problem is broad and complex.
This sounds like a very complex issue.
From my understanding of it you would need a quite large dictionary of these abbreviations and also, the lexical field (a.k.a. semantic field) in which they are used.
In order to detect the lexical field you could also group the speakers into "work related" or "colleagues from university" or "drinking buddies", and maybe have a standard for these groups, so that data from other users is also used. In order to understand this, maybe you can understand a sort of synonym of slang, which is argot.
So for instance, if someone says "the GM's feedback was actually pretty good" not only do you understand that it is a usual noun but feedback is also from the "business" lexical field.
An actual time frame, and data you'd work with would be useful, and I will edit this answer accordingly.