data-structures

Why doesn't .Net have a Set data structure?

One of my biggest issues dealing with a move from Java to .Net is the fact that there isn't a Set interface in .Net. I know there are libraries I could go and download but what is the reason for not having it built in? There are Maps (Dictionary) and Lists but why not a Set? Edit: I should clarify that not everyone uses .Net 3.5 yet -- ...

structure initialization

static struct Args { char* arg1; unsigned arg2; unsigned arg3; char* arg4; } arg; My program saves command line args to a structure. Sometime all of the members are set... sometimes only a couple of them. In the case where only arg1 is set, what would the best practice be to do with the rest of the members? Thanks. ...

Passing data of a non-primitive type between activities in android

Suppose you want to start a new activity and pass it some data from the current activity. If the data is of a primitive type you could simply use an intent and add extras, but how would you do this for more complex data structures like arraylists or objects? ...

Which library to use for C data structures with GCC

Hello all, I'm about to start a new project in C. I'm currently investigating a library for C data structures. I've found plenty of them. But which one would you recommend? I'm currently considering to use gdsl or glib . The important properties of a library for me is: Robustness and reliability of the code. Documentation. Readabilit...

[iPhone] Large data hierarchy - How to realize?

Hi guys, I am still trying to develop a small medicine iPhone app. :-] In the last few days I've structured all the data that should be displayed in a table. After reading books and watching a lot of tutorials I've built a couple of simple Table View applications. These apps always had a predefined depth of data. I am not sure if you un...

alternatives to php in_array for large arrays for avoiding duplicates entries

I need to generate a large list of random numbers from 600k to 2000k, but the list can not have duplicates. My current 'implementation' looks like this: <?php header('Content-type: text/plain'); $startTime = microtime(true); $used = array(); for ($i=0; $i < 600000; ) { $random = mt_rand(); //if (!in_arr...

How does one make a Zip bomb?

This question about zip bombs naturally led me to the Wikipedia page on the topic. The article mentions an example of a 45.1 kb zip file that decompresses to 1.3 exabytes. What are the principles/techniques that would be used to create such a file in the first place? I don't want to actually do this, more interested in a simplified "how...

implement a telephone address book - reverse index

Now I am trying to come up with a data structure for implementing a telephone adreess book. Say there are two infos : name, telephone numbers. The same name can have more than one number. Now i would like to come up with a data structure that will help me in fetching the number given a name and fetching the name, given a number. I have t...

[c++ / pointers]: having objects A and B (B has vector member, which stores pointer to A), knowing A is it possible to retrieve pointer to B?

Hello, While trying to learn c++, I tried to implement class representing very basic trie. I came up with the following: class Trie { public: char data; vector<Trie* > children; Trie(char data); Trie* addChild(Trie* ch); // adds child node (skipped others members/methods) }; Method addChild checks if child c...

Non-recursive post order traversal

Hi, I saw the following post order traversal algorithm in some website... it seems to be correct. I just want to verify that this algorithm works correctly — is this algorithm correct for post order traversal without recursion? void postOrderTraversal(Tree *root) { node * previous = null; node * s = null; push(root); w...

Looking for a good C++ book on data structures

I'm looking for a good book on C++ and data structures that would teach me everything about linked lists, how to reverse them, arrays, how to reverse them in place and any other tricks that seem to pop up during C++ interviews lately. ...

Storing Custom Classes in Objective-C

I need to take existing classes for an iPhone application and store them in a preference/plist/some other data storage format. A good comparison of what I need to store is a gradebook, with the following class structure: GBGradebook + NSArray (GBAssignment) + NSArray (GBClasses) + NSArray (GBStudent) GBStudent + NSString *stude...

Visual Explanation Guidance needed for reversal of Linked List datastructure code ?

Hi, I have following piece of code for reversing the linked list. I am getting confused in while loop and so would certainly appreciate if someone can provide visual explanation of how actually it's working. static void Reverse (struct node** headRef) { struct node* result = NULL; struct node* current = *headref; stru...

another Game of Life question (infinite grid) ?

Hi friends, I have been playing around with Conway's Game of life and recently discovered some amazingly fast implementations such as Hashlife and Golly. (download Golly here - http://golly.sourceforge.net/) One thing that I cant get my head around is how do coders implement the infinite grid? We can't keep an infinite array of anythin...

Records to Tree

Hi Guys, A little advise please. I am trying to create a tree out of following rows of data: TOP Level1 NotLeaf Level1 Data1 leaf TOP Level11 NotLeaf Level11 Level2 NotLeaf Level11 Data4 leaf Level2 Data2 leaf Level2 Data3 leaf The last column shows whether a node is a leaf...

Java OS Process Queue

I'm using the native ProcessBuilder class to create a variably sized list of process objects. Currently, I simply roll through the list calling the start method on each Process instance. I would however like to better control this aspect of the application by limiting the number of my running processes to a custom value (e.g. number of p...

Query engine for a variable data source. C#

I have a growing set of Excel spreadsheets none with the same data structure. I need a mechanism to query each of these spreadsheets (DataTables) using a single interface. So essentially, you choose the DataTable from a dropdownlist and then perform your search. My initial thought was to handle it like this. Create a generic data str...

Does the Java API have a data structure to represent hierarchy

I've got two classes; one interprets commands, and sends these commands to another class which executes them. I then want the class which executes the commands to be able to send the results of this execution back to the interpreter class. The problem is that these results are hierarchal in nature. Right now the only thing I know of i...

Data structure for fast line queries?

I know that I can use a KD-Tree to store points and iterate quickly over a fraction of them that are close to another given point. I'm wondering whether there is something similar for lines. Given a set of lines L in 3D (to be stored in that data structure) and another "query line" q, I'd like to be able to quickly iterate through all l...

How to Deal with Algorithm/Data Structures Problems in Interview Process ?

Hi, Recently I have been interviewing for quite a few Software Development Engineering position and almost every interview I have faced have been concentrated heavily on Algorithm and Data Structures, am wondering how could it be possible to face an unknown problem and design an algorithm for it using appropriate data structures that to...