Book Image

Learning F# Functional Data Structures and Algorithms

By : Adnan Masood
Book Image

Learning F# Functional Data Structures and Algorithms

By: Adnan Masood

Overview of this book

Table of Contents (21 chapters)
Learning F# Functional Data Structures and Algorithms
Credits
Foreword
Foreword
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 6. See the Forest for the Trees

 

I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships.

 
 -- Linus Torvalds

In the previous chapter, we started with building a basic ADT of stack using F# and after implementing the fundamental operations, proceeded to make a concurrent version of stack. Then, step-by-step, we learned how to do unit testing in C# for an F# program, and how to implement the same test method in F#. Later, we used our knowledge of stack operations to implement the parenthesis balancing algorithm.

Continuing with the theme of implementing ADTs, in this chapter we will learn about graph-related algorithms, and implementation of our own trees. Starting with a simple binary tree, we will discuss how implementation differs for an imperative (mutable) versus persistent...