Question need help with sequential search

neilyd

New member
Joined
Feb 9, 2016
Messages
3
Programming Experience
Beginner
1.Write code for a sequential search that determines whether the value -1 is stored in an array with array named values. The code should display a message indicating whether the value was found.
2.Create a list object that contains all alphabets. Write a function for binary search algorithm to search for the string ?A?. Display a message box indicating whether the value was found.
3.Download the required files and create an application that reads the contents of the file into an array or list. The application should then let the user enter a charge account number (7 digits) . The program should determine whether the number is valid by searching for it in the array or list that contains the valid charge account numbers. If the number is in the array or List, the program should display a message indicating that the number is valid. If the number is not in the array or list, the program should display a message indicating the number is invalid.


just tell me how would you do that and how your logic will look like i need just the statements.
 

Attachments

  • ChargeAccounts.txt
    160 bytes · Views: 41
just tell me how would you do that and how your logic will look like i need just the statements.

So, just do your assignment for you? How about no? Instead, you do what you think you need to do and, if you encounter any issues, post back here and provide us with what you've done and exactly where you're stuck and then we'll help you overcome that specific issue. You then continue on doing what you think you need to until you encounter issue, etc. We're here to help but that means help you solve your problems, not do your work for you so that you don't have to.
 
1.
bool found = false;
int index = 0;
int position = -1;
while (!found && index < sArray.Length)
{
    if (sArray[index] == value) 
    {
        found = true;
        position = index;
    }
    index++;
}

2.List<string>nameList=newList<string>(){“A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z” }
i didnt get how ho use a binary search for strings.
3.for the thrid one im just asking for statements, or pseudocode
 
Back
Top Bottom