Java-Code

In this file I have to uplode java problem Codes.


1: Merge Sort ::Date:11/06/2021

Merge Sort:

First divide the list into the smallest unit (1 element), then compare each element with the adjacent list to sort and merge the two adjacent lists. Finally all the elements are sorted and merged. ... Merge sort is a divide and conquer algorithm that was invented by John von Neumann in 1945. TC=O(nlogn) in all cases.
2:Insertation Sort ::Date:13/06/2021

Insertion Sort:

Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in the sorted part.

Algorithm

To sort an array of size n in ascending order:
1: Iterate from arr[1] to arr[n] over the array.
2: Compare the current element (key) to its predecessor.
3: If the key element is smaller than its predecessor, compare it to the elements before. Move the greater elements one position up to make space for the swapped element.
TC=O(n) Best case.
TC=O(n^2) Average case.
3:Count Sort ::Date:15/06/2021

Count Sort

Counting Sort Algorithm is an efficient sorting algorithm that can be used for sorting elements within a specific range. This sorting technique is based on the frequency/count of each element to be sorted. Let's talk about time complexity

Time Complexity:

O(n+k) where n is the number of elements in input array and k is the range of input.

Auxiliary Space:

O(n+k)
4:LongestCommonPrifix ::Date:16/06/2021

LongestCommonPrifix:

The longest common prefix for an array of strings is the common prefix between 2 most dissimilar strings. For example, in the given array {“apple”, “ape”, “zebra”}, there is no common prefix because the 2 most dissimilar strings of the array “ape” and “zebra” do not share any starting characters.
5:Evaluate Expression ::Date:18/06/2021

6:Anagram ::19/06/2021

What is Anagram?

Two words are anagrams of each other if they contain the same number of characters and the same characters. You should only need to sort the characters in lexicographic order, and determine if all the characters in one string are equal to and in the same order as all of the characters in the other string. Example::"keep" and "peek".
7:Zero Sum Subarray ::23/06/2021

8: Find Pivote ::09/07/2021

Problem ?

Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. If the index is on the left edge of the array, then the left sum is 0 because there are no elements to the left. This also applies to the right edge of the array. Return the leftmost pivot index. If no such index exists, return -1.
9:Binary Search ::24/07/2021

What is Binary Search

Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

Time Complexity

The time complexity of the binary search algorithm is O(log n). The best-case time complexity would be O(1) when the central index would directly match the desired value. The worst-case scenario could be the values at either extremity of the list or values not in the list.
10:Multiplying Number ::14-08-2021

Multiplying Number

There are three numbers multiply between mid number and max number.