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

Given n=2 Output: (()) ()()

**Approach:**

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

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

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

Given n=2 Output: (()) ()()

**Approach:**

**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]

**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**:

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

**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.*

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

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

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

**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:**

**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(n^{2}).

**Better Approach: Time Complexity – O(n)**

**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

**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:**

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

**Input:** A Binary Tree

**Output: **Height of a binary tree

**Example: **

**Approach:**** Recursion:**