Thread: code required for the problem..

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    2

    Unhappy code required for the problem..

    hi all..

    i am thoroughly confused with the question. could anyone help me out with the code

    "Question : to write a C program to sort a sequence of non negative numbers in ascending order. the method used should make use of finding out the smallest integer by converting it to its binary equivalent and be able to process binary representations of integer."

    I have attached the word document of the question along.

    It would be very helpful if anyone could help me out in this situation.

    thank you..

  2. #2
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    There isn't that much to this question. Do you understand how non-negative integers are represented in binary ?

    If you do, then you shouldn't be having trouble with coding this, or you need to be more specific about your problem.

    If you don't : check this out.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    2
    thanks for the reply.

    but i need the code.. i am struggling as i am a new student to C programming.

    thank you anyways..

  4. #4
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    Doesn't work that way here. Post an attempt and we'll tell you where you went wrong.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Did you read the homework announcement? http://cboard.cprogramming.com/annou...t.php?f=4&a=39

    The algorithm to be used for this assignment has three steps. Firstly, convert each integer into its equivalent binary representation. Secondly, make a single pass of all the binary representations through a two dimensional array. Thirdly, convert each of the binary representations back into its equivalent integer. The first and third steps can be done by an obvious sequential algorithm. For the second step we set up an array of linear arrays.
    Steps 1 and 3 are addressed in Happy_Reaper's link above and here: http://en.wikipedia.org/wiki/Binary_numeral_system

    Step 2 could be implemented with any sorting algorithm, such as with the Bubble Sort or Insertion Sort.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Replies: 5
    Last Post: 09-28-2004, 12:38 PM
  4. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM
  5. Replies: 5
    Last Post: 12-03-2003, 05:47 PM