Find The Index Of K In A Sorted Array OR Where It Belongs To Keep It Sorted | C Programming Example
1.5K views on YouTube
Use C to find the index of a value k in a sorted array of distinct elements, or find the index where k belong in order to keep the array sorted. Source code: https://github.com/portfoliocourses/c-example-code/blob/main/find_k_sorted_array.c. Check out https://www.portfoliocourses.com to build a portfolio that will impress employers!
Original question: Given a sorted array arr[] consisting of N distinct integers and an integer K, the task is to find the index of K, if it’s present in the array arr[]. Otherwise, find the index where K must be inserted to keep the array sorted.