data-structures

How can i store data in C in a tabular format?

Hi, I want to store data in C in tabular format. I am having difficulty in relating the following. Can someone help? For example: I want to store the follwong entries, then what should be the ideal way of storing in C? IP Address Domain Name 1.) 10.1.1.2 www.yahoo.com 2.) 20.1.1.3 ...

How do I compare two complex data structures?

I have some nested datastructures, each something like: [ ('foo', [ {'a':1, 'b':2}, {'a':3.3, 'b':7} ]), ('bar', [ {'a':4, 'd':'efg', 'e':False} ]) ] I need to compare these structures, to see if there are any differences. Short of writing a function to explicitly walk the structure, is there an existing library o...

Most elegant way to break CSV columns into separate data structures using Python?

I'm trying to pick up Python. As part of the learning process I'm porting a project I wrote in Java to Python. I'm at a section now where I have a list of CSV headers of the form: headers = [a, b, c, d, e, .....] and separate lists of groups that these headers should be broken up into, e.g.: headers_for_list_a = [b, c, e, ...] header...

Persistent (purely functional) Red-Black trees on disk performance

I'm studying the best data structures to implement a simple open-source object temporal database, and currently I'm very fond of using Persistent Red-Black trees to do it. My main reasons for using persistent data structures is first of all to minimize the use of locks, so the database can be as parallel as possible. Also it will be eas...

Data Structure Used For SMS Messages In Android

Does anybody know what data structures are used to the store messages in an SMS client app, and whether there is an existing API for this. I was perhaps looking at implementing a link list for the purpose but if the work has already been done in an API then perhaps it would be unnecessary to commit time to the task that could be spent p...

Java: immutable stack?

TERM Immutable Stack: I overuse stack. Poly's reply uses Collections.emptyList() as immutable list. No Collections.emptyStack(). Combining the words stack and immutability, from the last experiences, gets "immutable stack" (probably not related to functional prog). Java Api 5 for list interface shows that Stack is an implementing class...

Local File-type Datastore for Winforms

Hi there! I hope my title is not misleading, but what I'm looking for is a file-type datastore for a Winforms app (.NET 3.5) that will allow me to: store/retrieve strings and decimal numbers (only); open and save it to a file with a custom extension (like: *.abc); and have some relational data mapping. Basically, the application sh...

How to generate Markov Chain in C#

I want to create this Markov Chain in C#. I need to know if there is any other structure other than adjacency list which can work better in this situation. Also how can I use the existing .Net collection type to implement this. ...

How to create wordpress-like option table and get values for each row?

Hi guys. I'm looking to create an options table in my db that makes every record a system option, so I can work with a little number of fields. My db has the following structure: 3 columns named id, name, and value The following data is inserted as an example: +--+-----------+--------------------------+ |id|name |value ...

Java: over-typed structures? To have many types in Object[]?

Term over-type structure = a data structure that accepts different types, can be primitive or user-defined. I think ruby supports many types in structures such as tables. I tried a table with types 'String', 'char' and 'File' in Java but errs. How can I have over-typed structure in Java? How to show types in declaration? What about i...

Best datastructure for frequently queried list of objects

Hello, I have a list of objects say, List. The Entity class has an equals method,on few attributes ( business rule ) to differentiate one Entity object from the other. The task that we usually carry out on this list is to remove all the duplicates something like this : List<Entity> noDuplicates = new ArrayList<Entity>(); for(Entity en...

c++ lists question

I want put a value from front of the list into an another list but I am getting an error. for exmaple List<int> li; List<int> li2; ............. ............. li2.push_back(li.front()); // this statement doesnt work for me. Can someone please help me. example code: list<int> li; list<int> li2; li.push_back(1); li.pus...

Rowwise iteration of a dictionay object

I have a dictionary object like: Dictionary<string, HashSet<int>> dict = new Dictionary<string, HashSet<int>>(); dict.Add("foo", new HashSet<int>() { 15,12,16,18}); dict.Add("boo", new HashSet<int>() { 16,47,45,21 }); I have to print in such a way such that result would be as following at each iteration: It1: foo b...

Advice on simple efficient way to store web form data when no db/auth required

Hi, I have a situation where I need to provide an efficient way to process and store comments submitted via a web form. I would normally use PHP and either MySQL or XML to store the data, but this is slightly different in that this web form will only be temporarily available in a closed LAN environment, and all i need to do is process th...

A question on getting number of nodes in a Binary Tree

Dear all, I have written up two functions (pseudo code) for calculation the number of nodes and the tree height of a Binary Tree,given the root of the tree. Most importantly,the Binary Tree is represented as the First chiled/next sibling format. so struct TreeNode { Object element; TreeNode *firstChild; TreeNode *nextSibling; } ...

Is there a way to generate a short random id, avoiding collisions, without hitting persistent storage?

If you've used GoToMeeting, that's the type of ID I want. I'd like it to be random so that it obfuscates the number of items being tracked and short, so that it's easy to reference manually; UUIDs are way too long. I'd like to avoid hitting persistent storage merely for performance reasons, but I can't think of any other way to avoid col...

Should I learn about data structures & algorithms first or the programming language java first ?

I am a beginner to programming. Should I like learn them side by side ? Now that I know DS and Algorithms form the basis of programming..Should I learn them first ? I am confused. What should be my learning path ? I want to be a really good Java programmer. ...

Secondary keys in a B-tree

Let's say that there is a file that contains an unsorted list of student information, which includes a student ID number as well as other information. I want to make a program that retrieves student information based on student ID number. In order to make it efficient, I store the student IDs in a B-tree. So when I enter a student ID ...

What's the right way to do mutable data structures (e.g., skip lists, splay trees) in F#?

What's a good way to implement mutable data structures in F#? The reason I’m asking is because I want to go back and implement the data structures I learned about in the algorithms class I took this semester (skip lists, splay trees, fusion trees, y-fast tries, van Emde Boas trees, etc.), which was a pure theory course with no coding wha...

Are interval, segment, fenwick trees the same?

Today i listened a lecture about fenwick trees (binary indexed trees) and the teacher says than this tree is a generalization of interval and segment trees, but my implementations of this three data structures are different. Is this afirmation true? and Why? ...