Question: Coding: Traversing Linear Search(Linear Search) [C++] Given a List of Distinct N number a 1 ,a 2 ,a 3 ........a n . Find The Position

Coding: Traversing Linear Search(Linear Search) [C++]

Given a List of Distinct N number a1,a2,a3........an. Find The Position Of Number K In The Given List.

Input Format

First Line Take Input Value Of N

Second Line Take Input N Space Separated Integer Value

Third Line Take Input Value Of K

Output Format

Position Of K In The Given List

Constraints

  • 0 < N < 100001
  • 0 < ai < 1010
  • 0 < K < 1010

NOTE: Array Indexing Starts From 0

Sample Output

Example 1:

5 1 2 3 4 5 4
4 is in position 3.
Example 2: 
 
5 12 23 34 41 52 23
23 is in position 1.
Example 3:
4
2 1 3 23 
9
9 is not in the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!