## Magic Index – Find Index In Sorted Array Such That A[i] = i.

Objective: Given a sorted array of distinct integers, Find the Magic index or Fixed point in the array. Magic Index or Fixed Point: Magic index or a Fixed point in an array is an...

@tutorialhorizon

Objective: Given a sorted array of distinct integers, Find the Magic index or Fixed point in the array. Magic Index or Fixed Point: Magic index or a Fixed point in an array is an...

Objective: Write an algorithm to Print All the Well Ordered Permutations of a Given String. What is Well Ordered String: When all the alphabets in a string occur in the increasing order irrespective of...

Objective: Given an integer array A[1..n], find an instance of i,j,k where 0 < i < j < k <= n and A[i] < A[j] < A[k]. Example : int arrA[] = { 10,...

Objective: Given an array of integers such that first level will print all the elements in the array and from then at each level number of elements will be one less than the previous...

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S...

Objective: Given an array of integers of size N, print all the subsets of size k. (k<=N) Example: Generate all subsets of a fixed size k of a given set [1,2,3…n]. e.g, if n=5...

Objective: In a Stack, keep track of maximum value in it. It might be the top element in the stack but once it is poped out, the maximum value should be from the rest...

Objective: – Given “n”, generate all valid parenthesis strings of length “2n”. Example: Given n=2 Output: (()) ()() Approach:

Counting Sort is an sorting algorithm, which sorts the integers( or Objects) given in a specific range. Algorithm: Time Complexity O(n) Take two arrays, Count[] and Result[] and given array is input[]. Count[] will...

Objective: – Given an Integer array. Array contains duplicates of all the numbers in array except one number . Find that number. Example : int [] A = { 2,1,3,5,5,3,2,1,6,7,7,8,8}; Output : Missing duplicate...

Objective: – Given three integers, sort them without using if condition. Appraoch: Say 3 integers are, a, b, c. Find the maximum of a, b, c using Max() function. multiply all integers by -1....

Objective: We know that Queue is FIFO (First-in-First-Out) and Stack is LIFO ( Last-in-First-Out). Here our objective is to implement queue using stacks. Approach: Take 2 Stacks, stack1 and stack2. stack1 will be used...

Objective: – Given a Binary Search Tree, Do the Depth First Search/Traversal . Appraoch: Approach is quite simple, use Stack. First add the add root to the Stack. Pop out an element from Stack...

Objective: Given an array of unsorted numbers, check if it contains all elements of some given range. Examples: int[] arrA = { 11, 17, 13, 19, 15, 16, 12, 14 }; Range : 12-15...

Objective: Given a array of unsorted numbers, check if all the numbers in the array are consecutive numbers. Examples: int [] arrA = {21,24,22,26,23,25}; – True (All the integers are consecutive from 21 to...

%d bloggers like this: