Short story, I'm implementing a graph and now I'm working on the Kruskal, I need a priority queue. My definition of a priority queue is that the element with the smallest key would come first? Is this wrong? Because when I insert the weighted edges(or numbers) in the queue they don't end up sorted.
PriorityQueue<Integer> tja = new Prio...
A loop may occur in singly linked list (SLL).
To delete the loop in the list, first we need to detect the loop in the SLL and then delete the loop.
Can any one tell how to delete the loop in a SLL with pseudo code?
Can we do it using 3 pointers?
Is there any alternate to accomplish the task?
...
I'm implementing an AVL binary tree data structure in C# .NET 2.0 (possibly moving to 3.5). I've got it to the point where it is passing my initial unit tests without needing to implement any framework level interfaces.
But now, just looking through the FCL I see a whole bunch of interfaces, both non-generic and generic that I could...
I'm in the process of a writing an application, which needs to synchronize a file-structure between a client and a (http) server.
The file-structure is essentially a list of file-paths where each path is a string connected with 1 or more data-block ids (256-bit reference to the actual data-block). A data-block can be referenced by seve...
For debugging purposes, I find it useful to display the contents of data structures.
(In Python for example, I would just do "print some_dict_name").
Can this be achieved in C this easy too by using a standard library, or do I have to implement this myself depending on the data structure ?
Consider the following code, where I have to i...
All -
I need some help designing a table for a Postgre SQL database. I have a table of products ie;
CREATE TABLE products (
product_id integer PRIMARY KEY,
product_name text,
price numeric);
INSERT INTO products (product_id, product_name, price) VALUES
(DEFAULT, 'Purple Widget', '5.50'),
(DEFAULT, 'Green Widget', '1.5...
Possible Duplicate:
Efficient storage of prime numbers
Just an example of what I am looking for: I could represent every odd number with a bit e.g. for the given range of numbers (1, 10], starts at 3:
1110
The following dictionary can be squeezed more right? I could eleminate multiples of five with some work, but numbers that...
Is there a way to get all the elements of a structure, so I can use them and perhaps iterate over them and print them ?
...
What datastructure would you use in Python to represent the internal state of a MineSweeper grid?
Each x,y position will hold a numerical value which represents its current cell state (unexplored, mine, flag, ?).
Should I use nested lists? This seems like the closest thing to a 2D array and it is what I would probably use in any other...
I need to implement a file based multi-way B-Tree Class for c#. There is similar functionality available for C++ and C but I want to use it in C#. It also need to be available as source code as I wish to use with some alternative .NET implementations like MonoTouch.
If anyone knows of a non file based Multiway b-Tree then this could ada...
The following key:value pairs are 'page' and 'page contents'.
{
'section-a.html':{'contents':'section-b.html section-c.html section-d.html'},
'section-b.html':{'contents':'section-d.html section-e.html'},
'section-c.html':{'contents':'product-a.html product-b.html product-c.html product-d.html'},
'section-d.html':{'contents':'pr...
I have strings which look like this one:
"(8, 12.25), (13, 15), (16.75, 18.5)"
and I would like to convert each of them into a python data structure. Preferably a list (or tuple) of tuples containing a pair of float values.
I could do that with eval("(8, 12.25), (13, 15), (16.75, 18.5)") which gives me a tuple of tuples, but I don't ...
Is there a way to find a nonexisting key in a map?
I am using std::map<int,myclass>, and I want to automatically generate a key for new items. Items may be deleted from the map in different order from their insertion.
The myclass items may, or may not be identical, so they can not serve as a key by themself.
During the run time of th...
I'm making a class that will read information from resource files (doesn't matter the type of resource file, just for clarification) and pass
the information on a Form for easy manipulation of information.
My questions is should I use a struct to easily organize the information and then pass a List to a Form looking to utilize the infor...
You are given an array of integers and you have sort those integers based on the frequency of
their occurrence. Design an algorithm and analyze its time complexity. In case of ties the smaller
number should appear first in the sorted list.
Sample Input: 3,4,3,2,3,5,4,2,2,1,2
Sample Output: 1 5 4 3 2
...
typedef struct unit_class_struct {
char *name;
char *last_name;
} person;
int setName(person *array) {
array[0].name = strdup("Bob");
array[1].name = strdup("Dick");
return 1;
}
int setLastName(person *array) {
array->last_name = strdup("Sanchez");
array++;
array->last_name = strdup("Clark");
re...
I'm in the need of sort of a linked list structure, but if it had indexed access too it would be great.
Is it any way to accomplish that?
EDIT: I'm writing in C, but it may be for any language.
...
typedef struct unit_class_struct {
char *name;
} person;
person * setName() {
person * array;
array = malloc (2 * sizeof(person));
array->name = strdup("Robert");
array++;
array->name = strdup("Jose");
return array;
}
int main()
{
person *array;
arra...
This needs to be lock free as it has to run in the interrupt handler of an SMP system. I cannot take locks.
I have a contiguous array holding some values. Some of the entries in this array are "free", they are not occupied. I want to make a list of these entries so that I can quickly allocate one. However, I occasionally have to allocat...
I am trying to pass a structure array pointer and a pointer to a structure array pointer into a function and then have it modified rather than using a return.
This example code is indeed pointless, its just a learning example for me.
Basically I want to create array[0]...array[1]..array[2] and so on and have a pointer that points to t...