-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathJava-flipkart
More file actions
326 lines (311 loc) · 14.7 KB
/
Java-flipkart
File metadata and controls
326 lines (311 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
Programming Java
Getting Started
Base Types
Classes and Objects
Creating and Using Objects
Defining a Class
Strings, Wrappers, Arrays, and Enum Types
Expressions
Literals
Operators
Type Conversions
Control Flow
The If and Switch Statements
Loops
Explicit Control-Flow Statements
Simple Input and Output
An Example Program
Packages and Imports
Software Development
Design
Pseudocode
Coding
Documentation and Style
Testing and Debugging
Exercises
Object-Oriented Design
Goals, Principles, and Patterns
Object-Oriented Design Goals
Object-Oriented Design Principles
Design Patterns
Inheritance
Extending the CreditCard Class
Polymorphism and Dynamic Dispatch
Inheritance Hierarchies
Interfaces and Abstract Classes
Interfaces in Java
Multiple Inheritance for Interfaces
Abstract Classes
Exceptions
Catching Exceptions
Throwing Exceptions
Java’s Exception Hierarchy
Casting and Generics
Casting
Generics
Nested Classes
Exercises
Design Problem: Classes for CLI based Multiuser shopping E-Kart
Fundamental Data Structures
Using Arrays
Storing Game Entries in an Array
Sorting an Array
javautil Methods for Arrays and Random Numbers
Simple Cryptography with Character Arrays
Two-Dimensional Arrays and Positional Games
Singly Linked Lists
Implementing a Singly Linked List Class
Circularly Linked Lists
Round-Robin Scheduling
Designing and Implementing a Circularly Linked List
Doubly Linked Lists
Implementing a Doubly Linked List Class
Equivalence Testing
Equivalence Testing with Arrays
Equivalence Testing with Linked Lists
Cloning Data Structures
Cloning Arrays
Cloning Linked Lists
Exercises
Design Problem: Storing items in E-Kart in an Array. Keeping storage functionality modular
for further enhancements.
Algorithm Analysis
Experimental Studies
Moving Beyond Experimental Analysis
The Seven Functions Used in This Book
Comparing Growth Rates
Asymptotic Analysis
The “Big-Oh” Notation
Comparative Analysis
Examples of Algorithm Analysis
Simple Justification Techniques
By Example
The “Contra” Attack
Induction and Loop Invariants
Exercises
Design Problem: Understaing current complexity of Shopping E-Kart
Recursion - Fundamental of designing next level of data structures
Illustrative Examples
The Factorial Function
Drawing an English Ruler
Binary Search
File Systems
Analyzing Recursive Algorithms
Further Examples of Recursion
Linear Recursion
Binary Recursion
Multiple Recursion
Designing Recursive Algorithms
Recursion Run Amok
Maximum Recursive Depth in Java
Eliminating Tail Recursion
Exercises
Stacks, Queues, and Deques
Stacks
The Stack Abstract Data Type
A Simple Array-Based Stack Implementation
Implementing a Stack with a Singly Linked List
Reversing an Array Using a Stack
Matching Parentheses and HTML Tags
Queues
The Queue Abstract Data Type
Array-Based Queue Implementation
Implementing a Queue with a Singly Linked List
A Circular Queue
Double-Ended Queues
The Deque Abstract Data Type
Implementing a Deque
Deques in the Java Collections Framework
Exercises
Design Problem: Maintaining priority queue of unavailable items. Sending notification to user when
item is available to users based on priority
List and Iterator ADTs
The List ADT
Array Lists
Dynamic Arrays
Implementing a Dynamic Array
Amortized Analysis of Dynamic Arrays
Java’s StringBuilder class
Positional Lists
Positions
The Positional List Abstract Data Type
Doubly Linked List Implementation
Iterators
The Iterable Interface and Java’s For-Each Loop
Implementing Iterators
The Java Collections Framework
List Iterators in Java
Comparison to Our Positional List ADT
List-Based Algorithms in the Java Collections Framework
Sorting a Positional List
Case Study: Maintaining Access Frequencies
Using a Sorted List
Using a List with the Move-to-Front Heuristic
Exercises
Design Problem: Changing storage functionality to list data structures & realizing benefits over array
Trees
General Trees
Tree Definitions and Properties
The Tree Abstract Data Type
Computing Depth and Height
Binary Trees
The Binary Tree Abstract Data Type
Properties of Binary Trees
Implementing Trees
Linked Structure for Binary Trees
Array-Based Representation of a Binary Tree
Linked Structure for General Trees
Tree Traversal Algorithms
Preorder and Postorder Traversals of General Trees
Breadth-First Tree Traversal
Inorder Traversal of a Binary Tree
Implementing Tree Traversals in Java
Applications of Tree Traversals
Euler Tours
Exercises
Design Problem: Display all items in alphabetical order, increasing prices, exepected time of delivary
Priority Queues
The Priority Queue Abstract Data Type
Priorities
The Priority Queue ADT
Implementing a Priority Queue
The Entry Composite
Comparing Keys with Total Orders
The AbstractPriorityQueue Base Class
Implementing a Priority Queue with an Unsorted List
Implementing a Priority Queue with a Sorted List
Heaps
The Heap Data Structure
Implementing a Priority Queue with a Heap
Analysis of a Heap-Based Priority Queue
Bottom-Up Heap Construction ⋆
Using the javautilPriorityQueue Class
Sorting with a Priority Queue
Selection-Sort and Insertion-Sort
Heap-Sort
Adaptable Priority Queues
Location-Aware Entries
Implementing an Adaptable Priority Queue
Exercises
Maps, Hash Tables, and Skip Lists
Maps
The Map ADT
Application: Counting Word Frequencies
An AbstractMap Base Class
A Simple Unsorted Map Implementation
Hash Tables
Hash Functions
Collision-Handling Schemes
Load Factors, Rehashing, and Efficiency
Java Hash Table Implementation
Sorted Maps
Sorted Search Tables
Two Applications of Sorted Maps
Skip Lists
Search and Update Operations in a Skip List
Probabilistic Analysis of Skip Lists ⋆
Sets, Multisets, and Multimaps
The Set ADT
The Multiset ADT
The Multimap ADT
Exercises
Design Problems: Improvising current solution with Maps & check the results.
Search Trees
Binary Search Trees
Searching Within a Binary Search Tree
Insertions and Deletions
Java Implementation
Performance of a Binary Search Tree
Balanced Search Trees
Java Framework for Balancing Search Trees
AVL Trees
Update Operations
Java Implementation
Splay Trees
Splaying
When to Splay
Java Implementation
Amortized Analysis of Splaying ⋆
(,) Trees
Multiway Search Trees
(,)-Tree Operations
Red-Black Trees
Red-Black Tree Operations
Java Implementation
Exercises
Sorting and Selection
Merge-Sort
Divide-and-Conquer
Array-Based Implementation of Merge-Sort
The Running Time of Merge-Sort
Merge-Sort and Recurrence Equations ⋆
Alternative Implementations of Merge-Sort
Quick-Sort
Randomized Quick-Sort
Additional Optimizations for Quick-Sort
Studying Sorting through an Algorithmic Lens
Lower Bound for Sorting
Linear-Time Sorting: Bucket-Sort and Radix-Sort
Comparing Sorting Algorithms
Selection
Prune-and-Search
Randomized Quick-Select
Analyzing Randomized Quick-Select
Exercises
Text Processing
Abundance of Digitized Text
Notations for Character Strings
Pattern-Matching Algorithms
Brute Force
The Boyer-Moore Algorithm
The Knuth-Morris-Pratt Algorithm
Tries
Standard Tries
Compressed Tries
Suffix Tries
Search Engine Indexing
Text Compression and the Greedy Method
The Huffman Coding Algorithm
The Greedy Method
Dynamic Programming
Matrix Chain-Product
DNA and Text Sequence Alignment
Exercises
Graph Algorithms
Graphs
The Graph ADT
Data Structures for Graphs
Edge List Structure
Adjacency List Structure
Adjacency Map Structure
Adjacency Matrix Structure
Java Implementation
Graph Traversals
Depth-First Search
DFS Implementation and Extensions
Breadth-First Search
Transitive Closure
Directed Acyclic Graphs
Topological Ordering
Shortest Paths
Weighted Graphs
Dijkstra’s Algorithm
Minimum Spanning Trees
Prim-Jarn´ık Algorithm
Kruskal’s Algorithm
Disjoint Partitions and Union-Find Structures
Exercises
Memory Management and B-Trees
Memory Management
Stacks in the Java Virtual Machine
Allocating Space in the Memory Heap
Garbage Collection
Memory Hierarchies and Caching
Memory Systems
Caching Strategies
External Searching and B-Trees
(a,b) Trees
B-Trees
External-Memory Sorting
Multiway Merging
Exercises