david-kariuki / dsa-java-practice1

Data Structures and Algorithms Practice 1 using java.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DSAJavaPractice1

Hello There,

This is a repository to practice Data Structures and Algorithms using Java.

# Topics Covered Test Code
1. Binary Search Present
2.
3.
4.
5.

A. BINARY SEARCH
# EXAMPLE CASE TIME COMPLEXITY PROBLEM STATEMENTS
1. Find The Index of a Target. O(log(N)) Given a sorted array of integers and an integer called target, find the element that equals the target and return its index.
2. Find the Boundary. O(log(N)) Find integer's index
3. Find Element Not Smaller Than Target. O(log(N)) Given an array of integers sorted in increasing order and a target, find the index of the first element in the array that is larger or equal to the target. Assume that it is guaranteed to find a satisfying number.
4. Find First Occurrence. O(log(N)) Given a sorted array of integers and a target integer, find the first occurrence of the target and return its index. Return -1 if the target is not in the array.
5. Square Root. O(log(N)) Given an integer, find its square root without using the built-in square root function. Only return the integer part (truncate the decimals).
6. Find Minimum in Rotated Sorted Array. O(log(N)) A sorted array was rotated at an unknown pivot. For example, * [10, 20, 30, 40, 50] * becomes * [30, 40, 50, 10, 20] *. Find the index of the minimum element in this array.
7. The Peak of a Mountain Array O(log(N)) A mountain array is defined as an array that:
1. Has at least 3 elements.
2. Has an element with the largest value called the “peak”, at an index k. The array elements monotonically increase from the first element to A[k], and then monotonically decreases from A[k + 1] to the last element of the array. Thus creating a “mountain” of numbers.
Find the index of the peak element. Assume there are no duplicates.

About

Data Structures and Algorithms Practice 1 using java.

License:MIT License


Languages

Language:Java 100.0%