Learn how the merge function takes two sorted sequences and merges them into one sorted sequence. You may also provide your own comparison operator function.
- [Instructor] The merge function will merge…two sorted sequences into one.…Here I have a working copy of merge.cpp…from chapter six of the exercise files.…And you'll notice I have a comparison operator…that's a reverse comparison operator…you notice it's a greater than.…And I have two vectors…both of them unsorted…and they're both parts of my prime number sequence.…And then I have a vector three which is the size…of both the vectors added together.…
And that is not initialized.…And so first I sort the two vectors…and then I merge them using the merge function…which begins with the range of one of the ranges…to merge the second range to merge…and then the target beginning.…And so when I build and run you notice that…I've got my two unsorted sequences.…Here they are after they're sorted.…And here they are merged…all into one nice sorted sequence.…
So even though these are not sequential.…In other words, there's numbers between 11 and 17.…And 17 and 37 there's several of the them…all that gets zippered together…and in order with merge.…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- 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.