## Front and Back Search in an Array

Objective: Given an unsorted array of numbers and a number ‘x’, write a java program to search the number ‘x’ in the array and return its index else return -1. Example: Int [] a...

@tutorialhorizon

Objective: Given an unsorted array of numbers and a number ‘x’, write a java program to search the number ‘x’ in the array and return its index else return -1. Example: Int [] a...

Objective: Given an array of integers which contains duplicates as well. Write a program to print all unique elements in the array. This problem is also referred as print all distinct elements in the...

Objective: Given an array of integers A[],find no of reverse pairs means no of (i, j) pairs where i < j and A[i]>A[j]. Example: A[] = {10, 3, 4, 2, 5, 7, 9, 11}...

Objective: Given an array of integers, write an algorithm to find the first two largest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 1, 10}; Output: 10,...

Objective: Given an array of integers, write a java program to find the sum of all elements Example: Input [] = {20, 30, 40, 10, 5, 2, 60, 73} Output: 240 Approach: Do a...

Objective: Given an array of integers, write a program to rotate the array in cyclic manner by one. Example: Int a [] = {1, 2, 3, 4, 5} Output: {2, 3, 4, 5, 1}...

What is Heap Sort?? Heap sort is comparison based sorting algorithm. Heap sort is considered as improved selection sort, it divides the input into sorted and unsorted region. The improvement from selection sort is...

Objective: Given an array of integers A[] which is sorted in two parts (both parts are individually sorted), find no of reverse pairs means no of (i, j) pairs where i belongs to the...

What is Stack?? Stack is an abstract data type (ADT) and very useful in programming. In computer science, a stack is an abstract data type that serves as a collection of elements. Majorly all the operations are done at only one...

In this article we will discuss about what is bubble sort, why it is considered as one of the simplest sorting algorithm, what its complexity, how we can improve the bubble sort algorithm. What...

Objective: Given an array [] of n elements and a element ‘x’, write a program to search an element ‘x’ in the array. Example: Input [] = {20, 30, 40, 10, 5, 2, 60,...

Objective: Given an array of numbers, write an algorithm to find the maximum difference between any two elements in the array. Example: Int [] a = {2, 8, 1, 6, 10, 4} Output: Maximum...

Objective – Given a snake and ladder game, write a function that returns the minimum number of jumps to take top or destination position. You can assume the dice you throw results in always...

Objective: Given an array of positive integers and integer ‘K’. Write an algorithm to count all the possible sub arrays where product of all the elements in the sub array is less than k. Example:...

Objective: Given an array and integer k, write an algorithm to find the maximum element in each subarray of size k. Example: int [] nums = { 1, 2, 3, 2, 4, 1, 5,...

%d bloggers like this: