# Tagged: Beginner

## Find the roots of Quadratic Equation – Java Program

Quadratic equation is in the form = ax2 + bx + c Discriminant (d) = b2 – 4ac Then roots are calculates using the equations below Root_1 =  (-b + √d)/2a Root_2 =  (-b...

## Given two strings validate the output string

Objective: Given two input strings and one output strings, validate if output string contains all the characters from both the input strings. Example: Input1 = “boy”, Input2 = “girl”, output = “gboilry” Result =...

## Find Largest and Smallest word in a given String

Objective: Given a String, write a program to find largest and smallest word in it. Example: Input String: test Smallest Word: test Largest Word: test —————— Input String: This problem is solved at Algorithms...

## Find two smallest elements in a given array

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

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

## Print all Unique elements in a given array

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

## Multiply with power of 2 without using pow() or * operator

Objective: Given a number n and k, Calculate n * k2 without using pow() or *operator. Example: N = 3, k = 4 N*k2 = 48 Approach: Bit Manipulation Left shift the number N...

## Find first two largest elements in a given array

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

## Calculate Logn base r – Java Implementation

Objective: Given a number n and r, write a program to calculate Logrn Example: N = 32, r =2 Log232= 5 N = 64, r = 4 Log464= 3 Approach: Without using built-In function-...

## Java Program to find Sum the elements of an Array

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

## Insertion Sort – Java Implementation

What is Insertion Sort?? Insertion sort is a simple sorting algorithm that builds the sorted array one item at a time. Efficient for small data sets, not efficient for large data sets. Most of...

## Find Largest and Smallest word in a given String

Objective: Given a String, write a program to find largest and smallest word in it. Example: Input String: test Smallest Word: test Largest Word: test —————— Input String: This problem is solved at Algorithms...

## Check if Given Number is power of 2.

Objective: Given a number, write a program to find if number is power of two. Example: N = 5 Output: false. N = 8 Output: true (23) N = 512 Output: true (29) Approach:...

## Rotate the given array in cycles

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

## Print First n numbers in Fibonacci Series

Objective: Write a program to print first n numbers in Fibonacci series. Fibonacci number: First two Fibonacci numbers are defined as 0 and 1 and every number after the first two is the sum...