Thread: Bubble Sort Code :(

  1. #1
    Banned
    Join Date
    Apr 2011
    Location
    Santry, Ireland
    Posts
    29

    Bubble Sort Code :(

    hi every1, i am making a banking database for college and i need code for my assignment for a bubble sort to be able to

    * alphabetically by surname
    * by account balance
    * All acounts which have an overdraft sorted by account surname

    its seriously ........in me off

  2. #2
    Registered User
    Join Date
    Feb 2011
    Posts
    17

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    You may also want to read the following:
    Announcements - C Programming
    Announcements - General Programming Boards
    Announcements - General Programming Boards

    Make your best effort, and when you get really stuck post your relevant code and specific questions, and we'll help you out.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by irishfeeney92 View Post
    hi every1, i am making a banking database for college and i need code for my assignment for a bubble sort to be able to

    * alphabetically by surname
    * by account balance
    * All acounts which have an overdraft sorted by account surname

    its seriously ........in me off
    Start writing...

    Don't bother going the scoop and poop route since most colleges with curricula from this millenium will do searches to find your "found" code online and you'll lose marks big time.

    Learn C ... not Google!

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    17
    A caveat to my post is that I am not advocating the "scoop and poop route" (which is a freaking awesome term that should be copyrighted before i steal it). Use my link to understand the mechanics of the bubble sort. I just learned it last week and once you understand how simple it really is you kind of want to just bang your head against the wall for stressing out about it so much.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rgrwatson85 View Post
    A caveat to my post is that I am not advocating the "scoop and poop route" (which is a freaking awesome term that should be copyrighted before i steal it).
    Go ahead use it all you like... Consider it a public domain aspersion.

    Use my link to understand the mechanics of the bubble sort. I just learned it last week and once you understand how simple it really is you kind of want to just bang your head against the wall for stressing out about it so much.
    I "reuse" my own code all over the place... In fact I build libraries so I don't lose the good stuff.

    However; for a student "borrowing" code is entirely self-defeating. It sidesteps the development of problem solving skills that are the programmer's forte. Without these skills a programmer is dead in the water the first time he encounters a unique problem.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    3,970
    Quote Originally Posted by CommonTater View Post
    However; for a student "borrowing" code is entirely self-defeating.
    I try to find the algorithm, I want, in Pascal (or some other non C like language) and then convert it to C.
    This avoids most of the self-defeating part of using algorithms from the web.
    You need to understand C to convert an non C/C++/C#/Java code into it.

    Tim S.

  8. #8
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    463
    Quote Originally Posted by stahta01 View Post
    I try to find the algorithm, I want, in Pascal (or some other non C like language) and then convert it to C.
    This avoids most of the self-defeating part of using algorithms from the web.
    You need to understand C to convert an non C/C++/C#/Java code into it.

    Tim S.
    Why not just read the pseudo-code?
    Last edited by nimitzhunter; 04-25-2011 at 11:23 PM.
    "All that we see or seem
    Is but a dream within a dream." - Poe

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by stahta01 View Post
    I try to find the algorithm, I want, in Pascal (or some other non C like language) and then convert it to C.
    This avoids most of the self-defeating part of using algorithms from the web.
    You need to understand C to convert an non C/C++/C#/Java code into it.

    Tim S.
    And, how much do you learn about the actual code doing that?

    Ask yourself what you would do if you found yourself in a totally unique situation for which you can't scoop and poop (and translate) someone else's code. You don't have anyone else to do your thinking for you... now it's all on you... What ya gonna do?

    Sure you've learned C syntax by translating all that code... but what have you actually learned about programming?

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    3,970
    @CommonTater:

    I consider using other people algorithms a valid way to right code.
    So, you spend all of your time reinventing the wheel.
    I hope you are not the type that says we need to throw out all the project past code just because you did not write it. I worked with a few college kids who said things like that just because they did not wish to spend time reading other people code.
    I thought a experience programmer like you would understand my point of view.

    I consider myself a average to good C Programmer. Most of you, who answer posts here, are better than me.
    I have forgotten a lot about programming in C over the past few decades.
    (Self taught myself K&R C around the early 1980s) I am doing a little bit of embedded C programming in the real world and I was amazed at how much I have forgotten; add to that it is only a C-Like programming (Rabbit Dynamic C) that has caused me to pickup bad habits.

    As a Student taking an C++ Class; I consider myself better than most of the students in class on my knowledge of C.
    (Most of them barely qualify as beginners)
    It amazing what working in the real world teaches you about learning something with no outside help except the Internet.
    I learned SQL by reading posts on SQLTeam and answering the questions (normally too late to help the poster).
    I wish I knew more about OOP; the class is barely covering the basics of C++.

    Tim S.
    Last edited by stahta01; 04-26-2011 at 06:50 PM. Reason: Added Detail.

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    3,970
    Quote Originally Posted by nimitzhunter View Post
    Why not just read the pseudo-code?
    Edit: Most places that state pseudo-code are really using Pascal like syntax.
    Example here: http://en.wikipedia.org/wiki/Comb_sort this almost exactly like Pascal

    Are you too young to know that Pascal was created as a teaching language and was used to write algorithms for decades.
    I use Pascal like syntax to write my pseudo-code. I would use pseudo-code if it did not have Pascal or Ada.

    Tim S.
    Last edited by stahta01; 04-26-2011 at 06:29 PM.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rgrwatson85 View Post
    Stop doing this! You are NOT helping anyone.

    Scoop and poop coding like this teaches nobody anything... except plagerism...

    You don't learn programming by stealing other people's code. What you do is sabotage yourself so that the first time you get handed an assignment you can't steal from somewhere else you are totally lost...

    Moreover; most programming teachers do searches for code online... get caught and watch what happens to your grade.


    The mods here should close this thread.

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    3,970
    Quote Originally Posted by rgrwatson85 View Post
    Google is your friend...

    Buble sorting algorithm and source code in C
    FYI: That code is NOT common implementation of bubble sort. Removed link from quote on purpose.
    Edit: Change to common instead of better; I prefer the swap flag because it was what I learned instead of nested loop; I am not sure it is better.

    More common algorithm here: http://en.wikipedia.org/wiki/Bubble_...implementation

    Tim S.
    Last edited by stahta01; 04-26-2011 at 06:59 PM.

  14. #14
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by CommonTater View Post
    Stop doing this! You are NOT helping anyone.

    Scoop and poop coding like this teaches nobody anything... except plagerism...

    You don't learn programming by stealing other people's code.
    I know that cheating on yer homework is a concern, but giving people examples is not the same thing as telling them to "steal", and examples are a fine way to learn. In fact, sometimes they are the best and only way to learn, which is one reason open sources have benefited the world.

    I almost never cut and paste code directly, but occasionally I (more or less) do, and I credit my sources. Probably this is not a good tactic with homework, tho.

    Quote Originally Posted by CommonTater View Post
    Moreover; most programming teachers do searches for code online... get caught and watch what happens to your grade.
    Sure, that is their job, and they get well paid for it. You do not need to do it for them.
    Also: people who showed up for the class on day one have been warned already.


    WRT bubble sort, just try a minimal version with numbers, once you have that worked out the concept will be clear to you, and/or you can post the code here and get help quickly. Bubble sorting an array of ints is about 10 very simple lines.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    MK27... Of course examples are a good learning tool... but these examples should come from textbooks and blackboards. A teacher who does not explain code concepts to his students isn't doing his job.

    Moreover; if you go back to the first message you will see that the OP is asking for code... not help. You have to *know* what he's going to do with a working example...
    Last edited by CommonTater; 04-26-2011 at 09:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-10-2011, 02:50 PM
  2. Bubble Sort Code Problem...
    By h4rrison.james in forum C Programming
    Replies: 7
    Last Post: 01-22-2009, 07:43 AM
  3. problem(program error) with bubble sort(code included)
    By choykawairicky in forum C++ Programming
    Replies: 6
    Last Post: 05-16-2004, 08:54 AM
  4. Problem with Bubble Sort code
    By lisa1234 in forum C++ Programming
    Replies: 7
    Last Post: 01-13-2004, 03:40 PM
  5. Bubble Sort, Qucik Sort
    By insomniak in forum C Programming
    Replies: 2
    Last Post: 03-15-2003, 04:54 PM