I have a book on data structures and programming, and I referenced it to implement a B-tree insertion function. I copied most of the algorithm and variable names from the code samples in the book, but adapted it to match the structures I had already prototyped.
I'd like to release my code under a permissive license (e.g. the MIT License), but I don't know whether or not I'd be plagiarizing.
I have seen citations like this in open-source code before:
// See Knuth, Volume 2, section 4.3.1, Algorithm D.
Note that the book I referenced is not Knuth. The copyright notice on the cover of my book says:
All rights reserved. No part of this book may be reproduced, in any form or by any means, without permission in writing from the publisher.
That said, would it be legal for me to release code, under my own copyright, based on code samples found in a book? Am I required to add a citation like the Knuth example above?