Does this problem have more than what it seems to me ?

This is a discussion on Does this problem have more than what it seems to me ? within the Tech Board forums, part of the Community Boards category; It seems, to me that the program/function always terminates. (Though it doesn't produce the intended result (the function is named ...

  1. #1
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498

    Does this problem have more than what it seems to me ?

    Name:  prob7.png
Views: 128
Size:  18.4 KB
    It seems, to me that the program/function always terminates.
    (Though it doesn't produce the intended result (the function is named 'mu' which I guess, is for multiplication) for a < 0).
    And the 'Q' required is just the Loop Invariant (right?), which I think is "y=i*b".

    Or am I missing something large, considering that this is for a post grad paper and I've just begun my college education(two weeks, to be exact).

    (The whole question paper is here)
    Attached Images Attached Images  
    Last edited by manasij7479; 07-16-2012 at 10:42 AM.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  2. #2
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    494
    I have a hunch that condition P is about finding/avoiding boundary conditions to get an infinite loop, but that is most likely wrong.
    If the loop invariant were say
    i <= a
    instead of
    i < a
    , then we have an infinite loop at
    mu(INT_MAX,x)
    .
    For the given case though, I couldn't find any.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,215
    O_o

    Yeah, I'm not getting it either; the instructions are crazy vague.

    Code:
    if (0 = 0) do exit
    Does that insanity actually fit both roles?

    Soma

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,489
    Q should be some expression involving a,b,i,y (those things involved in the loop)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,215
    Q should be some expression involving a,b,i,y (those things involved in the loop)
    Bwahahaa!

    Okay, so, just to confirm here, this isn't about writing code at all is it? It is about reasoning through existing code isn't it?

    Soma

  6. #6
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    I think so.
    Something conceptually similar to assert.
    Thats why I think Q will be "y==i*b".
    But I have no idea what P can be.

    (W.r.t the first comment, shouldn't language/implementation based things like INT_MAX, be left out of consideration in algorithms? )
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp problem, whats the problem, i cant figure it out!
    By AvaGodess in forum C Programming
    Replies: 14
    Last Post: 10-18-2008, 06:45 PM
  2. Replies: 4
    Last Post: 10-16-2008, 07:30 PM
  3. sturct/pointer problem, and fscanf problem
    By hiphop4reel in forum C Programming
    Replies: 6
    Last Post: 07-28-2008, 09:40 AM
  4. Visual Studio Linker problem or my problem?
    By OOPboredom in forum C Programming
    Replies: 2
    Last Post: 04-13-2004, 12:32 AM
  5. syntax linked list problem & struct problem
    By beely in forum C Programming
    Replies: 5
    Last Post: 11-11-2002, 08:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21