Problem Solving in Data Structures Algorithms Using C Programming Interview Guide First Edition Hemant Jain All Chapter Instant Download
Problem Solving in Data Structures Algorithms Using C Programming Interview Guide First Edition Hemant Jain All Chapter Instant Download
com
https://textbookfull.com/product/problem-solving-
in-data-structures-algorithms-using-c-programming-
interview-guide-first-edition-hemant-jain/
https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-programming-interview-guide-1st-edition-hemant-
jain/
textbookfull.com
https://textbookfull.com/product/problem-solving-in-data-structures-
algorithms-using-c-first-edition-jain/
textbookfull.com
https://textbookfull.com/product/data-structures-algorithms-in-go-1st-
edition-hemant-jain/
textbookfull.com
https://textbookfull.com/product/the-existentialist-moment-the-rise-
of-sartre-as-a-public-intellectual-1st-edition-patrick-baert/
textbookfull.com
Interdisciplinary Approaches to Pedagogy and Place-Based
Education: From Abstract to the Quotidian 1st Edition
Deric Shannon
https://textbookfull.com/product/interdisciplinary-approaches-to-
pedagogy-and-place-based-education-from-abstract-to-the-quotidian-1st-
edition-deric-shannon/
textbookfull.com
https://textbookfull.com/product/derivative-pricing-a-problem-based-
primer-ambrose-lo/
textbookfull.com
https://textbookfull.com/product/teachers-and-teaching-time-and-the-
creative-tension-kaustuv-roy/
textbookfull.com
https://textbookfull.com/product/memory-and-action-selection-in-human-
machine-interaction-1st-edition-muneo-kitajima/
textbookfull.com
Soil Degradable Bioplastics for a Sustainable Modern
Agriculture 1st Edition Mario Malinconico (Eds.)
https://textbookfull.com/product/soil-degradable-bioplastics-for-a-
sustainable-modern-agriculture-1st-edition-mario-malinconico-eds/
textbookfull.com
Problem Solving in
Data Structures &
Algorithms
Using C#
First Edition
By Hemant Jain
Book Title: Problems Solving in Data Structures & Algorithms Using C#
Book Author: Hemant Jain
Hemant Jain asserts the moral right to be identified as the author of this work.
All rights reserved. No part of this publication may be reproduced, stored in or introduced into a
retrieval system, or transmitted, in any form, or by any means (electrical, mechanical, photocopying,
recording or otherwise) without the prior written permission of the author, except in the case of very
brief quotations embodied in critical reviews and certain other non-commercial uses permitted by
copyright law. Any person who does any unauthorized act in relation to this publication may be liable
to criminal prosecution and civil claims for damages.
ACKNOWLEDGEMENT
The author is very grateful to GOD ALMIGHTY for his grace and blessing.
Deepest gratitude for the help and support of my brother Dr. Sumant Jain. This book would not have
been possible without the support and encouragement he provided.
I would like to express profound gratitude to my guide/ my friend Naveen Kaushik for his invaluable
encouragement, supervision and useful suggestion throughout this book writing work. His support and
continuous guidance enable me to complete my work successfully.
Finally yet importantly, I am thankful to Love Singhal, Anil Berry and Others who helped me directly
or indirectly in completing this book.
Hemant Jain
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book. You can
provide your valuable feedback at www.Amazon.com & www.Flipkart.com.
Error Reporting
Although the author had tried his best to ensure the accuracy of the content of this book, but mistake
do happens. If you find a mistake in this book - may be mistake in the text or the code. We would be
grateful if you report them to us. Your feedbacks will help us in improving the next version of this
book. If you find an error simply, send an email to us at [email protected]. In the error
reporting please, mention the book title in the subject of your message.
To: [email protected]
Subject: Error : <Book Title>
Message: <Description of the Error>
New Problems
If the reader thinks that, a new problem should be added to this book. Then please send that problem
to us.
To: [email protected]
Subject: Problem : <Book Title>
Message: <Description of the Problem>
New Requests
If the reader thinks that, a new topic or some more elaboration need to be added to an existing topic
of this book. Then please send that request to us.
To: [email protected]
Subject: Request : <Book Title>
Message: <Description of the Request>
TABLE OF CONTENTS
TABLE OF CONTENTS
CHAPTER 0: HOW TO USE THIS BOOK
WHAT THIS BOOK IS ABOUT
PREPARATION PLANS
SUMMARY
CHAPTER 1: INTRODUCTION - PROGRAMMING OVERVIEW
INTRODUCTION
FIRST C# PROGRAM
OBJECT
VARIABLE
DATA TYPES
PRIMITIVE/ BASIC DATA TYPES
PARAMETER PASSING, CALL BY VALUE
REFERENCE DATA TYPES
PARAMETER PASSING, CALL BY REFERENCE
KINDS OF VARIABLES
METHODS
ACCESS MODIFIERS
INTERFACE
RELATIONSHIP
GENERAL PROTOTYPE OF A CLASS
ABSTRACT CLASS & METHODS
NESTED CLASS
ENUMS
CONSTANTS
CONDITIONS AND LOOPS
ARRAY
TWO DIMENSIONAL ARRAY
ARRAY INTERVIEW QUESTIONS
CONCEPT OF STACK
SYSTEM STACK AND METHOD CALLS
RECURSIVE FUNCTION
EXERCISES
CHAPTER 2: ALGORITHMS ANALYSIS
INTRODUCTION
ASYMPTOTIC ANALYSIS
BIG-O NOTATION
OMEGA-Ω NOTATION
THETA-Θ NOTATION
COMPLEXITY ANALYSIS OF ALGORITHMS
TIME COMPLEXITY ORDER
DERIVING THE RUNTIME FUNCTION OF AN ALGORITHM
TIME COMPLEXITY EXAMPLES
MASTER THEOREM
MODIFIED MASTER THEOREM
EXERCISE
CHAPTER 3: APPROACH TO SOLVE ALGORITHM DESIGN PROBLEMS
INTRODUCTION
CONSTRAINTS
IDEA GENERATION
COMPLEXITIES
CODING
TESTING
EXAMPLE
SUMMARY
CHAPTER 4: ABSTRACT DATA TYPE & C# COLLECTIONS
ABSTRACT DATA TYPE (ADT)
DATA-STRUCTURE
C# COLLECTION FRAMEWORK
ARRAY
LINKED LIST
STACK
QUEUE
TREES
BINARY TREE
BINARY SEARCH TREES (BST)
PRIORITY QUEUE (HEAP)
HASH-TABLE
CHOOSING THE RIGHT COLLECTION CLASS
DICTIONARY / SYMBOL TABLE
GRAPHS
GRAPH ALGORITHMS
SORTING ALGORITHMS
COUNTING SORT
END NOTE
CHAPTER 5: SEARCHING
INTRODUCTION
WHY SEARCHING?
DIFFERENT SEARCHING ALGORITHMS
LINEAR SEARCH – UNSORTED INPUT
LINEAR SEARCH – SORTED
BINARY SEARCH
STRING SEARCHING ALGORITHMS
HASHING AND SYMBOL TABLES
HOW SORTING IS USEFUL IN SELECTION ALGORITHM?
PROBLEMS IN SEARCHING
EXERCISE
CHAPTER 6: SORTING
INTRODUCTION
TYPE OF SORTING
BUBBLE-SORT
MODIFIED (IMPROVED) BUBBLE-SORT
INSERTION-SORT
SELECTION-SORT
MERGE-SORT
QUICK-SORT
QUICK SELECT
BUCKET SORT
GENERALIZED BUCKET SORT
HEAP-SORT
TREE SORTING
EXTERNAL SORT (EXTERNAL MERGE-SORT)
COMPARISONS OF THE VARIOUS SORTING ALGORITHMS.
SELECTION OF BEST SORTING ALGORITHM
EXERCISE
CHAPTER 7: LINKED LIST
INTRODUCTION
LINKED LIST
TYPES OF LINKED LIST
SINGLY LINKED LIST
DOUBLY LINKED LIST
CIRCULAR LINKED LIST
DOUBLY CIRCULAR LIST
EXERCISE
CHAPTER 8: STACK
INTRODUCTION
THE STACK ABSTRACT DATA TYPE
STACK USING ARRAY
STACK USING ARRAY (GROWING-REDUCING CAPACITY IMPLEMENTATION)
STACK USING LINKED LIST
PROBLEMS IN STACK
PROS AND CONS OF ARRAY AND LINKED LIST IMPLEMENTATION OF STACK.
USES OF STACK
EXERCISE
CHAPTER 9: QUEUE
INTRODUCTION
THE QUEUE ABSTRACT DATA TYPE
QUEUE USING ARRAY
QUEUE USING LINKED LIST
PROBLEMS IN QUEUE
EXERCISE
CHAPTER 10: TREE
INTRODUCTION
TERMINOLOGY IN TREE
BINARY TREE
TYPES OF BINARY TREES
PROBLEMS IN BINARY TREE
BINARY SEARCH TREE (BST)
PROBLEMS IN BINARY SEARCH TREE (BST)
SEGMENT TREE
AVL TREES
RED-BLACK TREE
SPLAY TREE
B-TREE
B+ TREE
B* TREE
EXERCISE
CHAPTER 11: PRIORITY QUEUE
INTRODUCTION
TYPES OF HEAP
HEAP ADT OPERATIONS
OPERATION ON HEAP
HEAP-SORT
PRIORITYQUEUE<> GENERIC HEAP IMPLEMENTATION
USES OF HEAP
PROBLEMS IN HEAP
EXERCISE
CHAPTER 12: HASH-TABLE
INTRODUCTION
HASH-TABLE
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
HASHING WITH OPEN ADDRESSING
HASHING WITH SEPARATE CHAINING
COUNT MAP
PROBLEMS IN HASHING
EXERCISE
CHAPTER 13: GRAPHS
INTRODUCTION
GRAPH REPRESENTATION
ADJACENCY MATRIX
ADJACENCY LIST
GRAPH TRAVERSALS
DEPTH FIRST TRAVERSAL
BREADTH FIRST TRAVERSAL
PROBLEMS IN GRAPH
DIRECTED ACYCLIC GRAPH
TOPOLOGICAL SORT
MINIMUM SPANNING TREES (MST)
SHORTEST PATH ALGORITHMS IN GRAPH
EXERCISE
CHAPTER 14: STRING ALGORITHMS
INTRODUCTION
STRING MATCHING
DICTIONARY / SYMBOL TABLE
PROBLEMS IN STRING
EXERCISE
CHAPTER 15: ALGORITHM DESIGN TECHNIQUES
INTRODUCTION
BRUTE FORCE ALGORITHM
GREEDY ALGORITHM
DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER
DYNAMIC PROGRAMMING
REDUCTION / TRANSFORM-AND-CONQUER
BACKTRACKING
BRANCH-AND-BOUND
A* ALGORITHM
CONCLUSION
CHAPTER 16: BRUTE FORCE ALGORITHM
INTRODUCTION
PROBLEMS IN BRUTE FORCE ALGORITHM
CONCLUSION
CHAPTER 17: GREEDY ALGORITHM
INTRODUCTION
PROBLEMS ON GREEDY ALGORITHM
CHAPTER 18: DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER
INTRODUCTION
GENERAL DIVIDE-AND-CONQUER RECURRENCE
MASTER THEOREM
PROBLEMS ON DIVIDE-AND-CONQUER ALGORITHM
CHAPTER 19: DYNAMIC PROGRAMMING
INTRODUCTION
PROBLEMS ON DYNAMIC PROGRAMMING ALGORITHM
CHAPTER 20: BACKTRACKING AND BRANCH-AND-BOUND
INTRODUCTION
PROBLEMS ON BACKTRACKING ALGORITHM
CHAPTER 21: COMPLEXITY THEORY AND NP COMPLETENESS
INTRODUCTION
DECISION PROBLEM
COMPLEXITY CLASSES
CLASS P PROBLEMS
CLASS NP PROBLEMS
CLASS CO-NP
NP–HARD:
NP–COMPLETE PROBLEMS
REDUCTION
END NOTE
CHAPTER 22: INTERVIEW STRATEGY
INTRODUCTION
RESUME
NONTECHNICAL QUESTIONS
TECHNICAL QUESTIONS
CHAPTER 23: SYSTEM DESIGN
SYSTEM DESIGN
SYSTEM DESIGN PROCESS
SCALABILITY THEORY
DESIGN SIMPLIFIED FACEBOOK
DESIGN A SHORTENING SERVICE LIKE BITLY
STOCK QUERY SERVER
DESIGN A BASIC SEARCH ENGINE DATABASE
DUPLICATE INTEGER IN MILLIONS OF DOCUMENTS
ZOMATO
YOUTUBE
DESIGN IRCTC
ALARM CLOCK
DESIGN FOR ELEVATOR OF A BUILDING
VALET PARKING SYSTEM
OO DESIGN FOR A MCDONALDS SHOP
OBJECT ORIENTED DESIGN FOR A RESTAURANT
OBJECT ORIENTED DESIGN FOR A LIBRARY SYSTEM
SUGGEST A SHORTEST PATH
EXERCISE
APPENDIX
APPENDIX A
INDEX
CHAPTER 0: HOW TO USE THIS BOOK
What this book is about
This book is about usage of data structures and algorithms in computer programming. Data structures
are the ways in which data is arranged in computers memory. Algorithms are set of instructions to
solve some problem by manipulating these data structures.
This book assumes that you are a C# language developer. You are not an expert in C# language, but
you are well familiar with concepts of references, functions, arrays and recursion. At the start of this
book, we will be revising the C# language fundamentals that will be used throughout this book. We
will be looking into some of the problems in arrays and recursion too.
Then in the coming chapter we will be looking into Complexity Analysis. Followed by the various
data structures and their algorithms. Will look into a Linked-List, Stack, Queue, Trees, Heap, Hash-
Table and Graphs. We will also be looking into Sorting, Searching techniques.
We will be looking into algorithm analysis of various algorithm techniques. We will be looking into
Brute-Force algorithms, Greedy algorithms, Divide and Conquer algorithms, Dynamic Programming,
Reduction and Backtracking.
In the end, we will be looking into System Design that will give a systematic approach to solve the
design problems in an Interview.
Preparation Plans
Given the limited time you have before your next interview, it is important to have a solid preparation
plan. The preparation plan depends upon the time and which companies you are planning to target.
Below are the three-preparation plan for 1 Month, 3 Month and 5 Month durations.
This plan should be used when you have a limited time before an interview. These chapters cover
90% of data structures and algorithm interview questions. In this plan since we are reading about the
various ADT and C# collections in chapter 4 so we can use these datatype easily without knowing the
internal details how they are implemented.
Chapter 24 is for system design, you must read this chapter if you are three or more years of
experienced. Anyway, reading this chapter will give the reader a broader perspective of various
designs.
Again, same thing here with system design problems, the more experience you are, the more important
this chapter becomes. However, if you are a fresher from college, then also you should read this
chapter.
It is tradition to discuss a HelloWorld program in the start which will print the phrase “Hello,
World!” to the output screen. So let us start discussing it. This is a small program but it contains many
common features of all the C# programs.