Hi,
I know that In-order traversal(VISIT LEFT, VISIT ROOT, VISIT RIGHT) on a binary search tree gives me a sorted result. But I need to do a Post-order traversal (VISIT LEFT, VISIT RIGHT, VISIT ROOT) on a binary tree and the result should give me sorted values.
In order to achieve that, how should I construct my binary tree?
...
Design a data structure which has the following features
push the data
pops the last inserted data [LIFO]
Gives the minimum
All of the above operations should have a complexity of O(1)
...
I've been doing some brushing up on my B-Tree and 2-3-4 tree (B tree with order 4), and I'm attempting to implement this in C#. My question to you is, given that a B-Tree node can contains N-1 number of items and N subtrees, what is the typical representation for one of these nodes? Is it an array, series of linked-lists, or something I...
I am working with a large set (5-20 million) of String keys (average length 10 chars) which I need to store in an in memory data structure that supports the following operation in constant time or near constant time:
// Returns true if the input is present in the container, false otherwise
public boolean contains(String input)
Java's ...
I have a hierarchical generic data structure. There is a root node and under that there can be many tree nodes, or just a single data node, and tree nodes can have more tree nodes. A basic tree structure.
All data in my system is persisted in this format. I do however want to have a strongly typed interface to some of the different type...
I have a data structure made of Jobs each containing a set of Tasks. Both Job and Task data are defined in files like these:
jobs.txt:
JA
JB
JC
tasks.txt:
JB T2
JA T1
JC T1
JA T3
JA T2
JB T1
The process of creating objects is the following:
- read each job, create it and store it by id
- read task, retrieve job by id, create t...
As an optional assignment, I'm thinking about writing my own implementation of the BigInteger class, where I will provide my own methods for addition, subtraction, multiplication, etc.
This will be for arbitrarily long integer numbers, even hundreds of digits long.
While doing the math on these numbers, digit by digit isn't hard, wha...
(10)
/ \
(9) (8)
/ \ / \
(7) (5) (4)
x x
/ and \ == x=>y
y y
thanks in advance
...
Background
I am designing an application which will convert text from one language to other. For example, input text hello will be converted to specified language text. This is done by having a lookup table for each language. Conversion algorithm has the following steps.
Looks for exact match. The whole word hello will be the pattern....
How would you parse in Java a structure, similar to this
\\Header (name)\\\
1JohnRide 2MarySwanson
1 password1
2 password2
\\\1 block of data name\\\
1.ABCD
2.FEGH
3.ZEY
\\\2-nd block of data name\\\
1. 123232aDDF dkfjd ksksd
2. dfdfsf dkfjd
....
etc
Suppose, it comes from a text buffer (plain file).
Each line of text is "...
I'm making a game and I need to represent a "layered" circle in some clever datastructure.
A circle can have any number of layers. Each layer has a number of "slices", they can be of different lengths and pieces can be missing. The innermost layer is always a full circle. Each segment has a color, multiple segments with the same color c...
I'm looking for a data structure similar to a dictionary that returns the set of all related items to a key.
For example, I would use it like this:
var data = new FancyDataStructure();
data.Add(new string[] {"Elizabeth", "Liz", "Betty"});
data.Add(new string[] {"Bob", "Robert", "Rob"});
string[] alternateNames1 = data["Betty"];
strin...
I'm looking for a C++ data structure that will let me associate objects with a unique numeric value (a key), and that will re-use these keys after the corresponding object have been removed from the container. So it's basically somewhat of a hybrid map/queue structure. My current implementation is a
std::map<size_t, TObject>
and I ins...
Hi,
This is a newbie question - how do I access the value0, value1, ... entities?
object(SimpleXMLElement)#43 (2) {
["@attributes"]=>
array(3) {
["ABC"]=>
string(1) "1"
["DEF"]=>
string(14) "recordXYZ"
["GHI"]=>
string(1...
Consider a two-dimensional grid (the usual lattice in the plane). For my purposes, a pattern or arrangement is an assignment of the numbers 1 and 2 to some connected subset of the grid points. For example, the following shows three separate arrangements:
.......1.....1....
.222...2.....12...
.111...2.....2....
.222...22...12211.
........
Hi!
I'm trying to figure out how to structure data properly in PHP in order to make a SOAP XML request like this:
<typ:saveRequest locationName="example.com">
<typ:datatype owner="ME" class="OPEN">
<typ:order>1</typ:order>
<typ:datavalue>[email protected]</typ:datavalue>
</typ:datatype>
</typ:saveRequest>
Th...
typedef struct Node
{
int data;
Node *next;
Node *other;
};
Node *pHead;
pHead is a singly linked list. The next field points to the next element in the list. The other field may point to any other element (could be one of the previous nodes or one of the nodes ahead) in the list or NULL.
How does one write a copy function that...
How to replace "foo" to "bar" ?
From
<h1>foo1<p>foo2<a href="foo3.com">foo4</a>foo5</p>foo6</h1>
to
<h1>bar1<p>bar2<a href="foo3.com">bar4</a>bar5</p>bar6</h1>
I want only replace tag inner content, without tag attributes.
Any ideas ?
...
Hi,
I am trying to find the solution for a problem where i have something like
A > B
B > C
B > D
C > D
And I should get the answer as A > B > C > D.
Conditions for this problem
The output will involve all the elements.
The problem will not have any bogus inputs.
for example, (A>B) (C>D) is a bogus input, since we cannot determine...
I am developing a Trie data-structure where each node represents a word. So words st, stack, stackoverflow and overflow will be arranged as
root
--st
---stack
-----stackoverflow
--overflow
My Trie uses a HashTable internally so all node lookup will take constant time. Following is the algorithm I came up to insert an item into the tr...