Source Code for Data Structures and Algorithm Analysis in C (Second Edition)

Here is the source code for Data Structures and Algorithm Analysis in C (Second Edition), by Mark Allen Weiss. The materials here are copyrighted.

Click here for the code in compressed tar format. Here's the uncompressed version.

Here is a listing of source code on a chapter-by-chapter basis. This is in a format suitable for printing out. Click on the chapter of interest: 1 2 3 4 5 6 7 8 10 12 all

Here is each file.

fatal.h: macros for fatal errors

fig1_2.c: a simple recursive routine with a test program

fig1_3.c: an example of infinite recursion

fig1_4.c: recursive routine to print numbers, with a test program

max_sum.c: Various maximum subsequence sum algorithms

fig2_9.c: Test program for binary search

fig2_10.c: Euclid's algorithm, with a test program

fig2_11.c: Recursive exponentiation algorithm, with a test program

list.h: Header file for linked list

list.c: Implementation for linked list

testlist.c: Test program for linked list package

poly.c: Polynomials

cursor.h: Header file for cursor linked list

cursor.c: Implementation for cursor linked list

testcurs.c: Test program for cursor implementation of linked lists

stackar.h: Header file for stack: array version

stackar.c: Implementation for stack: array version

teststka.c: Test program for (array-based) stacks

stackli.h: Header file for stack: list version

stackli.c: Implementation for stack: list version

teststkl.c: Test program for (list-based) stacks

queue.h: Header file for queue: array version

queue.c: Implementation for queue: array version

testque.c: Test program for queues

tree.h: Header file for binary search tree

tree.c: Implementation for binary search tree

testtree.c: Test program for binary search tree

avltree.h: Header file for AVL tree

avltree.c: Implementation for AVL tree

testavl.c: Test program for AVL trees

hashfunc.c: Some hash functions for strings

hashsep.h: Header file for separate chaining

hashsep.c: Implementation for separate chaining

testhash.c: Test program for hash tables

hashquad.h: Header file for quadratic probing hash table

hashquad.c: Implementation for quadratic probing hash table

binheap.h: Header file for binary heap

binheap.c: Implementation for binary heap

testheap.c: Test program for binary heaps

leftheap.h: Header file for leftist heap

leftheap.c: Implementation for leftist heap

testleft.c: Test program for leftist heaps

binomial.h: Header file for binomial queue

binomial.c: Implementation for binomial queue

testbin.c: Test program for binomial queues

sort.c: A collection of sorting and selection routines

disjsets.c: Disjoint sets algorithms, with test program

fig10_38.c: Simple matrix multiplication algorithm with a test program

fig10_40.c: Algorithms to compute Fibonacci numbers

fig10_43.c: Inefficient recursive algorithm (see text)

fig10_45.c: Better algorithm to replace fig10_43.c (see text)

fig10_46.c: Dynamic programming algorithm for optimal chain matrix multiplication, with a test program

fig10_53.c: All-pairs algorithm, with a test program

fig10_55.c: Implementation and test program for uniform random numbers

fig10_62.c: Randomized primality testing algorithm, with a test program

splay.h: Header file for top-down splay tree

splay.c: Implementation for top-down splay tree

testsply.c: Test program for splay trees

dsl.h: Header file for deterministic skip list

dsl.c: Implementation for deterministic skip list

testdsl.c: Test program for determinstic skip lists

redblack.h: Header file for top-down red black tree

redblack.c: Implementation for top-down red black tree

testrb.c: Test program for red black trees

treap.h: Header file for treap

treap.c: Implementation for treap

testtrp.c: Test program for treap

aatree.h: Header file for AA-tree

aatree.c: Implementation for AA-tree

testaa.c: Test program for AA-trees

kdtree.c: Implementation and test program for k-d trees

pairheap.h: Header file for pairing heap

pairheap.c: Implementation for pairing heap

testpair.c: Test program for pairing heaps