data-structures

How to store bidirectional relationships

I am writing some code to find duplicate customer details in a database. I'll be using Levenshtein distance. However, I am not sure how to store the relationships. I use databases all the time but have never come accross this situation and wondered if someone could point me in the right direction. What confuses me is how to store the...

Microsoft Bing?

What is the name of the algorithm used in Microsoft BING Search engine? ...

Convert a variable length struct to byte[]

I'm trying to send a network packet of data to a hardware device. I would like to use a slick, object oriented approach so I can work with it at a high level. The packet has several fields of variable length. Obviously the byte layout is very particular. Here's a struct representing the packet I need to send: [StructLayout(LayoutKind.S...

How best to store VERY large 2D list of floats in c++? Error-handling?

I'm migrating some code from c to c++. I've changed some malloc calls for structure memory allocation to new calls. Basically before the code I'm porting was malloc'ing arrays that contain multiple sets of frame coords, each a couple hundred thousand floats in length -- so the total array length could be in the tens of millions of co...

Fast algorithm for repeated calculation of percentile?

In an algorithm I have to calculate the 75th percentile of a data set whenever I add a value. Right now I am doing this: Get value x Insert x in an already sorted array at the back swap x down until the array is sorted Read the element at position array[array.size * 3/4] Point 3 is O(n), and the rest is O(1), but this is still quite ...

Good problem solving and data structure questions?

Possible Duplicate: Algorithm/Data Structure Design Interview Questions Share some of good problem solving and data structure questions for hiring a fresh programmer. ...

Core Data - Sorting results conditionally on values from a to-many-relationship

Hello I have an app with an Event entity that has a to-many-relationship to a Date entity that contains MULTIPLE startDates and endDates for each event. In my list view I need to sort the events by the next available startDate (or endDate) from the to-many-relationship. First I created a transient property in the Date entity that made a...

Pictures Filenames - GUID or ID-based, When to use which

Hi, I tend to rename a profile user uploaded picture to the corresponding id of that column in the profile table, but recently i saw several projects adding an extra column in the table to identify the related photo (uniqueid, md5 or guid), what is the benefit of doing that, i see it redundant as i can already identify the photo with th...

Why is it important to assume that integers in our computer model have a fixed size?

Why is it important to assume that integers in our computer model have a fixed size? ...

Can I use java.util.LinkedList to construct a circular/cyclic linked list?

I would like to create a circular/cyclic linked list where the tail of the list would point back to the head of the list. So can I use java.util.LinkedList and modify the tail node after creation of the list to make it circular/cyclic? If so, can you show me some code on how that would happen? If I can't use java.util.LinkedList, how sh...

How to convert a binary search tree into a doubly linked list?

Given a binary search tree, i need to convert it into a doubly linked list(by traversing in zig zag order) using only pointers to structures in C++ as follows, Given Tree: 1 | +-------+---------+ | | 2 3 | | +----+---+ ...

Find the smallest window of input array that contains all the elements of query array

Problem: Given an input array of integers of size n, and a query array of integers of size k, find the smallest window of input array that contains all the elements of query array and also in the same order. I have tried below approach. int[] inputArray = new int[] { 2, 5, 2, 8, 0, 1, 4, 7 }; int[] queryArray = new int...

Storing large tile based maps for an online multiplayer game

Hi All, I'm currently making a tile based mmorpg and am trying to find a good way to store a large 2d game world (at least 1000 squared tiles, but hopefully more like a few thousand squared). The idea is to encourage people to make their own cities on the shared map and users will be able to build houses and shops ingame so the tiles wou...

Data Structures and their Database Mapping in .Net

Hello. From what I know, complex data structures (tree, binary tree, graph) are not available in the .Net Framework Base Class Library. Is there a good 3rd party library available for this purpose? Further, I need to map these data structures back to a physical database (SQL Server). Is such an extension available? I'd love to have a to...

Store data in txt/xml file, read/write to database?

My wordpress theme accepts skin files. These skin files all install into my main theme folder via a zip uploader that's part of my theme. Each skin has a set of custom color codes (4 in all) that are stored in the wordpress options table like so... Assume the skin name is "halloween"...These are the values in my options.php for one of ...

What algorithms / optimisations are there for calculating a conditional subset of elements from an array?

My program often deals with large quantities of data, and one particular component of it creates a subset of that data, based on a condition. You could view this as, having the string, 10457038005502 the problem is to return the first five (say) non-0 elements, that is to return: 14573 In actual fact, each element of this string i...

Saving a trie to disk

Hello. This sounds like a simple question, but I don't know how to search for its answer. I have a trie implementation in C# that will store about 80K words from a dictionary file. It takes quite a while to load all these words (more than 5 mins). I was wondering, what is the best way to "persist" those data so I don't have to reload al...

An effecient datastructure to hold structure variable with sorting capability

Hi ppl, I have a structure struct dbdetails { int id; string val; }; I need a data structure in C++ that can hold structure variable with a sort capability. Is it possible? im a newbie. Sorry If this questions is wrong. I was looking at vector, which can hold structure variable, but I will not be able to sort it based on id ...

Indexing: Implementing Tree data structures with Arrays/Vectors

I have been implementing a heap in C++ using a vector. Since I have to access the children of a node (2n, 2n+1) easily, I had to start at index 1. Is it the right way? As per my implementation, there is always a dummy element at zeroth location. ...

User Access Control and Data Visibility

I have a Access Control based on Roles and Permissions, meaning That each group has permissions to access Some Controllers and users are part of those groups. (this is implemented in CakePHP framework) But this structure allows me to know what user is authorized to "use" like, access reports or add new users, but I was wondering what ar...