Frequently Asked Java Program 21: Searching an Element in Array | Binary Search
ฝัง
- เผยแพร่เมื่อ 15 ต.ค. 2019
- Topics :
----------
1) Searching an Element in Array
2) Binary Search
#########################
Udemy Courses:
#########################
Manual Testing+Agile with Jira Tool
************************************
► shorturl.at/xNXZ4
Selenium with Java+Cucumber
********************************
► shorturl.at/aIKMW
Selenium with Python & PyTest
********************************
► shorturl.at/ELW09
Selenium with python using Robot framework
****************************************
► shorturl.at/bcDPZ
API Testing(Postman, RestAssured & SoapUI)
*****************************************
► shorturl.at/uAWY7
Web & API Automation using Cypress with Javascript
********************************************
► rb.gy/4uum2n
Playwright with Javascript
**************************
► shorturl.at/gALZ1
Jmeter-Performance Testing
************************
► rb.gy/ocj7r2
SDET Essencials(Full Stack QA)
*************************
► rb.gy/hlnf2v
Appium-Mobile Automation Testing
************************************
► rb.gy/wmzv64
Java Collections
*****************
► bit.ly/3S66ezE
Python Programming
*********************
► urlis.net/gdsfpb0s
Cucumber BDD Framework
***************************
► bit.ly/3F7d69r
Protractor with Javascript
***************************
► urlis.net/4uddm1qb
####################################
TH-cam Playlists:
####################################
Manual Testing & Agile
***********************
► bit.ly/3ujvaYa
► bit.ly/3OYzxQj
SQL
*************************
► bit.ly/3R6XjeG
► bit.ly/3nE0a1s
► bit.ly/3IeKuuJ
linux & Shell Scripting
**********************
► bit.ly/3up1Z6a
► bit.ly/3nzvGxx
Java
**********************
► bit.ly/3R9QfOs
► bit.ly/3AoRMKM
► bit.ly/3IbTTDn
► bit.ly/3ybXInv
► bit.ly/3yCoHdw
Selenium With Java+Cucumber
********************************
► bit.ly/3P2FMm4
► bit.ly/3yhiIt4
► bit.ly/3uokzet
► bit.ly/3a7XIND
► bit.ly/3umN2S9
► bit.ly/3aar7GW
► bit.ly/3y9kD2S
► bit.ly/3uhLskn
Python
********************************
► bit.ly/3agNgU0
► bit.ly/3NJNnoy
► bit.ly/2CTQ4mR
► bit.ly/3OIYWh1
Selenium With Python,Pytest&Behave
***************************************
► bit.ly/3OHHoC9
► bit.ly/3IeNLdv
► bit.ly/2J4tPeT
► bit.ly/3ydSkAq
Selenium With Python Using Robert Framework
(Web&API Testing)
*************************************************
► bit.ly/3nUvlpr
► bit.ly/3nUvE3z
API Testing (Postman,SoapUi,&Rest Assured)
**********************************************
► bit.ly/3OXacWY
► bit.ly/3yh0UhE
► bit.ly/3nC9DWQ
► bit.ly/3yGfhNS
► bit.ly/3OJa11H
► bit.ly/3P2slCC
Mobile App Testing Appium
****************************
► bit.ly/3Al49HG
Performance Testing Jmeter
*******************************
► bit.ly/3nz4fE7
Maven,Jenkins,Git,Github,CI/CD
*******************************
► bit.ly/3P16HPj
► bit.ly/3yhlUVA
► bit.ly/3afYfwT
► bit.ly/3yGzweG
► bit.ly/3yF73Ws
► bit.ly/3NCOmH7
SQL,DB Testing&ETL,Bigdata
*******************************
► bit.ly/3NKOcNY
► bit.ly/3OVpDyI
► bit.ly/3NEvUy0
► bit.ly/3IryxlT
► bit.ly/3RkWBLh
JavaScript Based Automation Tools
********************************
► bit.ly/3nUx51X
► bit.ly/3AqI6Q0
► bit.ly/3yeurbT
► bit.ly/3ujzpTK
Selector Hub Tools
********************
►rb.gy/h3h424
GraphQL
******************
► rb.gy/sj3gys
Cypress API Testing
********************
► shorturl.at/fjKPX
Cypress Web Testing
**********************
► shorturl.at/agjlK
Playwright with Javascipt
**************************
► shorturl.at/adSTY
#PythonArraySearch
#ArrayElementSearch
#PythonSearchAlgorithm
#ArraySearching
#FindElementPython
#ArraySearchTechniques
#PythonSearchMethods
#SearchArrayPython
#ArraySearchTips
#PythonSearchTricks
#ArrayLookup
#SearchInPython
#ArrayQuery
#PythonArrayQueries
#ElementInArray
#PythonSearchTutorial
#ArrayHunting
#SearchLogicPython
#ArrayScan
#PythonArrayMagic
#ElementSeeking
#ArrayHunters
#PythonSearchPointers
#SearchingWithPython
#ArraySniper
#FindInArray
#PythonSearchHacks
#ArraySearchByExample
#PythonArrayQuest
#SearchChallenge
#ArraySleuthing
#PythonSeekAndFind
#ElementQuest
#PythonArrayExpedition
#SearchMastery
#ArrayInvestigation
#PythonSearchExploration
#ElementScout
#PythonArrayPuzzle
#SearchJourney
#ArrayDiscovery
#PythonHuntAlgorithm
#ElementDetection
#PythonArrayTracking
#SearchAlgorithms
#ArraySearchAdventures
#PythonSearchGuides
#ElementTrail
#PythonArraySleuth
#SearchInArrays
Thank you for this video sir. One request, Please remove the background noise which is making irritating while watching the video.
That irritating sound is coming in all your java interview Q&A series. So please consider my request.
Thanks a bunch ☺️..
Explanation was crystal clear 👍
Thank you for full session Sir, it is really helpful, It will be good if you upload frequently asked programs on DS or collections
How we can do the same binary search with for loop i tried for( low=0;low
Thank you for explaining coding interview questions line by line and also the logic behind them .I wish i had found this earlier.if possible please explain how to create an web application using spring mvc and please explain the mvc part as in where it is applied in the application.
is it only working sequential order in array?
the way your explanation is very clear it is possible only when u thorough in the subject thanks for the explanation
Glad it was helpful!
automation tester what types of coding will ask for expeirence candiadtes can make playlist
Thank you so much, Sir. You have a gift in explaining complex things!
You are very welcome
It doesn't work for 1 when you make 1 the key it returns not found
Sir.. You are helping us to learn Java programming in simple terms...
Glad to hear that
Yes sir.. I am also feeling the same
This 30 Programming is really Logical Building Program Thank You SO much sir.
Welcome
I understood it clearly..thanks!
Welcome
add on to previous comment if you set l=0 it will search all the other indexes but if you search number 1 at index [0] it will return not found I set l to -1 and it works fine.
It is very helpful for class 10 icse
Wonderfull explanation, thanks
Welcome
Thank you so much, by the way, there is a weird whistle in your audio.
Thanks for this wonderful tutorial
You're welcome 😊
@@sdetpavan Sir could you pls create tutorial on Extent Report 5
Bro u knows
Python
Java
Selinium
Data structures
JavaScript
Sql
U r a full stack developer
Very good explanation sir
Thanks
Commenting for better reach
2nd method is not working , here i have found correct code for it.
import java.util.Arrays;
public class BinarySearch2 {
public static void main(String args[]) {
int a[] = {1,2,3,4,5,6,7,8,9,10};
System.out.println(" found at index = " + Arrays.binarySearch(a, 8));
}
}
Using the binary search logic - how can we identify the exact position instead of element found ?
Can let us know sir
m is the position of the element. You can print it as System.out.println("Element Found at position:" + (m+1));
Thanks sir
@@TechStack9 plss reply what if there is no element given then how will I initialise the array plss explain
@@shivamsatpathy5171 using scanner class
Sir why using Boolean= false can explain
to initialize boolean and its default value is false
What if differences between alternate elements are not same
It doesn't matter
apaga saporra ae
package javaapplication23;
public class JavaApplication23 {
public static void main(String[] args) {
int[] L = {1,2,3,4,5,6,7,8};
int target = 0;
int start = 0;
int end = L.length - 1;
while (start target) {
end = mid - 1;
}
}
if (start > end){
System.out.println("Item not found");
} else {
System.out.println("Item not found.");
}
}
}
@1: 46 -> you are telling left side . => but its right side..
Yes i am aslo getting confuged there....
It's left side from array and right side from us
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
int[] L = {1,2,3,4,5,6,7,8};
System.out.print("ENTER TARGET: ");
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int start = 0;
int end = L.length - 1;
while (start < end){
int mid = (start + end) / 2;
if (L[mid] == n){
System.out.println("Found: " + L[mid]);
break;
} else if (L[mid] < n){
start = mid + 1;
} else if (L[mid] > n){
end = mid - 1;
}
}
if (n < L[start] || n > L[end]){
System.out.println("Not found in array.");
}
scan.close();
}
}
It's zero not jero