Last Friday afternoon I stopped by to donate blood to the Red Cross. I do this twice a year. As usual, I made an appointment. Earlier that day filled the RapidPass, and had a copy of the ticket in my cell phone. The staff at the blood collection site was running behind. After over an hour wait I was called. It took a while to get the process started. The actual donation took no more than 10 minutes. I will be back on fall later this year. Hope the entire process speeds up :o) Continue reading “Connected Cells in a Grid – Follow Up”
Tag: Algorithms fourth edition by Robert Sedgewick and Kevin Wayne
Max Priority Queue
A priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue.
While priority queues are often implemented with heaps, they are conceptually distinct from heaps. A priority queue is an abstract concept like “a list” or “a map”; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods such as an unordered array. Continue reading “Max Priority Queue”
Insertion Sort
Moving along in the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne, I experimented with the Insertion sort algorithm. Visit the https://en.wikipedia.org/wiki/Insertion_sort web site to view an animation of the algorithm. As you can see, it resembles a person arranging playing cards for a game of bridge.
The way the authors described the API to the sorting algorithms allow this one to be quite elegant and compact.
Continue reading “Insertion Sort”
Union-Find and Adapter Design Pattern
Earlier today I finished reading chapter 1.5 Case Study: Union-Find in the Algorithms Fourth Edition book by Robert Sedgewick and Kevin Wayne published by Addison-Wesley. Not sure if the authors recommend reading the chapters in order because they tend to use previous material. Last week I was browsing the table of contents and decided to read chapter 4.1. It mentions contents of chapter 1.5. From now on, I will read the book in order ;o)
It is always good to work on a single topic. I am breaking that rule to some extent. I will cover two very similar implementations of the Union-Find algorithm from chapter 1.5. It does give an introductory flavor for what is to come in chapter 4.1 Undirected Graphs. Continue reading “Union-Find and Adapter Design Pattern”
Generics Implementation
This blog entry is based on the example on page 141 of Algorithms fourth edition by Robert Sedgewick and Kevin Wayne. I am reading the book as a refresher and learning experience on computer algorithms. Initially what called my attention was the statement that it contains 50 algorithms that every programmer should know. I want to make sure I have a good handle on those algorithms. After reading the first few chapters which have not cover the algorithms yet, I feel that the way the ground work is presented is very educational, direct to the point and simple to follow. I always like simplicity in code and documentation. Elegant code is very hard to find and write. This book seems that it should help readers achieve such goal. Continue reading “Generics Implementation”
Generics
This blog entry was motivated by the description and implementation of Java Generics in the Algorithms fourth edition book by Robert Sedgewick and Kevin Wayne. The code in this post is based on their implementation. I did some minor changes.
Collections, Generics and Iterators are important concepts in object oriented programming languages. It is central to understand the reasons for them and the associated ideas. If you are interested (and you should if you work with object oriented languages) get a copy of the book and take a look at pages 132 – 141. Continue reading “Generics”
Algorithms – Chapter 1 and 2
I typically write one blog entry per book I read. In this blog, Algorithms Fourth Edition by Robert Sedgewick and Kevin Wayne will be split in comments per one or more chapters.
A few weeks ago I decided to read Algorithms and go over most of the exercises. I wish I would have enough time to tackle them all. This morning I finished reading the first two chapters. So far, so good. Continue reading “Algorithms – Chapter 1 and 2”
Book and Hub
My wife and I spent the past four days visiting my son in Indiana. It is always nice to get away from the routine to think and reflect on things. That said; I am happy returning home and back on my routine.
Over the long weekend I received some items I ordered from Amazon.com. I received an AmazonBasics 7 Port USB 2.0 Hub which I have not opened yet. Will open the box and connect it to my Raspberry Pi next weekend. On a separate package I should also have received a SD card with the Raspberry OS. It must be with the mail that my neighbor collected while we were out of town. My wife will check with them later today. Continue reading “Book and Hub”