liveBook · Manning

Reversing

Reversing is an operation that produces a sequence's elements in the opposite order, either by modifying the source or returning a reversed sequence.

How 3 Manning books explain it

Fabulous Adventures in Data Structures and Algorithms

Reverse is a method that constructs a new immutable linked list containing the input list's items in reverse order.

How it is used
Builds a reversed immutable list and transfers queued items between stacks when an immutable queue needs a new dequeue stack.
How deep it goes
Works through an iterative C# implementation, unchanged-input behavior, and O(n) time and extra-memory costs.
Examples
Tests reversal of a five-item integer list and uses stack reversal in an enqueue-and-dequeue sequence.
What you can do after
Build it from scratch with an empty accumulator and repeated Push calls, then apply the same pattern to an immutable queue.

Read how Fabulous Adventures in Data Structures and Algorithms explains reversing →

Python How-To

The reverse method is a Python list method that reverses a list in place and returns None.

How it is used
Use reversing to mutate a list into reverse order before subsequent readable, left-to-right operations.
How deep it goes
Defines in-place mutation and the None return, then contrasts reverse() with reversed() and negative-step slicing.
Examples
Demonstrates reversing before slicing and contrasts it with iterating through reversed(tasks).
What you can do after
Apply it to reverse an existing list in place and avoid treating its None return as reversed data.

Read how Python How-To explains reversing →

The Quick Python Book, Fourth Edition

The reverse method is a Python list operation that reverses the order of elements in the list in place.

How it is used
Applies an in-place operation when a list’s element order must be reversed.
How deep it goes
Defines the specialized in-place operation and demonstrates its output, without discussing implementation internals.
Examples
Demonstrates reversing [1, 3, 5, 6, 7] to [7, 6, 5, 3, 1].
What you can do after
Apply the reverse method to change an existing list from forward order to backward order.

Read how The Quick Python Book, Fourth Edition explains reversing →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.