Find The Index Of K In A Sorted Array OR Where It Belongs To Keep It Sorted | C Programming Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2024
  • 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: github.com/por.... Check out www.portfolioc... 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.

ความคิดเห็น • 6

  • @gouravchalotravlog
    @gouravchalotravlog 2 ปีที่แล้ว +2

    Nice and thanks

  • @iamtev7579
    @iamtev7579 2 ปีที่แล้ว

    how would you use an id declared in a structure to read 2 different txt files for specific data, then display the data for the person ?

    • @PortfolioCourses
      @PortfolioCourses  2 ปีที่แล้ว

      I would need more details about this question to understand exactly what needs to be done.

    • @iamtev7579
      @iamtev7579 2 ปีที่แล้ว

      @@PortfolioCourses
      This is the Question:
      Design a system to keep track of the participants and their scores for the different events.
      Each participant has a name, id number, date of birth, gender, event type and scores as well as an overall score.
      The three(3) events that each athlete competes in are: swimming, cycling and running.
      The triathlete time is calculated by adding the five timed intervals in the competition
      - swim time, transition 1 (T1),
      - cycling time, transition 2 (T2)
      and running time.
      A triathlete can register for one of three competitions:
      Kids - 10-13
      Teens - 14-17
      Adults - 18 -35
      Objective: The system should be able to
      Register a participant for any competition type by storing their personal information.
      Enter the times for a participant for a event in each competition.
      Display the triathlete with the best time(s) for each event in each competition.
      Display the overall winner for each competition.