1 / 5

Debugging practice

Instructor: Artem A. Lenskiy, PhD. Debugging practice. September 5, 2012. Bubble Sorting.

angelo
Download Presentation

Debugging practice

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Instructor: Artem A. Lenskiy, PhD Debugging practice September 5, 2012

  2. Bubble Sorting First Pass:( 65 3 1 8 7 2 4 ) ( 56 3 1 8 7 3 4), Compares and swaps them.( 5 63 1 8 7 2 4 ) ( 5 36 1 8 7 2 4 ), Swap since 6 > 3( 5 3 61 8 7 2 4 ) ( 5 3 16 8 7 2 4 ), Swap since 6 > 1( 5 3 6 18 7 2 4 ) ( 5 3 6 18 7 2 6 ), Does not swap them, (8 > 1), ( 5 3 6 1 8 7 2 4 ) ( 5 3 6 1 7 8 2 4 ), Swap since 8 > 7 ( 5 3 6 1 7 82 4 ) ( 5 3 6 1 7 28 4 ), Swap since 8 > 2 ( 5 3 6 1 72 8 4 ) ( 5 3 6 1 72 48 ), Swap since 8 > 2 Second Pass:( 5 3 6 1 72 4 8 ) ( 3 5 6 1 72 4 8 ), ( 3 5 6 1 72 4 8 ) ( 356 1 72 4 8 ), ( 35 6 1 72 4 8 ) ( 35 1 672 4 8 ), ( 35 6 1 7 2 4 8 ) ( 35 1 1 7 2 4 8 ), ( 35 6 1 7 24 8 ) ( 35 1 12 74 8 ), ( 35 6 12 74 8 ) ( 35 1 12 478 ), ( 35 1 124 78) ( 35 1 172 78), • Third Pass: ( 35 1 124 78 ) ( 35 1 172 78 ), N comparisons maximum N-1 comparisons Don’t need to call N-2 comparisons …

  3. Bubble Sorting The program has to request list of number form command line Then the main function will have the following parameters To convert stings in argv[] to numbers user atoi(); The main function has to call sorting algorithm Bubble, that you have to implement: the Bubble function will have to call function Order, which swap values *p and *q, if *p>*q

  4. Bubble Sorting (hinting code) Program output

  5. Debugging in Visual C • Press F9 to set breakpoint • Press F5 to run your program • Press F10 execute your program step by step • Press F11 to step inside functions • To add variables to watch window either drag and drop variable you want to watch or select it and press right mouse click then press W.

More Related