Categories
Ask Mathematics

Explicit action of the Dehn twist in the homology of punctured sphere with local coefficients

Let $X=\mathbb{P}^1\setminus S$, where $S=\{a_1,\dots, a_k\}$ is a finite subset of $\mathbb{P}^1$ and we may assume that $|S|\geq 4$. Let $\mathbb{L}$ be a local system on $X$ given by a monodromy representations $\rho:\pi_1(X)\to GL_n(\mathbb{C})$. We know that the First homology $H_1(X,\mathbb{L})$ is generated by the paths $\delta_r, r=1,\dots, k-1$, with values in $\mathbb{L}$ where $\delta_r$ […]

Categories
Ask Mathematics

How to read this Markov Chain equation

I’m having trouble reading this Markov Chain equation. This equation has to do with miners attacking a blockchain. $k$ is the count of an object (blocks) that belongs to one group 1 (the honest miners) $ℓ$ is the count (blocks) that belongs to group 2 (the selfish miners) $λ1$ is the percentage of computing power […]

Categories
Ask Mathematics

How many integer solutions are there for the equation $c_1 + c_2 + c_3 + c_4 = 25$, where $c_i \ge 0$ for all $1 \le i \le 4$

Question Statement: How many integer solutions are there for the equation $c_1 + c_2 + c_3 + c_4 = 25$, where $c_i \ge 0$ for all $1 \le i \le 4$. I would like to solve this problem using combinatorics and I’ve read generating functions can be used as a method to find the solution. […]

Categories
Development

How can I modify the Sparse Table quickly?

My problem is as follows: For table a (MxN) The rows of the table are numbered from 0 to M – 1, the columns of the table are numbered from 0 to N – 1. The intersection of row i and column j is called the cell (i, j). Cell (i, j) of the table […]

Categories
Development

Largest sum from absolute differences of N elements in an array

This isn’t really a homework, but rather a practice and optimization, but this seemed like the best section for this type of questions. It is a dynamical programming issue, and it’s the following: -Given an unsorted array of N elements, pick K number of elements from it, such that their absolute difference is the largest. […]

Categories
Development

R: Lag returns input

For example if I use lag(c(1:10), k = 1), it returns 1, 2, …, 10. How do I get this function to work at all? I tried looking at the documentation, but whatever I’ve tried from there didn’t work either.

Categories
Development

Initialize object with type [key, value: Array] in shorthand form

Suppose I want to loop through an array of characters and build up an object which represents the frequency of each character, for example: const frequency = {}; const str = ‘stackoverflow’; for (let i = 0; i < str.length; i++) { frequency[str[i]] = (frequency[str[i]] + 1) || 1; } With the above, we would […]

Categories
Development

Segmentation fault : Cannot access memory

I am implementing merge sort code. The code I have written is : #include<iostream> using namespace std; void merge(int *A,int i,int k,int j) { int l1,l2,c,d; int B[j – i + 1],ind = 0; l1 = k – i + 1; c = i; l2 = j – k; d = k + 1; while(l1 […]

Categories
Development

Can’t figure out how to change my code to solve a recursive problem

Print k-element subsets of a n element set (In essence n choose k) represent each subset as an array and skip B[0]. For example [0 1 0 1] means {1,3} to print. I believe my main problem is in my printSubsets() function because I am calling the method twice. but it looks like it can’t […]

Categories
C++ Development

parenthesizing an expression to get minimum result using recursion in C++

So I have written this code to minimize and maximize an expression using recursion. The code successfully runs and give the maximum value for the expression. However it fails to give the minimum value. Where am I going wrong. The two variables minum and maxum stores INT_MAX and INT_MIN respectively. What I am doing is […]