Here's a simple program to check memory allocation. Checking before and after values with Task Manager suggests that each dynamic array takes up 20 bytes of memory at size = 1. The element size is 4, which means 16 bytes of overhead for bookkeeping data.
From looking through system.pas, I can find an array length field at -4 bytes, an...
I just saw this data-structure on the Java 6 API and I'm curious about when it would be an useful resource. I'm studying for the scjp exam and I don't see it covered on Kathy Sierra's book, even though I've seen mock exam questions that mention it.
...
I have a data structure as the image below illustrates. I need to quickly figure out the index of the cells to the right or left of the highlighted cell group.
You can see in the code below I am naively looping through ALL cells at every index to determine if there is a cell at the requested index. This works great when I have a few (...
Below is my code snippet
struct encode
{
char code[MAX];
}a[10];
int main()
{
char x[]={'3','0','2','5','9','3','1'};
for(i=0;i<1;i++)
{
printf("%c",x[i]);
//This will printout like 3025931 now I want this to be stored in structure.
}
strcpy(a[0].code,x);
// or
a[0].code=x;//neither works
display();
}...
paxdiablo gave the previous answer for it working with char array.. can I know how to work with int array for the same below code?
LIke:
struct encode {
int code[MAX]; //instead char code[MAX]
} a[10];
int main() {
int i, j;
int x[] = {3,0,2,5,9,3,1};
//instead char x[] = {'3','0','2','5','9','3','1','\0'};
for(i ...
I have quite a big amount of fixed size records. Each record has lots of fields, ID and Value are among them. I am wondering what kind of data structure would be best so that I can
locate a record by ID(unique) very fast,
list the 100 records with the biggest values.
Max-heap seems work, but far from perfect; do you have a smarter ...
Hello Guys
I am developing a small C# windows application and in the need to Hierarchical Categories structure design. I am cuurrently using a single layer Categories from the DB i.e. no child categories. I would like to go about and allow the user to create multiple level categories. I looked into this thread Data structure for Categor...
I'm storing millions, possibly billions of 4 byte values in a hashtable and I don't want to store any of the keys. I expect that only the hashes of the keys and the values will have to be stored. This has to be fast and all kept in RAM. The entries would still be looked up with the key, unlike set()'s.
What is an implementation of this ...
I am trying to compute the depth of any(not necessarily complete) BST in O(log n) time recursively.
This is the algorithm I came up with:
//max() - returns the max of two numbers
int depth(root)
{
if(root->left==NULL && root->right==NULL) //leaf
return 0;
else if(root->left!=NULL && root->right==NULL) //with right leaf
...
I have upto 10,000 randomly positioned points in a space and i need to be able to tell which the cursor is closest to at any given time. To add some context, the points are in the form of a vector drawing, so they can be constantly and quickly added and removed by the user and also potentially be unbalanced across the canvas space..
I a...
Can anyone explain how the data are sorted in a TreeMap automatically when we try to print the data stored in them?
...
Hello all!
I have a quote that contains items (store in table QuoteItem):
QuoteItemId, QuoteId, ItemId, Quantity etc.
Now, I need to be able to create a group of chosen items in the quote and apply a discount on it.
Well that's simple, I create two more tables:
Group: GroupId, DiscountPercentage
GroupQuoteItem: GroupId, QuoteItemId
...
Hi,
I'm working on a project at the moment where I need to pick out the most common phrases in a huge body of text. For example say we have three sentences like the following:
The dog jumped over the woman.
The dog jumped into the car.
The dog jumped up the stairs.
From the above example I would want to extract "the dog jumped" as i...
My current dilemma is as follows:
I have a 2550x3300 tiff. At certain (variable) points in my tiff I need to insert a line of pixels from elsewhere in the tiff. e.g. I need to insert 12 copies in a row of line 100 between lines 500 and 501.
I've been looking up different image processing techniques for a few days now and can't find any...
Hi,
I have a txt file with some data that looks like this:
a:1(2,3) 55(33,45,67)
b:2(1,33,456) 4(123,12444)
which means that word "a" appear in text 1 in places 2 and 3 and in text 55 in places 33,45 and 67..
I have some texts and I go all over those texts and if I see that the word "a" appears in a text then I need to update the te...
Hi
I need an ordered queue where objects would be ordered by primary and secondary value.
class Object
{
int PrimaryValue;
int SecondaryValue;
}
The position of an Object in the queue must be determined by PrimaryValue. Object with higher PrimaryValue must preceed object with lower PrimaryValue. However for two objects with the s...
I'm looking for a priority queue with an interface like this:
class PriorityQueue<T>
{
public void Enqueue(T item, int priority)
{
}
public T Dequeue()
{
}
}
All the implementations I've seen assume that item is an IComparable but I don't like this approach; I want to specify the priority when I'm pushing it o...
I have a big csv file which lists connections between nodes in a graph. example:
0001,95784
0001,98743
0002,00082
0002,00091
So this means that node id 0001 is connected to node 95784 and 98743 and so on.
I need to read this into a sparse matrix in numpy. How can i do this?
I am new to python so tutorials on this would also help.
...
I was wondering if anyone had a possible solution to the following problem... I have a base class that a series of derived classes will inherit from. The base class cares about whether properties on the derived class have changed. This is to set up an "IsDirty" approach for a data transfer object.
The traditional approach would be to...
I'd like to use a data interchange format that uses no quotation marks. Maybe something based on JSON:
{param:value,param:value,param:{[{param:value,param:value}, {param:value,param:value}]}}
How should I go about parsing something like that in let's say PHP. Should do it through regular expressions?
...