Skip to Content
C# Data Structures and Algorithms
book

C# Data Structures and Algorithms

by Marcin Jamro
April 2018
Intermediate to advanced content levelIntermediate to advanced
292 pages
6h 44m
English
Packt Publishing
Content preview from C# Data Structures and Algorithms

Example – coupons

The first example represents the system that checks whether a one-time coupon has already been used. If so, a suitable message should be presented to the user. Otherwise, the system should inform the user that the coupon is valid and it should be marked as used and cannot be used again. Due to the high number of coupons, it is necessary to choose a data structure that allows for quickly checking whether an element exists in some collection. For this reason, the hash set is chosen as a data structure for storing identifiers of the used coupons. Therefore, you just need to check whether an entered identifier exists in the set.

Let's take a look at the code, which should be added to the Main method in the Program class. The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Data Structures and Algorithms in C#

Beginning Data Structures and Algorithms in C#

Marcin Jamro

Publisher Resources

ISBN: 9781788833738Supplemental Content