November 2016
Intermediate to advanced
469 pages
14h 9m
English
© Giulio Zambon 2016
Giulio Zambon, Practical C, 10.1007/978-1-4842-1769-6_9
Giulio Zambon1
(1)Harrison, Aust Capital Terr, Australia
In the previous chapter, you read about ordered arrays and binary trees. In particular, you learned how to work with ordered arrays of pointers to insert, delete, and find individual items.
In this chapter, you will learn methods to bring order to unordered arrays.
The simplest way to sort an array is to go through its elements one by one and move them to their correct positions. This is what you do when you sort the cards in your hand while playing a card game.
Listing 9-1 shows how easy it is to apply insertion sort to an array of pointers.
1. //-------------------------------------------------------------- ...Read now
Unlock full access