Most Popular

1500 questions
11
votes
4 answers

Minimum number of shopping trips for a group of people to buy presents for each other

We have a group of $n$ people. We are given a list of who must buy presents for whom within the group. Each person might need to buy/receive any number of presents, or possibly none at all. In a shopping trip, a subset of the people travel together…
Riley
  • 280
  • 1
  • 11
11
votes
4 answers

Two-way Hash Functions

While I'm aware most (good) hash functions are one-way (or at least mostly so), I'm wondering if there's any construct (not necessarily called a hash function) which behaves in many ways like a hash function, but can be easily reversed. For example,…
Joe Horne
  • 165
  • 1
  • 2
  • 7
11
votes
2 answers

Finding k'th smallest element from a given sequence only with O(k) memory O(n) time

Suppose that we read a sequence of $n$ numbers, one by one. How to find $k$'th smallest element just with using $O(k)$ cell memory and in linear time ($O(n)$). I think we should save first $k$ terms of sequence and when get the $k+1$'th term, delete…
Shahab_HK
  • 147
  • 1
  • 8
11
votes
4 answers

Does it make sense to have both the concept of 'null' and 'Maybe'?

While creating a client for a web API in C#, I ran into a problem regarding null as a value where it would represent two different things: nothing, e.g. a foo may or may not have a bar unknown: by default the API response only includes a subset of…
Stijn
  • 213
  • 1
  • 8
11
votes
1 answer

Alternatives to Defunctionalization

Defunctionalization is a transformation first described 1972 by John C. Reynolds to eliminate higher-order functions. Are there alternative transformations (more efficient?) to eliminate higher-order functions?
Peter
  • 361
  • 1
  • 5
11
votes
1 answer

Literature about a naive approach to graph isomorphism by inspecting polynomials of adjacency matrices

I describe an approach to graph isomorphism which probably has false positives, and I am curious whether there is literature indicating that it does not work. Given two adjacency matrices $G, H$, an admittedly naive method of checking for…
Lieuwe Vinkhuijzen
  • 4,292
  • 17
  • 27
11
votes
1 answer

Can properties such as memory usage of a function be expressed in a dependently typed language?

Suppose one wants to reason about properties of code beyond things like totality and functional purity - one also cares about the memory consumption, or algorithmic complexity of a function. Can this be done through dependent typing and effects…
11
votes
1 answer

Programming language semantics prototyping tool

Is there any tool for prototyping a programming language semantics and type system and that also allows for some sort of model checking of standard properties, like type soundness? I'm asking this, because I'm reading a book on Alloy and it…
Rodrigo Ribeiro
  • 283
  • 1
  • 10
11
votes
3 answers

Is there a difference between $\lambda xy.xy$ and $\lambda x.\lambda y.xy$?

I am currently learning the lambda calculus and was wondering about the following two different kinds of writing a lambda term. $\lambda xy.xy$ $\lambda x.\lambda y.xy$ Is there any difference in meaning or the way you apply beta reduction, or…
magnattic
  • 537
  • 3
  • 11
11
votes
3 answers

Automatic Downcasting by Inferring the Type

In java, you must explicitly cast in order to downcast a variable public class Fruit{} // parent class public class Apple extends Fruit{} // child class public static void main(String args[]) { // An implicit upcast Fruit parent = new…
Sam Washburn
  • 215
  • 1
  • 7
11
votes
2 answers

A Question relating to a Turing Machine with a useless state

OK, so here is a question from a past test in my Theory of Computation class: A useless state in a TM is one that is never entered on any input string. Let $$\mathrm{USELESS}_{\mathrm{TM}} = \{\langle M, q \rangle \mid q \text{ is a useless state…
BrotherJack
  • 1,115
  • 1
  • 10
  • 23
11
votes
4 answers

What are common formal techniques for proving functional code correct?

I want to provide proofs for parts of a Haskell program I'm writing as part of my thesis. So far however, I failed to find a good reference work. Graham Hutton's introductory book Programming in Haskell (Google Books)—which I read while learning…
FK82
  • 273
  • 2
  • 8
11
votes
3 answers

References on comparison between quantum computers and Turing machines

I was told that quantum computers are not computationally more powerful than Turing machines. Could someone kindly help in giving some literature references explaining that fact?
11
votes
3 answers

Why is the minimum height of a binary tree $\log_2(n+1) - 1$?

In my Java class, we are learning about complexity of different types of collections. Soon we will be discussing binary trees, which I have been reading up on. The book states that the minimum height of a binary tree is $\log_2(n+1) - 1$, but…
CodyBugstein
  • 2,957
  • 10
  • 30
  • 45
11
votes
3 answers

Are there parallel matrix exponentiation algorithms that are more efficient than sequential multiplication?

One is required to find power (positive integer) of matrix of real numbers. There are lots of efficient matrix multiplication algorithms (e.g. some parallel algorithms are Cannon's, DNS) but are there algorithms that are intended exactly for finding…
TomR
  • 1,381
  • 7
  • 16