## Print All the Subsets of a Given Set (Power Set)

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, … Read more

## Print All Combinations of subset of size K from Given Array

Objective: Given an array of integers of size N, print all the subsets of size k. (k<=N) Example: Generate all … Read more

## Print All Possible Valid Combinations Of Parenthesis of Given ‘N’

ObjecÂ­tive: Given “n”, generate all valid parenthesis strings of length “2n”.
Example:

```Given n=2

Output:
(())
()()
```

Approach:

## Generate All Strings of n bits.

ObjecÂ­tive: Generate All Strings of n bits, consider A[0..n-1] is an array of size n.

Example :

```n = 3
```

Output

```:
[0, 0, 0]    [1, 0, 0]    [0, 1, 0]    [1, 1, 0]

[0, 0, 1]     [1, 0, 1]     [0, 1, 1]    [1, 1, 1]
```

## Alternate Splitting of a given Linked List

Objective: Given a singly linked list, split it into two linked lists. These linked lists will contain the alternate nodes from the given linked list.

Example:

## Reverse The Doubly Linked List

Objective: Reverse The Doubly Linked List. Example: Approach: Every Node in a doubly-linked list has the next and previous pointer. … Read more

## Print the Bottom View of the Binary Tree.

ObjecÂ­tive: Given a binary tree, print it in Bottom View of it.

What is Bottom View: Bottom view means when you look the tree from the bottom the nodes you will see will be called the bottom view of the tree. See the examÂ­ple below.

as you can see in the example above,8, 4, 9, 5, 3, 7 is the bottom view of the given binary tree.

## Delete X Nodes After Y Nodes In a Linked List

Objective: Given a Linked List and x and y. Delete x number of nodes after y nodes from the start. … Read more

## Merge Sort in a Linked list

Objective: Given a Linked List, Sort it using merge sort.Example: ->9->3->4->2->5->1 Sorted List: ->1->2->3->4->5->9 Approach: Reference : Merge Sort in … Read more

## Construct a binary tree from given Inorder and Level Order Traversal

Objective: – Given an inorder and level order traversal, construct a binary tree from that. Input: Inorder and level order … Read more

## Inorder Predecessor and Successor in Binary Search Tree

Objective: Given a Binary Search Tree, Find predecessor and Successor of a given node.

What is Predecessor and Successor :

When you do the inorder traversal of a binary tree, the neighbors of given node are called Predecessor(the node lies behind of given node) and Successor (the node lies ahead of given node).

Example:

Approach:

## In an Array, find the Smallest Subarray with Sum Greater than the Given Value

Objective: Given an array and an integer, find the smallest subarray whose sum is greater than the given integer.

Examples:

```arrA[] = { 1, 5, 20, 70, 8}
Integer = 97
Output : Min Length = 3 Subarray = [20, 70, 8]

arrA[] = { 1, 10, 3, 40, 18}
Integer = 50
Output : Min Length = 2 Subarray = [40, 18]
```

Approach:

Naive Approach: Use 2 loops. Time Complexity – O(n2).

Better Approach: Time Complexity – O(n)

## Search an Element in a Rotated Sorted Array

Input: Rotated Sorted Array.

What is Rotated Sorted Array.

A sorted array is rotated around some pivot element. See the Example Below, array is rotated after 6.

Approach:

Naive Approach: Do the linear scan and find the element in O(n) time

## Print All The Permutations Of a String

Objective: Given a String, print all the permutations of it.

Input: A String

Output: Print all the permutations of a string

Example:

```Input : abc
```

Output:

``` abc acb bac bca cba cab

```

Approach:

## Find the Maximum Depth OR Height of a Binary Tree

Objective: Given a binary tree, find the height of it

Input: A Binary Tree

Output: Height of a binary tree

Example:

Approach:

Recursion: