I am having a sorted list which is rotated and I would like to do a binary search on that list to find the minimum element.
Lets suppose initial list is {1,2,3,4,5,6,7,8}
rotated list can be like {5,6,7,8,1,2,3,4}
Normal binary search doesn't work in this case. Any idea how to do this.
-- Edit
I have one another condition. What if th...
I want to save my objects according to a key in the attributes of my object in a sorted fashion. Later on I'll access these objects sequentially from max key to min key. I'll do some search tasks as well.
I consider to use either AVL tree or RB Tree. As far as i know they are nearly equivalent in theory(Both have O(logn)). But in practi...
I have a normal tree defined in Scala.
sealed abstract class Tree
object Tree {
case class Node (...) extends Tree
case class Leaf (...) extends Tree
}
Now I want to add a member variable to all nodes and leaves in the tree.
Is it possible with extend keyword or do I have to modify the tree classes by adding [T]?
Update:
It seems...
Hi, stack. I've got a binary tree of type TYPE (TYPE is a typedef of data*) that can add and remove elements. However for some reason certain values added will overwrite previous elements. Here's my code with examples of it inserting without overwriting elements and it not overwriting elements.
the data I'm storing:
struct data {
int n...
Hi
im using qt , and i parse complex json data structure but i find my self doing to many
loops each time i need to parse this JSON , i wander how or what can be the best way to
handle big JSON structures
...
I know how the push() and pop() methods in a typical implementation of a Queue/Linked List work but what I do want to know is what you actually define as a push or a pop? When can you name a method push()/pop()? What makes the insert()/add() method in a typical Tree implementation not a push()?
My understanding is that push()ing means p...
I'm developing an application in which I need a structure to represent a huge graph (between 1000000 and 6000000 nodes and 100 or 600 edges) in memory. The edges representation will contain some attributes of the relation.
I have tried a memory map representation, arrays, dictionaries and strings to represent that structure in memory, ...
Do you know any useful resource, book, article, webpage about data structures?
I found very useful wikibooks page:
http://en.wikibooks.org/wiki/Data_Structures
What helps you with data structure design?
...
What are the main differences, advantages and disadvantages between static and dynamic data structures?
Under which categories do the most common data structures fall?
How could I know in which situation to use each?
...
So if you look at my other posts, it's no surprise I'm building a robot that can collect data in a forest, and stick it on a map. We have algorithms that can detect tree centers and trunk diameters and can stick them on a cartesian XY plane.
We're planning to use certain 'key' trees as natural landmarks for localizing the robot, using ...
Hi there,
I need to match a series of user inputed words against a large dictionary of words (to ensure the entered value exists).
So if the user entered:
"orange" it should match an entry "orange' in the dictionary.
Now the catch is that the user can also enter a wildcard or series of wildcard characters like say
"or__ge" which wo...
Hello!
(This question is related to my previous question, or rather to my answer to it.)
I want to store all qubes of natural numbers in a structure and look up specific integers to see if they are perfect cubes.
For example,
cubes = map (\x -> x*x*x) [1..]
is_cube n = n == (head $ dropWhile (<n) cubes)
It is much faster than calcu...
Hi SO's
I have a question on good database design practices and I would like to leverage you guys for pointers. The project started out simple.
Hey we have a bunch of questions we want answered for every project (no problem)
Which turned into...
Hey we have so many questions can we group them into sections (yup we can do t...
i'm currently looking through some source code i found on the net, which makes use of preprocessor macros in a way i don't understand. it implements the quad-edge data-structure.
hope, someone can clear things for me!
typedef int edge_ref;
typedef struct {
edge_ref next[4];
void *data[4];
unsigned mark;
} edge_struct;
#def...
This is a past exam paper on binary search trees I am attempting. I have no way to check if the output is correct as I am not capable of building one of these things.
The question is in the title
class Tree{
Tree left;
Tree right;
int key;
public static int span(Tree tree)
{
if ( tree == null ){
...
Say you have data in the format:
name=john;age=33;gender=male
What would you call a method that converts data like that into an an object / associative array?
I've been thinking about:
- unserialize_variables
- parse_variables
...
I'm trying to create a Tetris-like game with Clojure and I'm having some trouble deciding the data structure for the playing field. I want to define the playing field as a mutable grid. The individual blocks are also grids, but don't need to be mutable.
My first attempt was to define a grid as a vector of vectors. For example an S-block...
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
the output in spiral order should be
1 3 2 4 5 6 7 15 14 13 12 11 10 9 8
...
I'm trying to parse a command-line in Python which looks like the following:
$ ./command -o option1 arg1 -o option2 arg2 arg3
In other words, the command takes an unlimited number of arguments, and each argument may optionally be preceded with an -o option, which relates specifically to that argument. I think this is called a "prefix ...
I'm wondering what way would be best to render a 2D map for a shooter (these will be static maps) similar to Soldat. Multiple options I've considered are a tile based map (stored in txt files), or just creating different classes for the different terrains I plan to use and creating a data structure to read/store them in a file. (I want t...