In this tutorial, We are going to learn various sorting algorithms and their time complexities. Before comparing the time complexity of various sorting algorithms, let’s first understand what’s the time complexity of an algorithm and why it is important.
Write a java program to find the second highest number in an array. Given an unsorted array, we have to write a java code to find the second highest number in an array.
Write a Java program to find GCD of two numbers using Recursion. Given two input integers, we have to write a code to find GCD of two numbers using recursion. For this program, I assume you are familiar with the concept of recursion. If you don’t know about recursion then check my previous post on recursion vs iteration.
Write a java program to find the first non-repeated character in a string.Given an input string, we have to write a java code to find the first non-repeated character in a string.
For example –
i) Input string – java
Output – j (j is the first non-repeating character in a string)
ii) Input string – web rewrite
Output – b (b is the first non-repeating character in a string)
Write a program to check whether two strings are anagrams of each other.
What is an Anagram ?
Two strings are said to be anagrams of each other if it contains the same characters, only the order of characters in both the strings is different. In other words, both strings must contain the same exact letters in the same exact frequency.
How to check if a number is a power of 2. To understand this question, let’s take some example.
Input – 16 – 16 is a power of 2 (2^4).
Input – 15 – 15 is not a power of 2.
Input – 32- 32 is a power of 2 (2^5).
We can use multiple approaches to check whether a number is a power of 2 or not.
Write a script to reverse a string in PHP without using strrev() method. In PHP, we can reverse a string easily using strrev() method. But think how will you reverse a string without using an inbuilt strrev() method.
Write a program to find maximum subarray sum in an array. Given an array of N elements, find the maximum possible sum of a contiguous subarray. An array can contain both positive and negative values.
Write a program to delete a node at Nth position from Linked List. Given a linked list, we have to write a method to delete a node from Nth position.
Program to delete a complete linked list
Recursion vs Iteration. What’s the difference between recursion and iteration. Recursion and Iteration both are two different programming approaches. In some cases recursion is best suited and in some other cases iterative way of programming is good.
In programming, repeated set of instructions can be handled either by using recursive or iterative approach in your code. So which approach you choose and why. Let’s talk about recursion vs iteration.
Implementation of Binary Search using Recursion.