Generate power set of a given set

Given a set S, generate all subsets of it i.e., find power set of set S. A power set of any set S is the set of all subsets of S, including the empty set and S itself.   For example, if S is the set {x, y, z}, then the subsets of S are: …

Recursive Program to Calculate Factorial of a Number

Write a recursive C/C++ and java program to calculate factorial of a given positive number.   The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. It is denoted by n!. There are n! different ways to arrange n distinct objects into a sequence.

Determine if a given string is palindrome or not

Write a program to determine if a given string is palindrome or not. A palindromic string is a string that remains the same when its characters are reversed. Like “ABCBA”, for example, it is “symmetrical”.

Disjoint-Set Data Structure (Union Find Algorithm)

Explain the working of disjoint-set data structure and efficiently implement it.   Problem: We have some number of items. We are allowed to merge any two items to consider them equal. At any point, we are allowed to ask whether two items are considered equal or not.

Depth First Search (DFS) | Iterative & Recursive Implementation

Depth first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking.