I want to be able to store an atomic model in an OpenGL program I'm writing. Nothing fancy; just constant mesh vertex values stored as GLfloat[3], plus simple textures. I also want the model to be able to move and rotate freely and as a single object. Here's what I have so far:
typedef struct _coordnode {
GLfloat *pts; /* ...
I am trying to calculate height of a tree. I am doint with the code written below.
#include<iostream.h>
struct tree
{
int data;
struct tree * left;
struct tree * right;
};
typedef struct tree tree;
class Tree
{
private:
int n;
int data;
int l,r;
public:
tree * Root;
Tree(int x)
{
n=x;
...
What is the most optimal way to find repetition in a infinite sequence of integers?
i.e. if in the infinite sequence the number '5' appears twice then we will return 'false' the first time and 'true' the second time.
In the end what we need is a function that returns 'true' if the integer appeared before and 'false' if the function rec...
I know that we should rather be using dictionaries as opposed to hashtables. I cannot find a way to clone the dictionary though. Even if casting it to ICollection which I do to get the SyncRoot, which I know is also frowned upon. I am busy changing that now. I am under the correct assumption that there is no way to implement any sort of ...
lets say i have numbers from 1-10Million (customer ids). each single number is associated with 1 of 3 possible values - A,B,C.
i know that very large adjacent regions of about 1000 elements are in the same category.
what is a data structure that allows me to save the link between number range and category in a memory-efficient way?
al...
I'm looking for an "efficient" way to persist a binary state when given to two integers. Giving these two integers A an B, A is always less than B and the range of values which they will contain is 0 through N. The integer N will be greater than 2 and less than 256.
The simple solution is to create a two-dimensional array of Boolean v...
Lets say, we have string "ABCAD", now we need to iterate through all possible arrangement of this string in both clockwise and counter-clockwise direction.
My ugly implementation looks like this:
string s = "ABCAD";
string t ="";
for(int i = 0; i < sz(s); i++){
t = s[i];
for(int j = i+1; ; j++){
if((j) == sz(s)){
...
Hi developers!
I am working with a very large dataset. Essentially I will be working with millions of records and storing a value into a dataset.
Each time that I store a value, I must first check to make sure that the value is not already in the data structure. If the value is in the data structure, I must update (or remove/add) the...
There are products, sections and attributes.
Each attribute can have up to 5 or 6 options.
Example: Power
10 Volt
15 Volt
20 Volt
And there are about 10 products in total, each product has up to 17 attributes applied to it.
Example: Product 1
power - 10 volt
color - red, yellow
link - online, offline
How would you setup the tabl...
This question is from an exam I had, and I couldn't solve it and wanted to see what the answer is (this is not homework, as it will not help me in anything but knowledge).
We need to create a data structure for containing elements whose keys are real numbers.
The data structure should have these functions:
Build(S, array): Builds the da...
I'm creating a kind of wiki site and have a data structure which consists of a parent entity which has a one to many relationship to a child entity. I'm currently storing this in two tables in the database, with a foreign key relationship from the child entity table to the parent entity table.
I need to version this data structure in my...
I am working on a Computer Vision problem, in which I have to merge regions of an image. A region (or blob) is defined by its lines, i.e. the following region of O:
0123456789
0 XXXXOXXXXX
1 XXXOOOXXXX
2 XXXOOXXXXX
3 XXXOXXXXXX
4 XXXXXXXXXX
is defined by :
row: 0, cols: 4-4
row: 1, cols: 3-5
row: 2, cols: 3-4
row: 3, cols: 3-3
I ...
My data is structured in a way that I ended up creating a nested dictionary in my design like:
my_dict = {"a": {"b": {"c":"I am c"}}}
my_dict["a"]["b"]["c"]
Is it usual! or we have some other better alternatives (using objects!)?
...
Can you recommend me a book or (better!) a site with many hard problems and exercises about data structures?
I'm already answering project Euler questions, but these questions are about interesting, but uncommon algorithms. I hardly used even a simple tree. Maybe there is a site with exercises like: hey, you need to calculate this: ... ...
I have a some large data structure (N > 10,000) that usually only needs to be created once (at runtime), and can be reused many times afterwards, but it needs to be loaded very quickly. (It is used for user input processing on iPhoneOS.) mmap-ing a file seems to be the best choice.
Are there any data structure libraries for C++ (or C)?...
Hi, when I try to compile my code below I get the following errors:
error C2440: '>=' : cannot convert from 'double *' to 'double'
error C2440: '>=' : cannot convert from 'double *' to 'double'
I believe I'm dereferencing everything correctly
#define TRUE 1
#define FALSE 0;
#include <stdio.h>
typedef struct Con{
double samTime[2]...
I'm working on a simple application that will generate time table (daily planner) for schools. I've read up basics of algorithms, but confused as to where to start.
The problem:
Allocate teachers to classes taking into consideration a lot of constraints like:
1) Subject
2) Expertise of teacher
3) Not more than 2 classes continuously.....
This shouldn't be a difficult question, but I'd just like someone to bounce it off of before I continue. I simply need to decide what data structure to use based on these expected activities:
Will need to frequently iterate through in sorted order (starting at the head).
Will need to remove/restore arbitrary elements from the/a sorted...
first, an example:
given a bunch of Person objects with
various attributes (name, ssn, phone,
email address, credit card #, etc.)
now imagine the following simple
website:
uses a person's email address as unique login name
lets users edit their attributes (including their email address)
if this website ha...
The question pretty much says it all, but I'm building a compiler and am trying to decide on what sort of data structure to use for my symbol table. Considering the only functions the symbol table will need is a search and an insert I'd like to use a data structure that can do those as quickly as possible. Any suggestions?
...