Find the nth element from the end of the node in LinkedList

Supposed that there is a linked list with this content:

  • 5: Rafsan Adam
  • 4: Andre
  • 3: Cindy Patricia
  • 2: Stephen D. Burd
  • 1: Nyoman D. Nata
  • 0: Freddy Aries

When I enter ‘3’ it will return the 3rd element from the end of the list, counted from 0, it returns “Cindy Patricia” which key itself is 3. The thing is, we can’t use key to determine the position as the key may not be integer.

Continue reading

Removing Duplicate Node From A Linked List

This is actually a question from At first, I thought this question is easy, but later it seems it is harder than what I think. Sometimes, when you think something is easy, it is not that really easy, especially talking in computer programming languages: a world that is not real.

So. I already try to solve this last night, but I can’t. However, it seems that my energy is not wasted. After breaking for a while from ‘memorizing’ (I hate it) for software project management, I try to do the question again and I solved it!

Continue reading

Plain English Explanation of Binary Tree with Java Code

Binary Tree is one of the most amazing data structure some one has come up with which I have a chance to learn it right now. Actually this was the most amazing of data structure I had to know. Guys, I really regret that during high school I think it was never be possible to learn linked list, hell, linked list is so easy :D. Okay, let’s learn binary tree!

Continue reading

Java Complete Application for Singly Linked List

Today’s tutorial class, I got a question for the lecturer to implement a singly linked list into a complete, working example of Java command line program. The whole class get 2 hours for programming this, and I completely finished within the first one hour. In my opinion, this program is not so challenging, maybe a doubly linked list would make this program a bit more challenging.

Continue reading

Implementation of Stack for Checking Incorrect Braces Used to Validate HTML Source Code in Java

HTML is a page-format language which is used to format how an internet browser should deliver a content to the user. HTML (and CSS) is not really a programming language. However, HTML is important here for illustration of how stack can be used to detect mismatch opening-closing braces.

Continue reading

About Stack, a Computer Abstract Data Type (ADT).

Stack is one of computer abstract data type, that usually will be learn by programmer during data structures class. Stack is a very simple data structure. Stack is really a ‘stack’ in a real world. Imagine a stack of book, you put the book a, book b, and then book c. The most top in the stack is book c (which is the last inserted), and the most at the bottom is book a (which is the least inserted, the most-senior).

Continue reading

Simple Linked List implementation in Java

Have you ever wondered what is Linked List? Linked List is a dynamic abstract data type comprised of node(s). By meaning of dynamic, the size of Linked List can grow and shrink. There are many types of Linked List, however, the most simple one is Singly Linked List. One you mastered how to create singly linked list, the other type of linked list (doubly linked list and circular linked list) is just a matter of expansion.

Continue reading