## Linear Search vs Binary Search

Earlier we have seen linear search and binary search and how these work individually, In this article we will compare these two search algorithms. If you are new to these, please read the prerequisites...

Earlier we have seen linear search and binary search and how these work individually, In this article we will compare these two search algorithms. If you are new to these, please read the prerequisites...

Objective: Given a binary tree, write an algorithm to count all the nodes in the tree. Example: Approach: Do postorder traversal. If the root is null return 0. (base case all well for the...

Objective: Given an input string, write an algorithm to find the longest contiguous character or in other words, find a maximum consecutive character in the string. Example: Input: “aaabbccccddbbaaa” Output: c, count = 4...

The Collatz conjecture is a conjecture in mathematics which states that no matter what value of Positive Number N, If the below sequence is followed then, the sequence will always reach 1. If N...

Objective: Implement atoi, which converts string to an integer. Rules for converting string to an integer. If the string is null or empty, Integer will be 0. The first character of string may represent...

Objective: Given a number N, Write a program to find all prime numbers which are between 0 and N. Prime Number : A prime number is a natural number that has exactly two distinct...

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

Objective: Given a string, write an algorithm to find all the duplicate characters in the string and print its count. Example: Input String: tutorial horizon Output: Duplicate Characters: r – 2 t – 2...

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

Objective– Given an array of numbers, write a java program to find the largest element in the given array. Example: int [] a = {1, 5, 3, 9, 2, 8, 2} Largest Element: 9...

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

Earlier we saw about Stack and its implementation using Linked List. Java has a built in class for Stack. In this article we will discuss about it in detail. First brief about Stack. What...

Infix, Postfix and Prefix notations are most common ways of writing expressions. Infix notation: Example: (A+B) Infix notation is commonly used in arithmetic formula or statements, the operators are written in-between their operands. An...

Objective: Given a Number, find all the set bits in that number. Example: Number: 23 Set bits: 4 (10111) Number: 15 Set bits: 4 (1111) Number: 21 Set bits: 3 (10101) Approach: Check the...

Objective: Given an array of integers, write a program to check if array contains all unique numbers. Example: Integer [] arrA = { 1, 2, 3, 6, 4, 9, 8}; Output: Array has all...

%d bloggers like this: