correctness Questions

10

Solved

In C++ I have compiler that tell me if something wrong with my code after refactoring. How to make sure that Python code is at least correct after changes? There may be some stupid error like wrong...
Veliz asked 11/9, 2009 at 11:56

4

Solved

Consider: std::tuple<int , const A&> func (const A& a) { return std::make_tuple( 0 , std::ref(a) ); } Is the std::ref required for writing correct and portable code? (It co...
Implicatory asked 6/8, 2012 at 17:30

18

Solved

Let's say I have code in C with approximately this structure: switch (something) { case 0: return "blah"; break; case 1: case 4: return "foo"; break; case 2: case 3: return "bar"...
Halm asked 17/6, 2010 at 20:36

6

I have recently having some discussions with my professor about how to handle the basic jdbc connection scheme. Suppose we want to execute two queries, this is what he proposes public void doQueri...
Oddson asked 26/3, 2014 at 19:55

5

I'm having a hard time figuring out which implementation of the 32-bit variation of the Fletcher checksum algorithm is correct. Wikipedia provides the following optimized implementation: uint32_t ...
Carrycarryall asked 26/10, 2016 at 19:15

4

Solved

I am using Sakamoto's algorithm to find out the day of week from a given date. Can anybody tell me the correctness of this algorithm? I just want this from 2000 to 2099. The algorithm from Wikiped...
Marathi asked 17/6, 2011 at 11:38

3

I was trying to solve one Interview problem that is: Given a matrix of n*n. Each cell contain 0, 1, -1. 0 denotes there is no diamond but there is a path. 1 denotes there is diamond at that lo...
Psychosomatics asked 21/10, 2015 at 8:26

10

Solved

I'm trying to count trailing zeros of numbers that are resulted from factorials (meaning that the numbers get quite large). Following code takes a number, compute the factorial of the number, and c...
Fierro asked 23/7, 2009 at 21:11

6

If you were testing a count function like the one below, is it considered to be 'right' or 'wrong' to test multiple things for the function in one function vs having a test function for each ...
Stites asked 17/4, 2009 at 21:2

2

I need to select n records at random from a set of N (where 0 < n < N). A possible algorithm is: Iterate through the list and for each element, make the probability of selection = (number...
Mundt asked 28/1, 2016 at 15:40

2

Solved

Problem Statement: On a positive integer, you can perform any one of the following 3 steps. Subtract 1 from it. ( n = n - 1 ) If its divisible by 2, divide by 2. ( if n % 2 == 0 , then n = n / ...
Hollywood asked 4/5, 2015 at 11:58

1

Solved

In Idris/Haskell, one can prove properties of data by annotating the types and using GADT constructors, such as with Vect, however, this requires hardcoding the property into the type (e.g. a Vect ...
Polluted asked 30/11, 2014 at 23:40

11

Solved

First of all, is this only possible on algorithms which have no side effects? Secondly, where could I learn about this process, any good books, articles, etc?
Fagot asked 27/1, 2010 at 19:1

2

Today I wrote an algorithm to compute the Fast Fourier Transform from a given array of points representing a discrete function. Now I'm trying to test it to see if it is working. I've tried about a...
Basanite asked 19/6, 2014 at 21:50

4

Solved

I've been refactoring some rather crufty code and came across the following rather odd construct: #!/usr/bin/env python2.7 # ... if (opts.foo or opts.bar or opts.baz) is None: # (actual option na...
Darmit asked 5/4, 2013 at 7:35

13

These for-loops are among the first basic examples of formal correctness proofs of algorithms. They have different but equivalent termination conditions: 1 for ( int i = 0; i != N; ++i ) 2 for ( ...

4

Solved

I've come to Java from C++. In the C++ world we pay attention to exception safety, and note that mutators can provide different guarantees in the face of exceptions thrown by the mutator itself or ...
Flirtation asked 4/1, 2012 at 14:56

5

Solved

I'm trying to learn exactly what it means to prove a program correct. I'm starting from scratch and getting hung up on the first steps/the introduction to the topic. In this paper on total functio...

1

Solved

This snippet (taken from this question) compiles fine with g++ (as seen), so long the template before the return type is there. In contrast, VC10 does not compile that code with the following error...
Shurlock asked 3/6, 2011 at 20:26

5

Solved

What types of applications have you used model checking for? What model checking tool did you use? How would you summarize your experience w/ the technique, specifically in evaluating its ef...

4

Solved

Hi I have got some code that is reported as having the NP_GUARANTEED_DEREF issue by Findbugs. Now looking at my code I don't quite understand what is wrong with it, can anyone suggest what the prob...

1

Solved

Is code produced by Cython always just as correct as the Python code it was produced from? It may help other readers to address the use of Cython static type declarations and other Cython features...
Lindon asked 21/3, 2011 at 18:34

4

Solved

Suppose I'm working with code of a stack machine, which can do some simple operations (push constant, add, mul, dup, swap, pop, convert types) on ints and doubles. Now the program I'm writing tak...
Carabiniere asked 26/1, 2011 at 12:13

9

Solved

Many standard C and POSIX functions return -1 for error, and 0 on success, for example truncate, fflush, msync, etc. int ret = truncate("/some/file", 42); Is it better practice to check for succ...
Porta asked 1/10, 2010 at 4:38

5

Solved

I was under the impression that I only need to specify the "protocol" when using JavaScript in URL attributes, such as in hrefs. Is this the only "useful" context for javascript:? Sensible: <a...
Lengthwise asked 23/2, 2010 at 20:28

© 2022 - 2024 — McMap. All rights reserved.