data-structures

Mapping a set of intervals to 2D text buffer with text change synchronization

Hello, Here's the problem. I have a 2D text-like buffer (basically List<List<Object>>), indexed by (row, col) coordinates. Each row can have arbitrary length. Let pos = (row, col). Then an interval is defined by (fromPos, toPos). The text buffer can be modified by inserting and deleting characters: void addRow(int rowIndex, Row<T> ne...

swapping adjacent nodes in a Linked list

I have problems swapping adjacent nodes in a linkedlist. for ex: input : 1->2->3->4->5->null output: 2->1->4->3->5->null bool swapAdjacent(node** head) { //1->2->3->4->null //2->1->4->3->null if(head==NULL) return 0; node* current = *head; *head = (*head)->next ; node* prev = NULL; cout<<"head val "<<(*head)->data <<endl; ...

difference between back tracking and Dynamic programming

Hi, I heard the only difference between dynamic programming and back tracking is DP allows overlapping of sub problems. (fib(n) = fib(n-1)+ fib (n-2)). Is it right ? Are there any other differences ? Also I would like know some common problems solved using these techniques. ...

data for testing graph alogrithms

Hi, i am looking for a source of huge data sets to test some graph algrothm implemention. The files should be in an easy to read file format somthing like: $Node1 Node23 Node322334 Node43432 $Node2: Node232 ... Thanks, Chris ...

How to draw a tree structure? (A two-dimensional space allocation tree recursion algorithm?)

I have an arbitrary tree structure of nodes. I want to draw this tree to provide users a visual representation. I need to recurse over the tree and for each node add a graphic item to a list, and then just draw the list of items once tree recursion has finished. The recursion and drawing of items is of course trivial - what's a bit more ...

Meh, C# SortedList has no .Find

Silly if you ask me. But this message is here because I will assume (probably correctly) that I am the silly one, not Microsoft. So... is there something I'm missing? Why didn't they include a "Find" method to this baby? The find could work on the Values, which are objects, so then I could do this: someObject = SortedList.Values.Find(or...

Parsing CFDUMP struct and store values

How do I parse this structure? I need to turn this into single variables. E.g. from the attributes struct: name type value I'm not familiar with structures, and I need to enter this type of data into a database. I've played around with cfloop, but nothing. ...

Technology for a reliable, persistent stack

Trying a mental reset here: I tried to create a reliable, persistent stack with MSMQ, didn't work So in more general terms: I have producer (a webservice, so multithreaded although "only one") / consumer (multiple processes, as many as needed) setup. The key problems are - The data needs to be consumed/processed in LIFO order (~> stack...

data structure for storing array of strings in a memory

Hi everyone! I'm considering of data structure for storing a large array of strings in a memory. Strings will be inserted at the beginning of the programm and will not be added or deleted while programm is running. The crucial point is that search procedure should be as fast as it can be. Saving of memory is not important. I incline to s...

.NET data storage - something between built-in colections and external SQL database?

Hi folks, I will preface the question by saying that I am somewhat new to the .NET world, and might be missing something entirely obvious. If so, I'd love to hear what that is! I often find myself writing small program that all do more or less the same thing: Read in data from one or more files Store this data in memory, in some sort...

Store large image

Hey, I'm looking for a way to store a very large image (e.g. 100.000x100.000 pixels) on a webserver. I must be able to retrieve parts of that image and write parts into it. The cherry on top would be a way to get parts of that image, resized to a specific resolution (for example, i want alle pixels from 0,0 to 10.000,10.000 resized to 1...

What are some quality graph libraries for C?

Hey All, I'm writing some C where I'm going to need to store a very large graph as an adjacency matrix. I was going to hack up a quick graph implementation, but wanted to ask first if there are any good graph libraries for C (not c++) that people like. I'm going to import the graph in some standard format (probably GML, but thats not a...

cant make sense of LARGE_INTEGER struct

Hello fellow SOers, I'm asking this mainly out of curiousity. I am not really a C(++) Coder but to widen my horizon I try to dive in other areas every now and then. When doing this with C++ and some Winapi things, I encountered this guy: #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else // MIDL_PASS typedef union _LARGE_INTE...

Binary Tree Transfer

How to transfer a binary tree (not a balanced tree) across two different systems efficiently, retaining its complete structure? ...

Why PriorityQueue in Java cannot have initialCapacity 0?

I use PriorityQueue for partial sorting of some data. In particular, this is the code: Collection<Data> data = ...; PriorityQueue<Data> queue = new PriorityQueue<Data>(data.size(), dataComparator); queue.addAll(data); // iterate over queue with remove() until we have as much data as we need or until queue is empty Unfortunately, when ...

Finding the highest-n values in a Map

I have a large map of String->Integer and I want to find the highest 5 values in the map. My current approach involves translating the map into an array list of pair(key, value) object and then sorting using Collections.sort() before taking the first 5. It is possible for a key to have its value updated during the course of operation. I...

data structure - running time

Just a confusion.... A portion of a C++ sample code is as follows I just re-edit the whole post. Sorry for any confusion int i, j; i = 0; // c1 j = 0; // c2 while (i < n) // (n+1)c3 { i++; // n c4 while ( j < i) // (2+3+....+n+(n+1)c5 { j++; // (1+2+...+n)c6 } j = 0; // c7 } Clearly, c1, c2, and c...

C++ fast bit array class for streaming compression algorithms

Implementing streaming compression algorithms, one usually need a super-fast FIFO bit container class with the following functions: AddBits(UINT n, UINT nBits); // Add lower nBits bits of n GetBitCount(); // Get the number of bits currently stored GetBits(BYTE* n, UINT nBits); // Extract n Bits, and remove them The nu...

extern problems with array of structures c++

I have the main .cpp file with this: #include "stdafx.h" #include "Form1.h" #include <iostream> ... #include <stdio.h> const int MAX_LEN = 1000; struct DataLine { char StartCode; int ByteCount; int Address; int RecType; int DBytes[16]; int Checksum; }; DataLine AllData[MAX_LEN]; Then I have a form.h with ...

Passing array of structures to function c++

Sorry for the noob question I'm just a little confused. If I have an array of structures in main that I want to pass to a function: struct MyStruct{ int a; int b; char c; mayarray[5]; }; MyStruct StructArray[10]; myFunction(StructArray[]) Pass to this to a function: void myFunction(struct MyStruct PassedStruct...