Sorting is a common programming task, though it's the computer that does the work. As a programmer, you must implement the sort. The easiest sort to code and to understand is the bubble sort. The qsort() function uses the quicksort algorithm to sort data faster than a bubble sort and without a lot of overhead.
- [Instructor] Sorting is one of those mindless, … repetitive tasks that doesn't bother a computer at all. … As a programmer, your job is to code the sort. … The simplest form of sort is the bubble sort … which is easy to understand in code … but a lot slower than some … of the more effective, efficient methods. … This code offers a bubble sort … on the list array of 100 random integers. … The first chunk of code assigns those 100 random values … to the ArrayList. … Then it displays the values. … The bubble sort starts at line 25. … It uses a nested loop to compare each array element … to every other array element. … The outer for loop with the variable a … traverses from element zero in the array list … to the next to last element which is size minus one. … The inner for loop at line 27 … with variable b moves from one plus the value … of variable a up to the full size of the array. … Now line 30 compares both values. … To sort from smallest to largest, … if the value of the first variable is greater …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.