Street Coder

Sedat Kapanoglu

With examples in C#

The rules to break and

how to break them

Sedat Kapanoglu

˘

M A N N I N G

Impact of complexity on performance

Search algorithm

Complexity

Time to find a record among 60 rows

The DIY quantum computer Lisa’s uncle has in his garage

O(1)

1 second

Binary search

O(log N)

6 seconds

Linear search (because your boss asked you to do it an

O(N)

60 seconds

hour before the presentation)

The intern accidentally nested two for loops.

O(N2)

1 hour

Some randomly pasted code from Stack Overflow that also

O(2N)

36.5 billion years

finds a solution to some chess problem while searching,

but the developer didn’t bother to remove that part.

Instead of finding the actual record, the algorithm tries to O(N!)

The end of the universe, but still

find the arrangement of records that spell out the record before those monkeys finish their

you’re looking for when sorted in a certain way. The good so-called Shakespeare

news is that the developer doesn’t work here anymore.

Street Coder

THE RULES TO BREAK AND HOW TO BREAK THEM

SEDAT KAPANOĞLU

M A N N I N G

SHELTER ISLAND

For online information and ordering of this and other Manning books, please visit

www.manning.com. The publisher offers discounts on this book when ordered in quantity.

For more information, please contact

Special Sales Department

Manning Publications Co.

20 Baldwin Road

PO Box 761

Shelter Island, NY 11964

Email: orders@manning.com

©2022 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end.