data-structures

Generic Information Schema for multiple database..

I need to get the db table informations like columns detail, pk/uk/check/fk constraints etc. for popular databases (Oracle, MySql, MSSql , DB2 etc). I know each database provide some way or other to retreive the schema information. Does somebody know the generic way to collect the schema information from different databases (Some sort of...

Implement Scrolling text in C

Hii , I was asked this question in one of my interviews with a MNC recently . The question was " We need to display a screen in which a text scrolls at the bottom of the screen and the remaining screen is empty . How would you accomplish this in C ? What data structures would you use ..?? " Any ideas please ...! ...

data structure that can do a "select distinct X where W=w and Y=y and Z=z and ..." type lookup

I have a set of unique vectors (10k's worth). And I need to, for any chosen column, extract the set of values that are seen in that column, in rows where all the others columns are given values. I'm hoping for a solution that is sub linear (wrt the item count) in time and at most linear (wrt the total size of all the items) in space, pr...

Minimum Spanning Tree: What exactly is the Cut Property?

Hi, I've been spending a lot of time reading online presentations and textbooks about the cut property of a minimum spanning tree. I don't really get what it's suppose to illustrate or even why it's practical. Supposedly it helps determine what edges to add to a MST, but I fail to see how it accomplishes that. My understanding of the cu...

How to print an a 4x4 array in clockwise direction using C#

int numbs[4][4] = 1, 2, 3, 4 5, 6, 7, 8 9, 10, 11, 12 13, 14, 15, 16; When i print it, it should print like this. 1 2 3 4, 8, 12,16, 15, 14, 13, 9, 5, 6, 7, 11, 10, (ie clockwise direction spiral): ---\ //first right, then down, left, up and repeat /-\| |-/| \--/ ...

Data range filters in C++

I want to allow the user to be able to define ranges that will filter data. The ranges defined could be contiguous, over lapping, or separated (e.g. the user enters the following ranges: 1-10, 5-10, 10-12, 7-13, and 15-20). I then want to filter the data so that the user is only displayed what is within those ranges. I will probably cr...

Asymptotically Fast Associative Array with Low Memory Requirements

Ok, tries have been around for a while. A typical implementation should give you O(m) lookup, insert and delete operations independently of the size n of the data set, where m is the message length. However, this same implementation takes up 256 words per input byte, in the worst case. Other data structures, notably hashing, give you ex...

Any improvements over my linked-list method?

I am continually writing a program to improve my knowledge of linked-lists and how they function. I was wondering if some of you could review my code and notice any faults that you may be familiar with, or any errors in general. The functions work for my test functions, but obviously, I have not tested every scenario possible. // Li...

storing occurrences for reporting

What is the best way to store occurrences of an event in a database so you can quickly pull reports on it? ie (total number of occurrences, number of occurrences between date range). right now I have two database tables, one which holds all individual timestamps of the event - so I can query on a date range, and one which holds a tota...

Problem converting a Matrix to Data Frame in R (R thinks all numeric types are factors)

Hello! I am passing data from C# to R over a COM interface. When the data arrives in R it is housed in a 'Matrix'. Some of the functions that I use require that the data be inside a 'DataFrame' instead. I convert the data structure using newDataFrame <- as.data.frame(oldMatrix) The table of data reaches R just fine, once I make the...

Data structure for when key and value are equally "important"

So, this is probably a stupid question, but I have a mapping of unique IDs to unique values. Sometimes I want the value for a certain ID, sometimes I want to know the ID of a certain value. I search more than I modify the collection. I'm wondering if there's a special datastructure that makes sense here, or if I should just maintain two ...

Merging two datasets in Python efficiently

What would anyone consider the most efficient way to merge two datasets using Python? A little background - this code will take 100K+ records in the following format: {user: aUser, transaction: UsersTransactionNumber}, ... and using the following data {transaction: aTransactionNumber, activationNumber: assoiciatedActivationNumber}, ...

Data Structures... so how do I understand them?

So I am a Computer Science student and in about a week or so... I will be retaking a Data Structures course, using C++ for applying the theory. Yes, I did say "retaking". I took the course last Fall and I feel like there is more that I need to learn. Being a student, I feel that I MUST know the basics because it will be much easier to un...

How can I generalize the use of these different data structures?

I have an application that reads times from a file. These times can be in three different formats, based on flag bits elsewhere in the file, as shown below: [StructLayout(LayoutKind.Sequential, Pack = 1] public struct IntraPacketTime_RTC { public UInt64 RTC; } [StructLayout(LayoutKind.Sequential, Pack = 1] public struct IntraPacke...

Efficent methods for finding most common phrases in a body of text AKA trending topics

Hi, I previously asked a similar question on this topic, I ended up deriving several solutions which worked, one based on bloom filters + ngrams, the other based on hash tables + ngrams. Both solutions perform fine with small data sets (<1000 texts, usually tweets) but the computation time grew exponentially meaning doing 10,000 could t...

Array remove duplicate elements

I have an unsorted array, what is the best method to remove all the duplicates of an element if present? e.g: a[1,5,2,6,8,9,1,1,10,3,2,4,1,3,11,3] so after that operation the array should look like a[1,5,2,6,8,9,10,3,4,11] ...

Advantages of using union when same thing can be done using struct - C

I have difficulty in understanding the use of union in C. I have read lot of posts here on SO about the subject. But none of them explains about why union is preferred when same thing can be achieved using a struct. Quoting from K&R As an example such as might be found in a compiler symbol table manager, suppose that a constant...

Building an index: Copies or pointers?

I have a data structure that stores ... well, data. Now, I need to access various pieces of data in slightly different manner, so I'm essentially building an in-memory index. But I'm wondering: should the index hold pointers or copies? To elaborate, say I have class Widget { // Ways to access the list of gears... private: std::...

Data structure for a search engine?

Which is the most efficient data structure or algorithm, which can be used for storing search engine data. Also which distributed file system could go with it? ...

'Followers' and efficiency

I am designing an app that would involve users 'following' each other's activity, in the twitter sense, but I am not very experienced with database/query design/efficiency. Are there best practices for managing this, pitfalls to avoid, etc.? I gather this can create a very large load on the db if not done properly (or maybe even then?). ...