I was reading binary search tree and was thinking that why do we need BST at all? All the things as far as I know can also be achieve using simple sorted arrays. For e.g. - In order to build a BST having n elements, we requires n*O(log n) time i.e. O(nlog n) and lookup time is O(log n). But this thing can also be achieve using array. We ...
and how can I do it in C++?
...
I'm storing a (possibly large) number of objects in memory that I want to refer to by long identifiers. Currently, I'm using a standard HashMap<Long, MyClass>. I was wondering if there might be a better way to do it, since intuitively, I'd think that wrapping long in a Long doesn't really make sense.
Note that, as of now, this question ...
hi,
Goal: to find count of all words in a file. file contains 1000+ words
My approach: use a HashMap() to store and count the number of times each word appears in the file.
Question:
Would a HashMap() be the best way or would it be better to use a Binary Tree for ensuring faster lookup as there is a large count of words in the file?
...
A Product can have lots of things said about it, I'll call them Properties. It can have a brief description. But that description can be in multiple languages. Likewise, it can have multiple Prices, some which are specific to Customers. Given the following data:
Product:
identifier: 123-ABC
Price:
value: $1.25
currency: ...
Possible Duplicate:
Is there a read-only generic dictionary available in .NET?
Hi everyone,
I realized that it was possible to return lists as read only collections:
var list = new List<string>();
return list.AsReadOnly();
I wanted to write a similar piece of code for data structures like Dictionary or HashSet but I didn’...
I'm working on a hybrid data structure that is an ordered double-linked list where each node contains an array[] of SIZE. My difficulty is the add method.
Using unit testing provided by the professor, a test string is broken up into individual characters and added to the list using a provided comparator. The default test is abcdefghij...
void insertLoc(int n, int i)
inserts a node with info n after the ith location in the list. If the ith location does not exist in the list then the program should exit with an error message.
Can anyone help me with the code please...
#include<iostream>
#include<process.h>
using namespace std;
struct node {
int info;
node *n...
I've seen people say that set objects in python have O(1) membership-checking. How are they implemented internally to allow this? What sort of data structure does it use? What other implications does that implementation have?
Every answer here was really enlightening, but I can only accept one, so I'll go with the closest answer to my o...
I am building a tree like data structure. What is the expected behavior if I have a method
public Set getSiblingNodes(Node node);
Should this method return a set including or excluding itself?
Thanks!
...
Possible Duplicate:
What do I use for a max-heap implementation in Python?
Python has a min heap implemented in the heapq module. However, if one would want a max heap, would one have to build from scratch?
...
I've nearly killed myself, multiple times, trying to find the perfect, flexible schema for storing many different types of objects with a wide variety of links between them in a relational database. But models such as EAV and things like polymorphic relationships just aren't true to relational databases.
After learning about NoSQL graph...
I'm looking for a better way to do this:
id key, value;
NSMutableDictionary dict;
[dict setObject:value forKey:[NSNumber numberWithInt:(int)key]]
That is, use an NSDictionary to map from address to object.
...
I wish to hold a heap of objects, not just numbers. They will have an integer attribute in them that the heap can sort by. The easiest way to use heaps in python is heapq, but how do I tell it to sort by a specific attribute when using heapq?
...
I have a question about implementing a data structure (with algorithm) that has these features:
There are too many places (like stores), and each place can store too many items, I want to store items in the places. The point is we need to have optimized insertion (or deletion) and optimized search feature.
Search can be done based on p...
Hello, guys.
I think I've created an AVL tree implementation, but as AVL Tree is quite a complex structure, I need to test it. So the question is - how can I test it? Have you got any ideas?
Up to this moment I have the following tests:
basic sanity check - checks that
for every node height equals max.
height of child nodes + 1...
My JSON object is constructed like this:
var Source =
{
Object: [ //Array
{Title: 'Test', Type: 'Pet', Category: 'Cat', Description: 'Fluffy', Count: 2 }
]
};
I was able to figure out how to properly add to the 'Object' array, but I can't seem to figure out the jQuery syntax to query the object based on the property li...
A patricia trie is the well-know, recommended data structure for storing IPv4 allocations/assignments and performing lookup.
Is this true for IPv6 adddresses too? Just a deeper/taller trie to accommodate the extra 96 bits? Is the trie still patricia, or a different radix trie?
...
I have a requirement to retrieve an item from a data structure by key. But I also have a requirement to traverse that data structure in sorted order, using a field other than the key.
Something like this (pseudocode, for illustrative purposes only):
var list = new SortedDictionary<TKey, TSortField, TItem>();
How would I do this? Is...
So I have about 16,000 75-dimensional data points, and for each point I want to find its k nearest neighbours (using euclidean distance, currently k=2 if this makes it easiser)
My first thought was to use a kd-tree for this, but as it turns out they become rather inefficient as the number of dimension grows. In my sample implementation,...