In this tutorial, we’ll be discussing what’s Level Order Traversal. Also, we’ll be printing each level of the tree. We’ll use the two major approaches – Recursive and Iterative and see what’s the difference in time complexities between them. Level Order Traversal Level Order traversal is also known as Breadth-First Traversal since it traverses all […]
Data Structure and Algorithms are the building blocks of computer programming. A well-defined data structure helps us in keeping our data organized. Some of the commonly used data structures are List, Queue, Stack, Tree etc.
The algorithms provide different ways to achieve a task on these data structures. Some of the common algorithms are in the area of sorting and searching elements in the data structure.
In this tutorial, we’ll be discussing a very popular algorithm which is used to detect whether a LinkedList has loops. It’s called Floyd’s Cycle-Finding Algorithm. LinkedList Loop Detection A loop exists in a LinkedList when no NULL is reached as we traverse throughout the LinkedList. So in order to detect whether a LinkedList has a […]
In this tutorial, we’ll be discussing Binary Trees. We’ll see how to calculate the height of a tree data structure recursively as well as iteratively. Binary Trees Binary Trees are a data structure in which data is stored in a hierarchical manner rather than linear (as it is done in LinkedList and Arrays). A Binary […]
Reversing a Linked List is an interesting problem in data structure and algorithms. In this tutorial, we’ll be discussing the various algorithms to reverse a Linked List and then implement them using Java. Reverse a Linked List LinkedList is a data structure which stores the data in a linear way. Though not in a contiguous […]