From the course: C Standard Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Sort and search main
- [Instructor] Here's an example application where I will run b search twice in an array that's the array defined in 9.14 which is called nums and it's an array of ten integers. As you can see it's not sorted in any particular way and I will look for one number that I know is in the array first and then I'll look for a number I know is not in the array. Now remember that b search requires the array to already be sorted and so I will have to call q sort so this application will show both functions. As you can see I have already written some code so I want you to pay attention to line four where I have a function that prints out the array. It's called print array and you may want to take a minute to verify what it does but it's just printing out integers. We also have a series of comments in the code that act as a to do list to fill in the blanks. So as you can see in lines ten and eleven we have to write a compare function and a find function. The compare function is the call back…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Memory allocation1m 32s
-
(Locked)
Memory allocation example2m 29s
-
(Locked)
Random number generation1m 48s
-
(Locked)
Random number generation example2m 40s
-
(Locked)
String conversion2m 11s
-
(Locked)
String conversion example6m 29s
-
(Locked)
Sort and search1m 52s
-
(Locked)
Sort and search main4m 50s
-
(Locked)
Sort and search functions5m 6s
-
(Locked)
Challenge: Let's get random1m 38s
-
(Locked)
Solution: Let's get random5m 40s
-
-
-
-