Category Archives: Data Structures

Balanced Brackets Problem in Data Structures in C++

Write a program to validate whether the brackets in the given input string are balanced or not. Examples: Input : {[()]} Output : Valid Input :{{(}}[] Output : Invalid Explanation: This problem is a very common application of stacks in data structures. An opening bracket may be ‘{‘,'[‘,'(‘ and their corresponding closing brackets are ‘}’,’]’,’)’. The brackets are… Read More »

Importance of Data Structures

When you start to research IT and CS and you find out everything you want to do is based on Data Structure and Algorithm so what is Data Structure? Data Structure is a way of organizing data in a computer so that it can be used. A computer program performs various tasks like storing data, retrieving data, and… Read More »

Tricky C++ programs

Programming has never been easier. Even though you may have mastered a particular programming language, there might still be some concepts that may make you dizzy on reading it. This article contains some set of tricky questions which may make you go dizzy. 1. Take a look at this terminated int main (); What will this program do?… Read More »

Dangerous String

A string contains ‘0’ and ‘1’.You have to find out whether the string is dangerous or not. The string will be dangerous in the following two conditions. There are at least 7 continuous occurrences of ‘1’. There are at least 7 continuous occurrences of ‘0’. Examples: Input : 1000000001 Output : YES Explanation: It has more than 7… Read More »

k-th distinct (non-repeating) element in an Array

Given an integer array arr[] a non negative integer k, print k-th distinct element in an array. The given array may contain duplicates and the output should print k-th distinct element among all elements in the array. If k is more than number of distinct elements, print -1. Examples : Input : arr[] = {1, 2, 1, 3,… Read More »

Why to Learn Data Structure and Algorithms ?

Programming is all about data structures and algorithms. Data structures are used to hold data while algorithms are used to solve the problem using that data. Data structures and algorithms (DSA) goes through solutions to standard problems in detail and gives you an insight into how efficient it is to use each one of them. It also teaches… Read More »

Advantages of Linked List over Dynamic Arrays

Dynamix array is also known as Vector, Dynamic array is an array that resizes itself up or down depending on the number of content. Linked lists have both advantages and disadvantages. The advantage of linked lists is that they can be expanded in constant time. While creating dynamic arrays, we must allocate memory for a certain number of… Read More »