Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Andrew Wyrzykowski
linear search
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 30, 2008 at 11:38 PM


Hi friend,


Code to solve the problem :

public class LinearSearch
{


// Search "array" for the specified "key" value
public static boolean linearSearch( String array[][], int key1,int key2,String strMatch)
{
for ( int n = 0; n <array.length; n++ )
{
for(int m=0;m<array[n].length;m++)
{
if((key1==n) && (key2==m))
{
String str = array[n][m].substring(0,2);
if(str.equals(strMatch))
{
return true;
}
}
}
}

return false;
}


public static void main(String args[])
{

String Data[][] = new String[2][3];

Data[0][0] = "Hello"; //lastname
Data[0][1] = "World"; //firstname
Data[0][2] = "Roseindia"; //location

//Second row
Data[1][0] = "Xyz"; //lastname
Data[1][1] = "Abc"; //firstname
Data[1][2] = "India"; //location


int key1 = 1;
int key2 = 1;
String strmatch = "Ab";

if(linearSearch(Data,key1,key2,strmatch))
{
System.out.println("Item exists");
}
else
{
System.out.println("Item doesn't exists");
}

}
}

For any more problem on Java visit to :

http://www.roseindia.net/java/

Thanks


Related Tutorials/Questions & Answers:
linear search
linear search  write a program to find string using linear search
linear search - Java Beginners
linear search  How do i use a linear search for a 2 dimensional hard coded array? I need to check the first 2 letters in an item number... { // Search "array" for the specified "key" value public static
Advertisements
Linear search in java
Linear search in java In this section we will  know, what is linear search and how linear works. Linear search is also known as "sequential.... Linear search is a searching mechanism which search  key element
Algorithms: Linear Search
Java Notes: Algorithms: Linear Search Look at every element This is a very..., linear search is a good solution because it's so straightforward. In an array of a million elements linear search on average will take 500,000 comparisons to find
Linear Search in Java
Linear Search in Java In this section, we are going to find an element from an array using Linear Searching. Linear searching is a good way to find an element...(); } LinearSearch search = new LinearSearch(); System.out.print("Enter the element
Linear hashing
Linear hashing   hello,, What is linear hashing?   hii, In linear hashing, the table is gradually expanded by splitting the buckets in order until the table has doubled its size
Linear Regression
Linear Regression  hi........ Can u give me a simple code for Linear Regression in java swings????????? thanks in advance plz reply
linear sorting
linear sorting  what is linear sorting? can any send me an example   Hi Friend, Try this: import java.util.*; class ArraySort{ public static void sortArray(int arr[]){ Arrays.sort(arr); System.out.println
Binary Search in Java
Binary Search in Java In this section, we are going to search an element from an array using Binary Search. The advantage of a binary search over a linear search is astounding for large numbers. It can be done either recursively
Linear and Non-Linear Data Structure in C
Linear Data Structure: Linear data structure is linear if element is adjacent... as its previous and next member. Example of Linear Data Structure Array Linked List Stack Queue Non- Linear Data Structure Non-Linear data
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Search
Search   Hi, I have a project in which I am trying to enter "Marathi" (Indian local language) data in JSP using JSTL and trying to search data... and tries to search then It shows no data from database
Binary Search in Java
Binary Search in Java is used to search an element from an array. Programmers opt for Binary search over linear search when it comes to large numbers. It can... the answer "Not Found". Following is the example of Binary Search in Java: import
What is Linear Tape Open(LTO)
and application of data. LTO or Linear Tape Open is one of the most promising storage... for data sharing. LTO or Linear Tape Open is the storage technology that addresses all...) and Quantum's DLT (Digital Linear Tape). Other big brands in the storage market were
Search index
Search index  how to write code for advanced search button
Algorithms: Binary Search
of a binary search over a linear search is astounding for large numbers. For an array... with a worst case of only 20 comparisons. Linear search, O(N), on average... } Related Pages Linear Search, Recursive Binary Search Copyleft 2006
gauss elimination of system of linear equations using java code
gauss elimination of system of linear equations using java code  Here is my code: import java.util.Scanner; import java.util.*; public class gausselimination { private static final double EPSILON = 1e-10
Hibernate Search
Hibernate Search  Where to learn Hibernate Search module? Thanks   Hi, Check the tutorial: Hibernate Search - Complete tutorial on Hibernate Search Thanks
SEARCH AND SORT
SEARCH AND SORT  Cam any one provide me the code in java that : Program to search for MAX,MIN and then SORT the set using any of the Divide and conquer method
SEARCH PAGE
SEARCH PAGE  search page:option for search criteria like name and DOB will be asked.on entering the detail,data matching search criteria will be displayed..criteria can be both or any one of them.. can you send code
search program
search program  i m writing program which takes company names from databse...serch on google...n try to find the best match WEBSITE...of company name... links after google search...plzz help
Search Engine
Search Engine  I have gone through the below mentioned link document to create search engine and fetch the data from mysql database.But i am getting errors. http://www.roseindia.net/sql/mysql-table/sql-search.shtml Error: Notice
search for a name
search for a name  Search for a name Write a program to accept an array of names and a name and check whether the name is present in the array. Return the count of occurrence. Use the following array as input {?Dave?, ?Ann
Google Search
Google Search  I have a textbox and submit button in my JSP page. On giving word in the textbox and click submit it should redirct to google search page and fetch all the results based on my input word automatically. JSP/Servlet
Array search
for the search operation. he value with one or more of the array items. Search begins
php search variable
php search variable  Search variable in PHP
email search code in php
email search code in php  email search with multiple option in php
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
Search operation in JSP page
Search operation in JSP page  How to perform search in jsp with MYSQL database plz help me
mkmapkit location search
mkmapkit location search  How to create a location search function that will allow the current location search on the MKMapKit
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
search operation - Java Beginners
search operation  how to retrive all the similar elements (search operation ) on xml document using regular expressions
Drop down for search textbox like google search
Drop down for search textbox like google search  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop down list appear, then we can select one of word as our
jquery search for html pages
jquery search for html pages  i want to search html pages with jquery, it is k for single page but i want search more than one page at a time. Thank you in advance
NSMutableArray Search String
NSMutableArray Search String  Hi all, In my iPhone SDK application.. i wanted to search from the table data. My question is ..do i need to innsert the table data into search array? thanks
php file search
php file search  How to search file in PHP .. $dir = '/tmp
SEO and Search Engines,Best Search Engines on Web,What is Search Engine
SEO and Search Engine   ... of the search engine while doing SEO work. Since in SEO we are using search engine to promote our website, so understanding the search engine details like
Search million records????
Search million records????  How to get fast search results from a table with over 10 million record??? 11g Oracle DB
search feature - JSP-Servlet
search feature  i need help to do a search feature servlet to search for employees from the database. the search will be done by search by employee name, department and email  Hi friend, As per your problem
Molu - The Search Spider
Molu - The Search Spider       www.themolu.com - Search engine which can search both Web 1.0 (Web search) as well as Web 2.0 (Tag search). Currently it gives a facility of searching web
sql query search function
sql query search function  i have a textbox on a form , i like a search a data in the form, when i give whatever name and id or etc..its will search and show the same form , so help me using jsp
Search engine for email
Search engine for email  Build a search engine which will look at your email inbox and sort your email into 5 or more bins according to some criteria (e.g. date, email address, text of the email
Search Page in jsp
Search Page in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
search query - SQL
search query  hi anyone can help me? i have four textfield...) 4)Age From and Age to ((drop down list box) i have to search the result for four keyword. 1)suppose user may search country and age only 2)suppose
search for exact match in excel
search for exact match in excel  How to search for an exact match in excel and show data if the matched sting is found? Please tell me the script. Thanks in Advance
 

 

 

DMCA.com