discrete-mathematics

Learning to enjoy maths again

I'm a first year computer science student, having returned several years after finishing high school. As I delve deeper down the rabbit hole I am gain a greater appreciation for the importance of math in computer science. The problem is I don't enjoy math, I read an article called Lockhart's Lament that I think sums up my experience w...

Calculating check digit for ISBN

This isn't actually homework, I'm just looking through some questions in a discrete maths book before I start computer science next week. Anyway, one of the questions asks me to write a program to perform this algorithm (which it explains). The part I'm stuck with is how to take the 9 digit number and "split" it into single integers, so...

Algorithm for Postage Stamp Problem

The postage stamp problem is a mathematical riddle that asks what is the smallest postage value which cannot be placed on an envelope, if the letter can hold only a limited number of stamps, and these may only have certain specified face values. For example, suppose the envelope can hold only three stamps, and the available stamp values...

Function one-to-one and onto from set to an other

Hello, I saw somewhere that if we have a one-to-one function from sets X to Y mean that we have a onto function from Y to X. I can't understand it !! Someone can explain ?? ...

What is the importance of DISCRETE STRUCTURES from a programmer point of view

What is the importance of DISCRETE STRUCTURES from a programmer point of view ...

How to find the local minima of a smooth multidimensional array in NumPy efficiently?

Say I have an array in NumPy containing evaluations of a continuous differentiable function, and I want to find the local minima. There is no noise, so every point whose value is lower than the values of all its neighbors meets my criterion for a local minimum. I have the following list comprehension which works for a two-dimensional ar...

What does this definition of contiguous subsequences mean?

I don't understand the following definition of a contiguous subsequence: A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. If S is {5, 15, -30, 10, -5, 40, 10} then 15, -30, 10 is a contiguous subsequence. What makes 15, -30, 10 a contiguous subsequence? ...

How to customize a discrete function plot in MATLAB?

I would like to plot discrete values in MATLAB like this: stairs() and stem() make similar plots but can I configure one of them to look like the image above? ...

What is the formal name of the number-picking game?

You know that game, where you and an opponent take turns choosing numbers, and the last person to take their turn before the cumulative total passes a preset value, is the winner? What's the formal name of that game? I know it's a solved game in that there's an algorithm to generate the winning moves, but, given that google doesn't under...

Determining BigO of a recurrence

T (1) = c T (n) = T (n/2) + dn How would I determine BigO of this quickly? ...

Mergesort running time BigO

Snape’s “Unfriendly Algorithms for Wizards” textbook claims the running time of merge sort is O(n^4). Is this claim correct? Solution: Yes. This claim is technically correct, because O(n^4) only gives an upper bound for how long the algorithm takes. However, it’s an obnoxiously unhelpful answer, since the tight bound is Θ(n log n). I'm...

Height of a tree with only one node

According to Wikipedia, The height of a tree is the length of the path from the root to the deepest node in the tree. A (rooted) tree with only one node (the root) has a height of zero (or one). I dont get it-is it zero or one (or both)? ...