Data Structures

C++ Pre-Order, In-Order, Post-Order Traversal of Binary Search Trees

Pre-Order, In-Order, Post-Order traversal of Binary Search Trees (BST) This article explains the depth first search (DFS) traversal methods for binary search search trees. Pre-Order, In-Order and Post-Order are depth first search traversal methods for binary search trees. Starting at the root of binary tree the order in which the nodes are visited define these …

C++ Heaps

What is a heap data structure? How to implement in C++? This article explains the heap data structure and provides a sample implementation using C++. Heap is a binary tree that stores priorities (or priority-element pairs) at the nodes. It has the following properties: All levels except last level are full. Last level is left …

Binary Search Trees in C++

What is binary search trees? How to implement in C++? This article explains the concept of binary search trees (BST) and provides a sample implementation in C++. Binary Search Tree (BST) is a binary tree (has atmost 2 children).  It is also referred as sorted/ ordered binary tree. BST has the following properties. (notes from …

C++ Deque

What is a deque? How to implement deques using C++? Deque is an abbreviation for double-ended queue. It is a data structure in which the elements can only be added or removed from front and back of the queue. A typical deque implementation support the following operations. Insert at front an element, insert at back … C++ Level Order Traversal of Binary Search Trees

What is level-order traversal/ Breadth First (BFS) traversal of binary search tree? This article explains level-order traversal/ Breadth First (BFS) traversal of binary search tree with a sample implementation in C++. Level order traversal is also referred as Breadth First (BFS)/ Width First tree traversals. In simple terms every node of a level is visited before going to the … C++ Singly Linked Lists

What is a singly linked list? How to implement singly linked lists in C++? This article explains the concept of singly linked list data structure and provides a sample implementation in C++. Linked lists are building blocks for many other data structures like stacks and queues. Linked lists are a sequence of nodes containing data … C++ Queues

What is a queue? How to implement queues using C++? This article explains the queue data structure and demonstrates sample implementation using C++. Queue is a first-in, first-out (FIFO) data structure. i.e. the element added first to the queue will be the one to be removed first. Elements are always added to the back of the queue … C++ Stacks

What is a stack? How to implement stacks using C++? This article explains about the basics of a stack data structure and demonstrates with simple examples implementation of stack using arrays and linked lists. Stack is a last-in, first-out (LIFO) data structure. i.e. the element added last to the stack will be the one to …