C ++ weird chained list Help?

my code is here : #include <iostream> using namespace std; struct Mhs { int nim; char nama[10]; Mhs *next; }; void fs(Mhs *m) { m = m->next; } int main() { int i; Mhs mhs[2] = { {1, "Alice", &mhs[1]}, {2, "Bob", &mhs[0

Double Link Reversal - Waste Data Printing

I've got problem with this part of code. My goal is to reverse a doubly linked list. I receive garbage values when I try to print out reversed list. typedef struct node{ int val; struct node* prev; struct node* next; }Node; typedef struct list{ Node*

Choose an appropriate FIFO data structure

I need a FIFO structure that supports indexing. Each element is an array of data that is saved off a device I'm reading from. The FIFO has a constant size, and at start-up each element is zeroed out. Here's some pseudo code to help understand the iss

How to convert a vector into an array of cells in matlab?

I have two pieces of codes as the following: nodes = randsample ( n_nodes, round(j*n_nodes) )-1; nodes_seqs = arrayfun (@transfer, nodes, 'UniformOutput', false ); nodes = num2str(nodes); nodes = cellstr(nodes); file_n = strcat('fasta','_','myfilenam

How to perform this aggregation in python

I have the following list of dictionaries which contains the country and the values for corresponding servers. [ {'country': 'KR', 'values': ['Server1']}, {'country': 'IE', 'values': ['Server1', 'Server3', 'Server2']}, {'country': 'IE', 'values': ['S

HashMap / TreeMap sorting my keys

Using JSoup I am scraping some data from a website that gives me pollen data. They do not have an API access, so scraping was my last resort. Using a HashMap, I am storing the date and the pollenIndex, which is how high pollen levels are that day on

Insertion in Heap in Java

Here is an implementation of a Heap in java without using array but I have some problem in inserting data in it for example when i insert 1,3,2,5,8 it inserts 5,8 two times one as subtree of 3 and another one as subtree of 2. public class Heap { priv

When to create a new table?

I have an application with employees and their work contracts. Each work contract has a Vacation. We keep track of how many days the company owes the employee ("VacationOwe") and how many he has taken ("VacationTaken"). Should I make t

Implementing the B + Tree node

Im implementing a B+Tree for a class. The Nodes are currently implemented like this: class Node { public: E* keys[order*2]; Node *children[order*2+1]; int size; Node(){ size = 0; } bool empty() { return size == 0; } bool isLeafNode() { return false;

Create a doubleTree () of a binary search tree?

I came across a problem stating For each node in a binary search tree, create a new duplicate node, and insert the duplicate as the left child of the original node. The resulting tree should still be a binary search tree. http://cslibrary.stanford.ed

Data structure with heap and map equivalent power

I want to design a container C of element E. E has 2 attributes (priority, name), All elements in container have unique 'name' I want to support following operations on this container C as effeciently as possible. insert:- inserts element1(name1, pri

How to store adjacent nodes for the Dijkstra algorithm?

Most articles about Dijkstra algorithm only focus on which data structure should be used to perform the "relaxing" of nodes. I'm going to use a min-heap which runs on O(m log(n)) I believe. My real question is what data structure should I used t

Multiplication of tables in MATLAB

First off, I didn't know what to put as title, since the question is not easy to formulate shortly. I need to convolve a matrix-valued function (k) with a vector-valued function (X), each of which is defined on R^3. I need to to this in MATLAB, so na

hit detect web JS

i want to detect clicks on canvas elements which are drawn using paths. so far i have think of to store elements path in javascript data structure and then check the cordinates of hits which matches the elements cordinates. i belive there is algorith

assigning a 32-bit value to the unsigned uint8_t array

I have a structure as shown below. typedef struct { attribute_code_t field_id; uint8_t instance_num; uint8_t length; uint8_t data[32]; uint32_t crc_value; }table_entry_t; I want to populate the structure as follows. entry->field_id = 54;; entry->ins

Code revision for linked list add (i, x) Method

I'm currently trying to brush up on ADT implementations, specifically an implementation for a Linked List (I'm using Java 5 to do this). I have two questions: (1) Is this implementation I've written for add(i, x) correct and efficient? public void ad

Effective iteration method on real bits in std :: bitset?

Is there a way of iterating over a (possibly huge) std::bitset that is linear in the number of bits that are set to true? I want to prevent having to check every single position in the bitset. The iteration should successively return the indices of e

Inserting a node into a double-linked list

I'm having trouble understanding the second half of connecting a new node into a double-linked list. I'm writing an add method that takes in the node which the new node is to be inserted after. My area of difficulty is understanding how to link to th

C # searchable data storage methods

In a desktop application, I need to store a 'database' of patient names with simple information, which can later be searched through. I'd expect on average around 1,000 patients total. Each patient will have to be linked to test results as well, alth

How does a hash table work?

I'm looking for an explanation of how a hash table works - in plain English for a simpleton like me! For example, I know it takes the key, calculates the hash (I am looking for an explanation how) and then performs some kind of modulo to work out whe

Is there a proximity card algorithm or data structure?

A problem I keep running into when writing code that draws images of scientific data is the following: Given some floating point data, fit those data into slots (1-dimensional case) or a grid (2-dimensional case) such that each datum is in the slot o