Searching algorithms

EasyMediumHard
12
Question 2
Hard

Extend the program in Figure 1 to implement a linear search. Your answer must be written in C#.

string[] isotopes = {"Carbon-14", "Cobalt-60", "Cesium-137",
                     "Iodine-131", "Radium-226", "Plutonium-239"};

Figure 1

The program should ask the user to enter an isotope name and perform a linear search on the array isotopes to check if that isotope is present in the list.

The program must:

  • prompt the user to input an isotope name to search for
  • output the message Isotope Verified if the isotope is present in the array
  • output the message Isotope Unverified if the isotope is not present in the array

You must write your own linear search routine and not use any built-in search functions or methods available in C#.

You should use meaningful variable names and correct C# syntax in your answer.

[7]

Searching algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Searching algorithms