data-structures

Difference between vertices and edges [Graphs, Algorithm and DS]

I've just now started reading an Algorithms book that defined Graphs as follows: Graphs – which represent relationships between arbitrary pairs of objects. Figure 1.8(b) models a network of roads as a graph, where the vertices are cities and the edges are roads connecting pairs of cities. Graphs are likely the object in q...

Best data/display choice for 'simple' address book application

I've started hacking together a little application for managing a list of addresses and contacts. I fancied going the way of using XmlSerialization on custom objects, but have come up against a first hurdle in that I can't sort a DataGridView on a custom object collection without implementing BindingList. Which has got me wondering whet...

When is an ArrayList preferable to an array in Java?

When should I use an ArrayList in Java, and when should I use an array? ...

position index for binary heap priority queues?

So let's say I have a priority queue of N items with priorities, where N is in the thousands, using a priority queue implemented with a binary heap. I understand the EXTRACT-MIN and INSERT primitives (see Cormen, Leiserson, Rivest which uses -MAX rather than -MIN). But DELETE and DECREASE-KEY both seem to require the priority queue to ...

Which ML implementation for working throughthe book " purely functional datastructures"?

Hi, I was using Moscow ML to work through the exercises in PFD till I hit chapter on Lazy Evaluation. Mosml implementation does not have any thing like $ notation described in the book. Mosml comes with suspension datatype but I cannot use pattern matching as described in the book. Which implementation of ML did you use to work though...

Finding dictionary words

I have a lot of compound strings that are a combination of two or three English words. e.g. "Spicejet" is a combination of the words "spice" and "jet" I need to separate these individual English words from such compound strings. My dictionary is going to consist of around 100000 words. What would be the most efficient by which I...

[Java] What are the pros and cons of a TreeSet

Just wondering what the pros and cons of a TreeSet is, if anyone could tell me please? Thanks! ...

php data structure - xml or tree?

i want to write a generalized function that can output something like this. <span class="side_title">By Collection</span> <ul class="menu"> <li class="top"> <a class="top_menu" href="#url">home</a> </li> <li class="sub"> <a h...

How to convert a vector<pair<int,int> > to multimap<int,int> efficiently?

How to convert a multimap<int,int> to vector<pair<int,int> > efficiently EDIT: Sorry for the trouble I was actually looking for converting vector to map ...

Which datastructure is appropriate for this situation?

I'm trying to decide which datastructure to use to store key-value pairs when only features needed are insertion lookup Specifically, I don't need to be able to delete pairs, or iterate through keys/values/pairs. The keys are integer tuples, the values are pointers (references, whatever). I'm only storing a couple million pairs spr...

Java Datastructures

Greetings, I've been working out of an embedded version of Java where the height of complex structures included in the API was a vector or queue. This usually meant writing structures from scratch when needed. I am now coming back to the land of the living, I will have full access to a real version of java with all the bells and whis...

Hash tables in prolog

I was solving a puzzle in prolog the other day and realized that were I using another programming language, I would have made use of a hash table/dictionary, but as far as I know this isn't really possible in prolog. So my first question is are there any prologs that support a dictionary-like data structure with the performance charact...

Big Number Subtraction in C

I just finished my exam in an introductory C course about 20 minutes ago. The first question on the exam caught me somewhat off guard, and involved finding the difference two large numbers. The goal was to take two structures (N1 and N2) by value, and store the difference in a structure passed by reference (N3). We were allowed to assum...

which data structure is appropriate to query "all points within distance d from point p"

hey there! i have a 3D pointcloud and i'd like to efficiently query all points within distance d from an arbitrary point p (which is not necessarily part of the stored pointcloud) the querry would look something like Pointcloud getAllPoints(Point p, float d); what accelerationstructure would be appropriate for this? A range-tree see...

Key-ordered dict in python

Hello, I am looking for a solid implementation of an ordered associative array (in terms of keys, not of insertion order). More precisely, I am looking for a space-efficent implementation of a int-to-float (or string-to-float for another use case) mapping structure for which: Ordered iteration is O(n) Random access is O(1) The bes...

java.util.Stack appropriate data structure?

Hmm. I'm noticing Stack is a subclass of Vector, and I thought Vector and Hashtable were considered "old" datastructures because of their builtin synchronization even if you don't need it. (vs. List, Map, etc. which don't provide it for you) That and it's a class, not an interface. Is there a more modern, recommended alternative? ...

Ropes: what's "large enough to benefit from cache effects"?

From Wikipedia: The main disadvantages are greater overall space usage and slower indexing, both of which become more severe as the tree structure becomes larger and deeper. However, many practical applications of indexing involve only iteration over the string, which remains fast as long as the leaf nodes are large e...

How to pass Map to Oracle PL/SQL function?

Hi, I would like to create an equivalent if this Java method as PL/SQL function in Oracle 10g: String myMethod(int par1, Map<String, Object> par2); Is it possible to pass a Map (or some simillar structure) to Oracle PL/SQL function? I have to be able to call this function from Java somehow. ...

Multi-threaded Queue in C#

I've been tasked with working on a download queuing system but I'm a bit confused about where to start. Essentially what we need to do is to have something like a download manager (but not as fully blown). We have about 20-100 files to download, we give the user a UI (with a listview) to allow them to pause, stop, or move the priorty of...

How to specify maxExclusive on struct?

I want to create a structure Degrees for a GPX library. In the XSD for GPX (GPX 1.1 Schema) degreesType is defined as minInclusive = 0 and maxExclusive = 360. The structure now shall have two public static fields MinValue = 0 and MaxValue = x: public struct Degrees : IFormattable, IComparable, IComparable<Degrees>, IEquatable<Degrees> {...