Beginning Java Data Structures and Algorithms

Book description

Though your application serves its purpose, it might not be a high performer. Learn techniques to accurately predict code efficiency, easily dismiss inefficient solutions, and improve the performance of your application.

Key Features

  • Explains in detail different algorithms and data structures with sample problems and Java implementations where appropriate
  • Includes interesting tips and tricks that enable you to efficiently use algorithms and data structures
  • Covers over 20 topics using 15 practical activities and exercises

Book Description

Learning about data structures and algorithms gives you a better insight on how to solve common programming problems. Most of the problems faced everyday by programmers have been solved, tried, and tested. By knowing how these solutions work, you can ensure that you choose the right tool when you face these problems.

This book teaches you tools that you can use to build efficient applications. It starts with an introduction to algorithms and big O notation, later explains bubble, merge, quicksort, and other popular programming patterns. You'll also learn about data structures such as binary trees, hash tables, and graphs. The book progresses to advanced concepts, such as algorithm design paradigms and graph theory. By the end of the book, you will know how to correctly implement common algorithms and data structures within your applications.

What you will learn

  • Understand some of the fundamental concepts behind key algorithms
  • Express space and time complexities using Big O notation.
  • Correctly implement classic sorting algorithms such as merge and quicksort
  • Correctly implement basic and complex data structures
  • Learn about different algorithm design paradigms, such as greedy, divide and conquer, and dynamic programming
  • Apply powerful string matching techniques and optimize your application logic
  • Master graph representations and learn about different graph algorithms

Who this book is for

If you want to better understand common data structures and algorithms by following code examples in Java and improve your application efficiency, then this is the book for you. It helps to have basic knowledge of Java, mathematics and object-oriented programming techniques.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Beginning Java Data Structures and Algorithms
  3. Packt Upsell
    1. Why Subscribe?
  4. Contributors
    1. About the Author
    2. Packt Is Searching for Authors like You
  5. Preface
    1. Who This Book Is For
    2. What This Book Covers
    3. To Get the Most out of This Book
      1. Download the Example Code Files
      2. Download the Color Images
      3. Conventions Used
    4. Get in Touch
      1. Reviews
  6. Algorithms and Complexities
    1. Developing Our First Algorithm
      1. Algorithm for Converting Binary Numbers to Decimal
        1. Activity: Writing an Algorithm to Convert Numbers from Octal To Decimal
    2. Measuring Algorithmic Complexity with Big O Notation
      1. Complexity Example
      2. Understanding Complexity
        1. Activity: Developing a Timing Table Using the Exponential Algorithm
      3. Complexity Notation
        1. Identifying the Best and Worst Performance of an Algorithm While Checking for Duplicates in an Array
        2. Activity: Converting Expressions to Big O Notations
    3. Identifying Algorithms with Different Complexities
      1. Linear Complexity
      2. Quadratic Complexity
      3. Logarithmic Complexity
      4. Exponential Complexity
      5. Constant Complexity
        1. Activity: Developing a Faster Intersection Algorithm
    4. Summary
  7. Sorting Algorithms and Fundamental Data Structures
    1. Introducing Bubble Sorting
      1. Understanding Bubble Sorting
        1. Implementing Bubble Sort
      2. Improving Bubble Sorting
        1. Implementing Bubble Sort Improvement
        2. Activity: Implementing Selection Sort in Java
    2. Understanding Quick Sort
      1. Understanding Recursion
        1. Implementing Binary Search Recursively
      2. Quicksort Partitioning
        1. Activity: Understanding the Partitioning Method
      3. Putting It All Together
        1. Implementing Quick Sort
    3. Using Merge Sort
      1. Dividing the Problem
        1. Implementing Merge Sort
      2. Merging the Problem
        1. Activity: Implementing Merge Sort in Java
    4. Getting Started with Fundamental Data Structures
      1. Introducing Data Structures
      2. Linked Lists Structure
        1. Converting the Linked List to a Doubly Linked List Structure 
      3. Linked Lists Operations
        1. Activity: Traversing the Linked List
      4. Queues
        1. Adding and Deleting the Elements from the Queue
      5. Stacks
        1. Reversing a String
      6. Modeling Stacks and Queues Using Arrays
        1. Safe Enqueuing in an Array
        2. Activity: Evaluating the Postfix Expression
    5. Summary
  8. Hash Tables and Binary Search Trees
    1. Introducing Hash Tables
      1. Understanding Hash Tables
      2. Dealing with Collisions with Chaining
      3. Dealing with Collisions with Open Addressing
        1. Carrying out the Linear Probing Search Operation
        2. Remainder and Multiplication Hash Functions
        3. Implementing the Multiplication Method for a Hash Table
      4. Universal Hashing
        1. Activity: Implementing Open Addressing
    2. Getting Started with Binary Search Trees
      1. Binary Tree Structure
      2. Binary Search Tree Operations
        1. Searching for a Minimum Key in a Binary Tree
      3. Traversing a Binary Search Tree
        1. Activity: Implementing BFS in Java
      4. Balanced Binary Search Trees
        1. Applying Right Tree Rotation
        2. Activity: Retrieving the Successor of an Element When the Tree is Traversed in Inorder
    3. Summary
  9. Algorithm Design Paradigms
    1. Introducing Greedy Algorithms
      1. The Activity Selection Problem
      2. Solving the Activity Selection Problem
      3. Ingredients of a Greedy Algorithm
        1. Optimal Substructure Property
        2. Greedy Choice Property
      4. Huffman Coding
        1. Building a Huffman Code
        2. Developing an Algorithm to Generate Code Words Using Huffman Coding
      5. Activity: Implementing a Greedy Algorithm to Compute Egyptian Fractions
    2. Getting Started with Divide and Conquer Algorithms
      1. The Divide and Conquer Approach
      2. The Master Method
      3. The Closest Pair of Points Problem
      4. Activity: Solving the Maximum Subarray Problem
    3. Understanding Dynamic Programming
      1. Elements of a Dynamic Programming Problem
        1. Optimal Substructure
        2. Overlapping Subproblems
      2. 0-1 Knapsack
        1. Solving the 0-1 Knapsack Problem Using Recursion
      3. Longest Common Subsequence
      4. Activity: The Coin Change Problem
    4. Summary
  10. String Matching Algorithms
    1. Naive Search Algorithm
      1. Implementing Naive Search
        1. Developing the String Matching Algorithm in Java
      2. Rationalization of the Naive Search Algorithm
    2. Getting Started with the Boyer-Moore String Searching Algorithm
      1. The Bad Character Rule
        1. Activity: Implementing the Bad Character Rule
      2. The Good Suffix Rule
      3. Application of the Boyer-Moore Algorithm
        1. Implementing the Boyer-Moore Algorithm 
    3. Introducing Other String Matching Algorithms
      1. Rabin-Karp
        1. Applying the Rabin-Karp Algorithm
      2. Knuth–Morris–Pratt
      3. Aho–Corasick
    4. Summary
  11. Graphs, Prime Numbers, and Complexity Classes
    1. Representing Graphs
      1. Adjacency List Representation
        1. Writing a Java Code to Add Weights to the Directed Graph
      2. Adjacency Matrix Representation
        1. Activity: Building the Adjacency Matrix Representation of a Weighted Undirected Graph
    2. Traversing a Graph
      1. Breadth-First Search
      2. Depth-First Search
      3. Cycle Detection
        1. Activity: Using BFS to Find the Shortest Path Out of a Maze
    3. Calculating Shortest Paths
      1. Single Source Shortest Path: Dijkstra's Algorithm
      2. All Pairs Shortest Paths: Floyd-Warshall Algorithm
        1. Activity: Improving Floyd-Warshall's Algorithm to Reconstruct the Shortest Path
    4. Prime Numbers in Algorithms
      1. Sieve of Eratosthenes
      2. Prime Factorization
        1. Activity: Implementing the Sieve of Eratosthenes
    5. Other Concepts in Graphs
      1. Minimum Spanning Trees
      2. A* Search
      3. Maximum Flow
    6. Understanding Complexity Classes of Problems
    7. Summary
  12. Other Books You May Enjoy
    1. Leave a Review - Let Other Readers Know What You Think

Product information

  • Title: Beginning Java Data Structures and Algorithms
  • Author(s): James Cutajar
  • Release date: July 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789537178