Cover....1
Title page....2
Copyright and credits....3
Contributors....4
Table of Contents....6
Preface....10
Chapter 1: Data Types....18
C# as a programming language....19
.NET-based console applications....20
Division of data types....23
Value types....24
Integral numbers....25
Floating-point numbers....26
Boolean values....27
Unicode characters....27
Constants....28
Enumerations....29
Value tuples....31
User-defined structs....33
Nullable value types....34
Reference types....36
Objects....36
Strings....37
Classes....39
Records....42
Interfaces....44
Delegates....46
Dynamics....47
Nullable reference types....49
Summary....51
Chapter 2: Introduction to Algorithms....52
What are algorithms?....53
Definition....53
Real-world examples....54
Notations for algorithm representation....55
Natural language....56
Flowchart....56
Pseudocode....59
Programming language....60
Types of algorithms....61
Recursive algorithms....61
Divide and conquer algorithms....62
Back-tracking algorithms....62
Greedy algorithms....63
Heuristic algorithms....63
Dynamic programming....64
Brute-force algorithms....64
Computational complexity....65
Time complexity....65
Space complexity....66
Summary....67
Chapter 3: Arrays and Sorting....68
Single-dimensional arrays....69
Example – month names....73
Multi-dimensional arrays....75
Example – multiplication table....78
Example – game map....79
Jagged arrays....81
Example – yearly transport plan....83
Sorting algorithms....86
Selection sort....87
Insertion sort....90
Bubble sort....91
Merge sort....94
Shell sort....97
Quicksort....99
Heap sort....102
Performance analysis....106
Summary....111
Chapter 4: Variants of Lists....112
Simple lists....112
Array lists....113
Generic lists....116
Sorted lists....121
Example – address book....122
Linked lists....123
Singly linked lists....123
Doubly linked lists....124
Circular singly linked lists....129
Circular doubly linked lists....135
List-related interfaces....138
Summary....140
Chapter 5: Stacks and Queues....142
Stacks....142
Example – Reversing a word....144
Example – Tower of Hanoi....145
Queues....153
Example – Call center with a single consultant....156
Example – Call center with many consultants....160
Priority queues....165
Example – Call center with priority support....168
Circular queues....172
Example – Gravity roller coaster....176
Summary....179
Chapter 6: Dictionaries and Sets....182
Hash tables....182
Example – phone book....185
Dictionaries....187
Example – product location....190
Example – user details....192
Sorted dictionaries....193
Example – encyclopedia....195
Hash sets....197
Example – coupons....200
Example – swimming pools....202
“Sorted” sets....205
Example – removing duplicates....206
Summary....207
Chapter 7: Variants of Trees....208
Basic trees....208
Implementation....210
Example – hierarchy of identifiers....211
Example – company structure....212
Binary trees....214
Traversal....215
Implementation....218
Example – simple quiz....222
Binary search trees....225
Implementation....228
Example – BST visualization....235
Self-balancing trees....243
AVL trees....244
Red-black trees....245
Tries....247
Implementation....249
Example – autocomplete....253
Heaps....256
Summary....258
Chapter 8: Exploring Graphs....260
The concept of graphs....261
Applications....264
Representations....266
Adjacency list....266
Adjacency matrix....269
Implementation....271
Node....271
Edge....272
Graph....273
Example – undirected and unweighted edges....277
Example – directed and weighted edges....278
Traversal....279
Depth-first search....279
Breadth-first search....283
Minimum spanning tree....286
Kruskal’s algorithm....288
Prim’s algorithm....293
Example – telecommunication cable....298
Coloring....301
Example – voivodeship map....304
Shortest path....307
Example – path in game....311
Summary....314
Chapter 9: See in Action....316
The Fibonacci series....317
Minimum coin change....319
Closest pair of points....320
Fractal generation....324
Rat in a maze....329
A Sudoku puzzle....331
Title guess....335
A password guess....339
Summary....341
Chapter 10: Conclusion....344
Classification....345
Arrays....347
Lists....348
Stacks....350
Queues....350
Dictionaries....352
Sets....352
Trees....353
Graphs....357
The last word....359
Index....360
Other Books You May Enjoy....369
Write sophisticated C# code with this complete guide to using diverse data structures and algorithms, featuring ready-to-use code snippets, detailed explanations, and illustrations
Building your own applications is exciting but challenging, especially when tackling complex problems tied to advanced data structures and algorithms. This endeavor demands profound knowledge of the programming language as well as data structures and algorithms - precisely what this book offers to C# developers.
Starting with an introduction to algorithms, this book gradually immerses you in the world of arrays, lists, stacks, queues, dictionaries, and sets. Real-world examples, enriched with code snippets and illustrations, provide a practical understanding of these concepts. You'll also learn how to sort arrays using various algorithms, setting a solid foundation for your programming expertise. As you progress through the book, you'll venture into more complex data structures - trees and graphs - and discover algorithms for tasks such as determining the shortest path in a graph before advancing to see various algorithms in action, such as solving Sudoku.
By the end of the book, you'll have learned how to use the C# language to build algorithmic components that are not only easy to understand and debug but also seamlessly applicable in various applications, spanning web and mobile platforms.
This book is for developers looking to learn data structures and algorithms in C#. While basic programming skills and C# knowledge is useful, beginners will find value in the provided code snippets, illustrations, and detailed explanations, enhancing their programming skills. Advanced developers can use this book as a valuable resource for reusable code snippets, instead of writing algorithms from scratch each time.