This video provides a description and example of bsearch() and qsort().
- [Instructor] Let me briefly tell you about two functions…that implement array sort and search respectively.…But just to be clear,…let me tell you what I mean by sort and search.…First, a sort algorithm takes an array…where the elements are placed in no particular order…and it somehow moves these elements to end up…with a sorted array either in ascending or descending order.…Now, a search algorithm looks for an element…which may or may not be in the array.…
It compares this element to the elements in the array…somehow traversing the array until the element is found…or until it learns that the element was not in the array.…The sorting function is called qsort…and its parameters are the address of the first element…in the array, the element count…and the size in bytes of each element.…The last parameter is a call back function…that is used to compare two values…as this is the heart of a sorting algorithm.…
This is a call back function…because qsort is supposed to work on any type of array,…including arrays of structures.…
- Working with header files
- C constants and types
- Unformatted and formatted input/output
- Accessing files with C functions
- Generating random numbers
- Converting strings
- Sorting and searching for data
- Manipulating strings
- Using mathematical functions
Skill Level Intermediate
1. The C Standard Library
2. Input and Output Library: stdio.h
3. General Purpose: stdlib.h
4. String Functions: string.h
5. Mathematical Functions: math.h
- 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.