-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotes.txt
24 lines (17 loc) · 1.75 KB
/
Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Linear search technique: Compare and find the value one by one in the linear form.
Best case: O(1) Where 1 is the constant value.
Worse case: O(n) Where n is number of elements in the array.
---------------------------------------------------------------------------------------------
Binary search technique: Binary search is a technique in which array always divided at middle
and change the middle pointer according to the target value.
Best case: O(n) Where 1 is the contant value.
Worse case: log(n) Where n is number of elements in the array.
---------------------------------------------------------------------------------------------
How to find whether the array is in ascending or descending order
Ans: Compare the first and last element values. If the first element value is greater than the last element value,
then array is then sorted in descending order. Furthermore, if the first element value is less than the last element value,
then the array is sorted in ascending order.
Tip: if you given the sorted array, Always try with the binary search, 95% of the time it will do the work.
Ceiling number: The ceiling function of a real number is the least integer number greater than or equal to the given number. In the case of 4.5, the integers greater than 4.5 are 5, 6, 7, 8, ….. The smallest of all is 5. Therefore, ⌈4.5⌉ = 5.
Floor number: In mathematics and computer science, the floor function is the function that takes as input a real number x, and gives as output the greatest integer less than or equal to x, denoted ⌊x⌋ or floor(x). Similarly, the ceiling function maps x to the least integer greater than or equal to x, denoted ⌈x⌉ or ceil(x).[1]
For example, ⌊2.4⌋ = 2, ⌊−2.4⌋ = −3, ⌈2.4⌉ = 3, and ⌈−2.4⌉ = −2.