I have three questions about three nested loops:
for (int x=0; x<400; x++)
{
for (int y=0; y<300; y++)
{
for (int z=0; z<400; z++)
{
// compute and store value
}
}
}
And I need to store all computed values. My standard approach would be to use a 3D-array:
values[x][y][z] = 1; // test v...
I've been at this for a while now and it really puzzles me. This is a very distilled code fragment that reproduces the problem:
uint8_t dataz[] = { 1, 2, 3, 4, 5, 6 };
struct mystruct {
uint8_t dummy1[1];
uint16_t very_important_data;
uint8_t dummy2[3];
} *mystruct = (void *) dataz;
printf("%x\n", mystruct -> very_import...
in .json text, is the 'value' in a basic single pair object the title of a value type (e.g. [string, number, object]), or a value for a typed object (e.g. 2, or "dog", or Object3)?
This is how http://www.json.org/ presents the information:
"An object is an unordered set of
name/value pairs. An object begins
with { (left brace) a...
Hi stack overflow. I need to insert some objects contained in a Node class into a LinkedList class in a sorted over. The Node class looks like:
public class Node {
private Card val;
private Node next;
public Node(Card v) {
val = v;
next = null;
}
where card implements the Comparator interface. I'm trying to...
I have an application (C++) that I think would be well served by an STL priority_queue. The documentation says:
Priority_queue is a container adaptor, meaning that it is implemented on top of some underlying container type. By default that underlying type is vector, but a different type may be selected explicitly.
and
Priority...
What property makes Hash table, Hash list and Hash tree different from each other? Which one is used when? When is table superior than tree.
...
I'm trying to write depth first search in C. In the search instead of maintaing a set of all the reachable nodes I instead have to mark the isVisited field in Vertex as a 1 for visited. Here's my data structs and my algo attempt.
struct Vertex {
char label;
int isVisited;
int numNeighbors;
struct Vertex** neighbors;
};
...
Hi,
I am having a database with tables having billions of rows in a single table for a month and I am having data for the past 5 years. I tried to optimize the data in all possible ways, but the latency is not decreasing. I know there are some solutions like using horizantal shrading and vertical shrading. But I am not sure about any op...
Hi
I have found these algorithms in the internet but I can not understand that why in the enqueue method we compare size with N-1??? please help me thanks!!
Algorithm size():
return (N-f+r)mod N
Algorithm enqueue(e):
if size()=N-1 then
throw a FullQueueException
Q[r]<---e
r<----(r+1)mod N
...
Hi,
Are there books you know that covers data structure? how data should be properly structured (eg, in array or database).
thanks!
...
Hi all:
I am working on a front-end web app where a nested unordered list would be used for the jQuery plugin mcdropdown.
Here is the data structure from PHP: a nested array of arrays :
Array
(
[0] => Array
(
[fullpath] => ../foil/alphanumeric/
[depth] => 0
)
[1] => Array
(
...
I would like to write a piece of code for inserting a number into a sorted array at the appropriate position (i.e. the array should still remain sorted after insertion)
My data structure doesn't allow duplicates.
I am planning to do something like this:
Find the right index where I should be putting this element using binary search
C...
How to search fast in a non-sorted array? I am unable to think of any other search mechanism apart from linear search.
Any pointers will be helpful.
...
I want to design a data-structure for storing elements, which will be retrieved only once after insertion and will be deleted after that.
I can't use a stack or queue as the order of retrieval is not guaranteed.
[EDIT] - I would like to use contigous memory (I would prefer to avoid doing malloc every now and then) and also I would pref...
Consider the deletion procedure on a BST, when the node to delete has two children. Let's say i always replace it with the node holding the minimum key in its right subtree.
The question is: is this procedure commutative? That is, deleting x and then y has the same result than deleting first y and then x?
I think the answer is no, but ...
Hello,
Let's imagine that we have high traffic project (a tube site) which should provide sorting using this options (NOT IN REAL TIME). Number of videos is about 200K and all information about videos is stored in MySQL. Number of daily video views is about 1.5KK. As instruments we have Hard Disk Drive (text files), MySQL, Redis.
Views...
I have a graph that starts off with a single, root node. Nodes are added one by one to the graph. At node creation time, they have to be linked either to the root node, or to another node, by a single edge. Edges can also be created and deleted (one by one, between any two nodes). Nodes can be deleted one at a time. Node and edge creatio...
Hi
this a part of code for Quick Sort algorithm but realy I do not know that why it uses rand() %n please help me thanks
Swap(V,0,rand() %n) // move pivot elem to V[0]
...
Hi
I have written this code but it will print these stack traces in the console please help me thanks! (Aslo "p" and "q" are the first and last index of our array ,respectively)
public class JavaQuickSort {
public static void QuickSort(int A[], int p, int q) {
int i, last = 0;
Random rand = new Random();
if (q < 1) {
...
Given the code for outputing the postorder traversal of a tree when I have the preorder and the inorder traversal in an interger array. How do I similarily get the preorder with the inorder and postorder array given?
void postorder( int preorder[], int prestart, int inorder[], int inostart, int length)
{
if(length==0) return; //termi...