0% found this document useful (0 votes)
19 views6 pages

Master Dsa Java

The document outlines various data structure and algorithm (DSA) problems in Java, providing code snippets and explanations for each. It covers topics including arrays, numbers, number systems, sorting algorithms, and string manipulation techniques. Each section includes methods for finding elements, checking properties, sorting, and manipulating strings.

Uploaded by

patidarshourya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

Master Dsa Java

The document outlines various data structure and algorithm (DSA) problems in Java, providing code snippets and explanations for each. It covers topics including arrays, numbers, number systems, sorting algorithms, and string manipulation techniques. Each section includes methods for finding elements, checking properties, sorting, and manipulating strings.

Uploaded by

patidarshourya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MASTER DSA PROBLEMS - JAVA WITH

EXPLANATION
ARRAYS
Find Smallest Element
int min=arr[0]; for(int i=1;i<[Link];i++) if(arr[i]<min) min=arr[i];

Find Largest Element


int max=arr[0]; for(int i=1;i<[Link];i++) if(arr[i]>max) max=arr[i];

Reverse Array
int i=0,j=n-1; while(i<j){int t=a[i];a[i]=a[j];a[j]=t;i++;j--;}

Second Largest
Maintain first and second maximum variables.

Rotate Array by K
Reverse whole array then parts.
NUMBERS
Palindrome
Reverse number and compare.

Prime Check
Check divisibility till sqrt(n).

Factorial
Multiply 1 to n.

Fibonacci
Use loop to print series.

GCD
Use Euclidean algorithm.
NUMBER SYSTEM
Binary to Decimal
Multiply bits by powers of 2.

Decimal to Binary
Repeated division by 2.

Octal to Decimal
Multiply by powers of 8.
SORTING
Bubble Sort
Compare adjacent and swap.

Selection Sort
Select minimum and swap.

Insertion Sort
Insert element in sorted part.

Quick Sort
Partition and recurse.

Merge Sort
Divide and merge.
STRINGS
Palindrome String
Reverse and compare.

Reverse String
Use StringBuilder reverse.

Anagram
Sort both and compare.

Remove Vowels
Skip vowels.

Count Characters
Use HashMap.

You might also like