Code: https://thecodingsimplified.com/searc...
Solution:
For Unsorted Array:
- Start from 0th index & keep on checking the target value.
- Whenever you find the value, return the index, else return -1 at last
For Sorted Array:
- We'll apply binary search here.
- get middle index & check target value
- If value matches, return index.
- If target value greater than middle indexed value, it means, our target value lies in later half of array, so start = mid + 1
- If target value less than middle indexed value, it means, our target value lies in first half of array, so end = mid - 1
Please check video for more info:
This problem is similar to:
search a value in array,
search a value in sorted array,
find value a array,
sorted array,
search,
binary search,
array,
java tutorial,
coding simplified,
java
CHECK OUT CODING SIMPLIFIED
/ codingsimplified
★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplif...
★☆★ Send us mail at: ★☆★
Email: thecodingsimplified@gmail.com
On this page of the site you can watch the video online Array - 15: Search a value in Unsorted & Sorted Array with a duration of hours minute second in good quality, which was uploaded by the user Coding Simplified 15 September 2019, share the link with friends and acquaintances, this video has already been watched 14,934 times on youtube and it was liked by 154 viewers. Enjoy your viewing!