Linear search between two arrays

I'm having trouble with the comparison of an array of football teams and an array of team names that may or may not be in the football team array. I have read both .txt files into their own arrays and parsed the team array with substring in order to isolate the team name. I know I can read both the search array and the team names individually because I tested it with a println. I think my problem is in the comparison "if" statement.
    public void seqSearch()//Sequential(linear) search
    int j=0, s;
    //int m = j+1;
        for(s=0; s<searchSize; s++)//increments through the search array
          for(j=0; j<teamArray.length; j++)//increments through the team array
           if(teamArray[j].getName().equals(search[s]))//I think this is where the problem is
               System.out.println("Found " + teamArray[j].getName() + "after" + j + "searches.");
               break;                 
           else
               System.out.println(teamArray[j].getName());//prints through all of the names during each search for testing
               if(j == teamArray.length-1)
                   System.out.println("Can't find " + search[s] + " after " + j + " searches");
        }//end for
    }//end seqSearch()My output prints the names of each team on their own line and at the end it always says that it can't find each search term.
Ex.
Bears
Bengals
Bills
Vikings
Can't find Bills after 32 searches
Bears
Bengals
Bills
Vikings
Can't find Eagles after 32 searches
etc
I though that .equals was the way to compare in this situation. Any idea what I'm doing wrong?

Dave,
teamArray[j].getName().equals(search[s]))what is the implementation class which is returned from "search[s]" and from "eamArray[j].getName()"
if both of them are java.lang.String then us "equalsIgnoreCase" instead of "equals"
if the implementation class is different, then you have to override the equal method and implement your own.
Regards,
Alan Mehio
London, UK

Similar Messages

  • Implementation of linear fit between two cursors

    Hi,
    I am trying to implement a linear fit between two cursors, as I am using total of 4 cursors. I would like to implement linear fit between cursor 2&3. Please help me how to implement it and to find a slope. I am also attaching my code.
    With Regards
    Phani kiran
    Solved!
    Go to Solution.
    Attachments:
    Linear Fit Implementaion.PNG ‏44 KB

    phanikiran wrote:
    Hi koen,
    Now I would like to merge both graphs i.e., Bestfit and XY Graph (in the block diagram). Can you suggest me, I have tried with build array and concenate Inputs function, but no use. Dont mine as I  am new to Labview. Thanks in advance.
    First, get rid of the Express XYGraph subVIs and use the "real" XY graph VIs. The Express ones get you going faster for simple things, but your options are limited.
    Take your X and Y arrays for both your original points and the best fit points (just two points, right?) and combine them into clusters of arrays (instead of feeding them into the XY graph). Then combine these into an array and feed it into your graph. It's all outlined in the XY Graph section of the LabVIEW help file.
    The LV Help File is your friend, learn to use it. It gets lonely if you don't look in on it once in a while.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • Search between Two date Error

    Hi,
    i have create report using to table i have take search option in that report now i want to display report between two dates
    How to put Between Date Quary in search option in where Clause .
    My code is
    select      CRM_SALES_DEALs.id,
             "CRM_SALES_CUSTOMERS"."CUSTOMER_NAME" as "CUSTOMER_NAME",
          "CRM_SALES_SALESREPS"."REP_LAST_NAME"||', '||
          "CRM_SALES_SALESREPS"."REP_FIRST_NAME" as "REP_NAME",
          "CRM_SALES_DEALS"."DEAL_NAME" as "DEAL_NAME",
          "CRM_SALES_DEALS"."EMAIL" as "EMAIL",
          "CRM_SALES_DEALS"."DEAL_CLOSE_DATE" as "DEAL_CLOSE_DATE",
          "CRM_SALES_DEALS"."DEAL_AMOUNT" as "DEAL_AMOUNT",
          "CRM_SALES_DEALS"."DEAL_PROBABILITY" as "DEAL_PROBABILITY",
          "CRM_SALES_DEAL_STATUS_CODES"."STATUS_CODE" as "STATUS_CODE" ,
             "CRM_SALES_DEALS"."DATE_OF_QUARY" as "DATE_OF_QUARY",
             "CRM_SALES_DEALS"."DEAL_SOURCE" as "DEAL_SOURCE",
             "CRM_SALES_DEALS"."DEAL_AMOUNT" *
             "CRM_SALES_DEALS"."DEAL_PROBABILITY" / 100 weighted_forecast,
    (select count(*) from CRM_SALES_DEAL_products where deal_id = "CRM_SALES_DEALS".id) products,
    nvl("CRM_SALES_DEALS".updated_on,"CRM_SALES_DEALS".created_on) last_changed,
    t.territory_name,
    CRM_SALES_DEALS.qtr, "CRM_SALES_DEALS"."CONTACT_NAME" as "CONTACT_NAME",
    "CRM_SALES_DEALS"."ACTIVE_FLAG" as "ACTIVE_FLAG"
    from     
    "CRM_SALES_SALESREPS",
    "CRM_SALES_DEAL_STATUS_CODES" ,
    "CRM_SALES_CUSTOMERS",
    "CRM_SALES_DEALS",
    CRM_SALES_territories t
    where  
    CRM_SALES_customers.customer_territory_id = t.id(+) and
    "CRM_SALES_DEALS"."CUSTOMER_ID"="CRM_SALES_CUSTOMERS"."ID"(+)
    and      "CRM_SALES_DEALS"."DEAL_STATUS_CODE_ID"="CRM_SALES_DEAL_STATUS_CODES"."ID"(+)
    and      "CRM_SALES_DEALS"."SALESREP_ID_01"="CRM_SALES_SALESREPS"."ID"(+) and "CRM_SALES_DEALS"."ACTIVE_FLAG" ='Y' and (:p1_find is null or instr(upper("CRM_SALES_CUSTOMERS"."CUSTOMER_NAME"),upper(:p1_find))>0 or instr(upper("CRM_SALES_DEALS"."DEAL_NAME"),upper(:p1_find))>0 or
    instr(upper("CRM_SALES_SALESREPS"."REP_FIRST_NAME"||' '||"CRM_SALES_SALESREPS"."REP_LAST_NAME"),upper(:p1_find))>0)
    and
    (nvl(:P1_TERRITORY,0) = 0 or t.id= :P1_TERRITORY)
    and
    (nvl(:P1_ACCOUNT,0) = 0 or "CRM_SALES_CUSTOMERS".id = :P1_ACCOUNT)
    and
    (nvl(:P1_QUARTER,'0') = '0' or CRM_SALES_deals.qtr = :P1_QUARTER)
    and
    *("CRM_SALES_DEALS".created_on between :P1_CREATE_DATE and :P1_END_DATE ) >0 and*                                          *Here I have put Quary*
    instr(upper("CRM_SALES_DEALS"."CREATED_ON"),upper(nvl(:P1_CREATE_DATE,"CRM_SALES_DEALS"."CREATED_ON"))) > 0
    and
    nvl(DEAL_PROBABILITY,10) between nvl(:P1_MINIMUM_PROBABILITY,0) and nvl(:P1_MAXIMUM_PROBABILITY,100) AND
    (nvl(:P1_LEAD_SOURCE,'0') = '0' or CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Show me Error Command not Properly Ended
    How can i search Between two date In Search option.
    Thanks

    I'm guessing that this is Jay???
    Please heed my numerous previous comments regarding formatting and those horrible full table aliases and upper case, double quoted names... Grrr...
    Anyway, try this...
    SELECT   CRM_SALES_DEALs.id,
             CRM_SALES_CUSTOMERS.CUSTOMER_NAME AS CUSTOMER_NAME,
                CRM_SALES_SALESREPS.REP_LAST_NAME
             || ', '
             || CRM_SALES_SALESREPS.REP_FIRST_NAME
                AS REP_NAME,
             CRM_SALES_DEALS.DEAL_NAME AS DEAL_NAME,
             CRM_SALES_DEALS.EMAIL AS EMAIL,
             CRM_SALES_DEALS.DEAL_CLOSE_DATE AS DEAL_CLOSE_DATE,
             CRM_SALES_DEALS.DEAL_AMOUNT AS DEAL_AMOUNT,
             CRM_SALES_DEALS.DEAL_PROBABILITY AS DEAL_PROBABILITY,
             CRM_SALES_DEAL_STATUS_CODES.STATUS_CODE AS STATUS_CODE,
             CRM_SALES_DEALS.DATE_OF_QUARY AS DATE_OF_QUARY,
             CRM_SALES_DEALS.DEAL_SOURCE AS DEAL_SOURCE,
             CRM_SALES_DEALS.DEAL_AMOUNT * CRM_SALES_DEALS.DEAL_PROBABILITY / 100
                weighted_forecast,
             (SELECT   COUNT ( * )
                FROM   CRM_SALES_DEAL_products
               WHERE   deal_id = CRM_SALES_DEALS.id)
                products,
             NVL (CRM_SALES_DEALS.updated_on, CRM_SALES_DEALS.created_on)
                last_changed,
             t.territory_name,
             CRM_SALES_DEALS.qtr,
             CRM_SALES_DEALS.CONTACT_NAME AS CONTACT_NAME,
             CRM_SALES_DEALS.ACTIVE_FLAG AS ACTIVE_FLAG
      FROM   CRM_SALES_SALESREPS,
             CRM_SALES_DEAL_STATUS_CODES,
             CRM_SALES_CUSTOMERS,
             CRM_SALES_DEALS,
             CRM_SALES_territories t
    WHERE   CRM_SALES_customers.customer_territory_id = t.id(+)
             AND CRM_SALES_DEALS.CUSTOMER_ID = CRM_SALES_CUSTOMERS.ID(+)
             AND CRM_SALES_DEALS.DEAL_STATUS_CODE_ID =
                   CRM_SALES_DEAL_STATUS_CODES.ID(+)
             AND CRM_SALES_DEALS.SALESREP_ID_01 = CRM_SALES_SALESREPS.ID(+)
             AND CRM_SALES_DEALS.ACTIVE_FLAG = 'Y'
             AND (:p1_find IS NULL
                  OR INSTR (UPPER (CRM_SALES_CUSTOMERS.CUSTOMER_NAME),
                            UPPER (:p1_find)) > 0
                  OR INSTR (UPPER (CRM_SALES_DEALS.DEAL_NAME), UPPER (:p1_find)) >
                       0
                  OR INSTR (
                       UPPER(   CRM_SALES_SALESREPS.REP_FIRST_NAME
                             || ' '
                             || CRM_SALES_SALESREPS.REP_LAST_NAME),
                       UPPER (:p1_find)
                    ) > 0)
             AND (NVL (:P1_TERRITORY, 0) = 0 OR t.id = :P1_TERRITORY)
             AND (NVL (:P1_ACCOUNT, 0) = 0
                  OR CRM_SALES_CUSTOMERS.id = :P1_ACCOUNT)
             AND (NVL (:P1_QUARTER, '0') = '0'
                  OR CRM_SALES_deals.qtr = :P1_QUARTER)
             AND CRM_SALES_DEALS.created_on BETWEEN :P1_CREATE_DATE
                                                 AND  :P1_END_DATE
             AND INSTR (
                   UPPER (CRM_SALES_DEALS.CREATED_ON),
                   UPPER (NVL (:P1_CREATE_DATE, CRM_SALES_DEALS.CREATED_ON))
                ) > 0
             AND NVL (DEAL_PROBABILITY, 10) BETWEEN NVL (:P1_MINIMUM_PROBABILITY,
                                                         0)
                                                AND  NVL (
                                                        :P1_MAXIMUM_PROBABILITY,
                                                        100
             AND (NVL (:P1_LEAD_SOURCE, '0') = '0'
                  OR CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Cheers
    Ben

  • Query to search between two specific dates and time period

    Hi,
    Need a query to search between two particular dates and time period
    Like i want to search table having one date field .
    Suppose the date range is '01-JUL-06' and '01-AUG-06' and time frame
    is 23:00:00 to 08:00:00
    i.e i want to search between dates 01 july to 01 aug and also within the time frame i.e 23:00 to 08:00 hrs only

    The general principle is
    SELECT * FROM your_table
    WHERE some_date BEWTEEN to_date('01-JUL-06') and to_date('01-AUG-06' )+0.99999
    AND  ( some_date <= trunc(some_date)+8/24
               OR  some_date >= trunc(some_date)+23/24 )
    /Cheers, APC

  • How to make search between two dates accept null not obligatory search proplem

    Hi guys when i search record between two dates it works ok success but you must enter date from and dateto first to  to make search
    i will show what i need from this example
    I need to search dynamic by 4 textbox
    1-datefrom
    2-dateto
    3-EmployeeNo
    4-EmployeeName
    but search i need must be dynamic meaning
    if i enter employee no only give me employee no found in database
    if i enter employee name give me employees found with this name using like
    if i enter all 4 text box null and enter button search get all data
    but i have proplem in this query when i need to search by click search button
    i must write date from and date to firstly then write employee no or employee name if i need to search
    so that i need to search by employee no alone or employee name alone without using date from and date to
    And if i search without using datefrom and dateto it give me message error 'string wasnot recognized as valid datetime"
    my stored procedure and code as following :
    ALTER proc [dbo].[CollectsearchData]
    @StartDate datetime,
    @EndDate datetime,
    @EmployeeID  NVARCHAR(50),
    @EmployeeName  nvarchar(50)
    as
    Begin
    Declare @SQLQuery as nvarchar(2000)
    SET @SQLQuery ='SELECT * from ViewEmployeeTest Where (1=1)'
    If (@StartDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate >= '''+ Cast(@StartDate as varchar(100))+''')'
    If (@EndDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate <= '''+ Cast(@EndDate as varchar(100))+''')' 
    If @EmployeeID <>''
    Set @SQLQuery = @SQLQuery + 'And (EmployeeID = '+ @EmployeeID+') '
    If @EmployeeName Is Not Null
    Set @SQLQuery = @SQLQuery + ' AND (DriverName LIKE
    ''%'+@EmployeeName+'%'') '
    Print @sqlQuery
    Exec (@SQLQuery) 
    End
    Function using
    public DataTable SearchDataA(string ConnectionString,string EmployeeNo,string EmployeeName, DateTime StartDate, DateTime EndDate)
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CollectsearchData";//work
    cmd.Parameters.Add("@StartDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EndDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 50);
    cmd.Parameters.Add("@EmployeeName", SqlDbType.NVarChar, 50);
    cmd.Parameters["@StartDate"].Value = StartDate;
    cmd.Parameters["@EndDate"].Value = EndDate;
    cmd.Parameters["@EmployeeID"].Value = EmployeeNo;
    cmd.Parameters["@EmployeeName"].Value = EmployeeName;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    DataSet ds = new DataSet();
    da.Fill(ds);
    DataTable dt = ds.Tables[0];
    return dt;
    interface button search
     try
    CultureInfo ukCulture = new CultureInfo("en-GB");             
    FleetManagment.Fleet fleet = new FleetManagment.Fleet();
    DataTable Table = fleet.SearchDataA("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "",textBox3.Text,textBox4.Text, DateTime.Parse(textBox1.Text,
    ukCulture.DateTimeFormat), Convert.ToDateTime(textBox2.Text, ukCulture.DateTimeFormat));
    dataGridView1.DataSource = Table;
    dataGridView1.Refresh();
    catch (Exception ex)
    MessageBox.Show(ex + "error");

    Yes, the below code should not be passed any value: (I am not sure of the syntax in .NET,Sorry) 
    --If startdate len is 0 - do not assign this value
    cmd.Parameters["@StartDate"].Value = StartDate;
    --If endate len is 0 - do not assign this value
    cmd.Parameters["@EndDate"].Value = EndDate;

  • Linear fit between two cursors from a signal from a NI-instruments via DAQ-Assistant

    Hi ! 
    I'm currently having som problem with my labview code. I'm trying to make regression on a specific part of my graph. The graph consist of a signal gathered from a NI cDAQ-9178. Currently I can get the live data in a graph (Raw Signal) and then  "zoom in" to the part of the graph that im intrested in by two cursors and then display the results in a new graph (Adjusted Signal). Now a want to make regresion in the new graph. How can i do this the best way ? 
    To be noted I'm a beginner of labview so my code maybe a bit off.
    Best regards Maurlind
    Solved!
    Go to Solution.
    Attachments:
    Rawsignal test.vi ‏245 KB
    rawsignal test.png ‏64 KB

    Hi maurlind,
    I got it, the function that derived the linear fit couldn't handle that large numbers on the x-axis. I edited the VI so that the large number is suctracted for the fit, i.e. the array will now begin at zero time for the fit. It will not affect your plots though, only the algorithm .
    Try it now with the files I provided. The file "pm_mod2_Rawsignal test.vi" should be used with "test3.lvm" (your data). The file "pm_mod3_Rawsignal test.vi" is the same as "pm_mod2_Rawsignal test.vi", but it is arranged to work with the simulated data. The file "test3.lvm" is your data, but the file is slightly edited to work on my system.
    Edit "pm_mod3_Rawsignal test.vi" to fit with your acquired signal as you did with the first file you got from me.
    Attachments:
    1412794.zip ‏483 KB

  • Correlatio​n between two arrays

    hello,
    please i need help in labview. i have collected data in stabilometer and i determined the area and circumference of XY graph for 30 staudents before and after carrying a backpack, so I want to enter the values of the area for the 30 students before and after and do the correlation between them and plot the variation nd the same thing will be done for the circumference.
    Any Help Please !!! 

    here is my code ... the stabilometer is a device that measures the balance ... in each measurment I have two txt file to save the data which are X and Y where X is the movement of the body to the right and left and Y is the anterior-posterior movement, I have attached the two txt files in the name XB and YB where B means at the begining before the student walk a distance with a backpack , also I extract XE and YE which means the stabilometer measurement after the student walk with a backpack to check if there is any influence of that load on the student's balance... in the code I plot XB in terms of YB and I draw a circle on the XY grpah to calculate the area and circumference, and the same thing will be done with XE and YE... and that will be done for 30 students... So I want to plot the area ( for XB and YB ) for all students by putting the values of the area for each student in an array , and also I want to plot the area (XE and YE) for all the student by putting all the area values in an array and see the difference ... and that will be done using the correlation between them ( between the begining (B) and the end (E) ) 
    Attachments:
    xB.txt ‏345 KB
    yB.txt ‏309 KB
    read data (1).vi ‏348 KB

  • Search between two dates

    Hi,
    I have a fields start_date(Literal Date) and end date (Literal Date) in my MDM table.
    Could any one give me a clue how to search values between these two dates from java program to this type of columns.
    Waiting for reply.

    Hi,
    Following is a snippet of code for searching a range on a date/time field in an MDM repository.
    In the following code, the table we are searching on is called "Products", and has two fields: "Part Number" and "Update Date" which is the date field. We will search for all products with "Update Date" between 2006-1-1 and 2006-1-31. (Remember in Java that MONTHS are from 0-11, and NOT 1-12).
    ============= START OF CODE =================
                        // Create a ResultSetDefinition
                        ResultSetDefinition rsd = new ResultSetDefinition("Products");
                        rsd.AddField("Part Number");
                        rsd.AddField("Update Date");
                        // Create a Search object
                        Search search = new Search("Products");
                        FreeFormTableParameter fftp = search.GetParameters().NewFreeFormTableParameter("Products");
                        FreeFormParameterField ffpf = new FreeFormParameterField("Update Date");
                        FreeFormParameter ffp = new FreeFormParameter();
                        ffpf.Add(new DateTimeParameter(2006, 0, 1, 0, 0, 0, 0, FreeFormParameter.GreaterThanOrEqualToSearchType));
                        ffpf.Add(new DateTimeParameter(2006, 0, 31, 0, 0, 0, 0, FreeFormParameter.LessThanOrEqualToSearchType));
                        ffpf.SetSearchOperator(FreeFormParameterField.SEARCH_OPERATOR_AND);
                        fftp.Add(ffpf);
                        // Get the results using the search                    
                        A2iResultSet rs = catalog.GetResultSet(search, rsd, "Part Number", true, 0);
                        System.out.println("Num found = " + rs.GetRecordCount());
    ============= END OF CODE =================
    Hope this helps,
    Walter

  • Search Between Dates

    This is confusing so I will do my best to explain.
    We have an app where employees sign out of the office. They
    supply there userID, LeaveDate, and ReturnDate and it is written
    into one record in SQL.
    There are also several searches for this data, one of which
    is to enter two dates and a userID and return whether that user is
    signed out between those two dates by looking at whether the
    LeaveDate is between the two search dates.
    The problem arose that if someone was signed out from the 8th
    to the 15th, and a search was done on them for the 11th to the
    13th, it would not return anything since the LeaveDate (8th) did
    not fall between the two search dates.
    So now I am tasked with a way to fix this. Is there a search
    between two dates and determine if any date in that span is in the
    span of dates that the employee is signed out? Is it possible to,
    when the employee signs out, create a record for each date in the
    span of days they are gone? So if someone signed out from the 10th
    to the 12th, it would create three different entries.
    Any help is appreciated.

    > return whether that user is signed out between those two
    > dates by looking at whether the LeaveDate is between the
    > two search dates
    Start by creating a few date examples that will cover all
    possibilities. Such as
    If the search dates are:
    Search Start = 11th
    Search End = 13th
    You want to include these cases
    1. Date1 is before Search Start ..AND.. Date2 is between
    Search Start and End
    Example: 6th to 13th
    2. Date1 is between Search Start and End ..AND...Date2 is
    after search End
    Example: 9th to 17th
    3. Date1 is between Search Start and End ..AND...Date2 is
    between Search Start and End
    Example: 7th to 12th
    4. Date1 is before Search Start ...AND...Date2 is after
    Search End
    Example: 5th to 21st
    Next translate those conditions to sql and test with some
    sample values. If your fields contain dates only the comparisons
    are simple. If they contain a date and time be sure to properly
    account for the time in your comparisons.
    There are better ways to write this but here is an example of
    how you might start translating the 4 conditions above. Once you've
    got the initial query working you can improve the sql.
    Psuedo-CF/SQL
    WHERE ( Date1 < #Start# AND Date2 BETWEEN #Start# AND
    #End# )
    OR ( Date1 BETWEEN #Start# AND #End# AND Date2 > #End# )
    OR ( Date1 BETWEEN #Start# AND #End# AND Date2 BETWEEN
    #Start# AND #End# )
    OR ( Date1 < #Start# AND Date2 > #End#)

  • Linear and Binary Searching of Parallel Arrays

    I'm an AP student who used the "Fundamentals of Java" by Lambert/Osborne 3rd Edition. This text book has code that doesn't match anything else I've found in other how-to's, guides, or teach yourself books. Not even online can I find code that matches up with the format used in this book!
    I've got an assignment that wants me to read in a 4 digit account number of N number of customers, places them in two parallel arrays. Data found in two separate txt files. Create a prompt that ask's for customer's account number then displays account balance. Same program for both linear and binary search methods (2 programs).
    I know the search method and how to read the files with a scanner. It is the body of the program that is stumping me. How to call and search the arrays themselves. Any help would be great.

    First of all, you have posted this question in the wrong place. Please post these kinds of general questions in the New to Java forum.
    Second, if you're in an AP class, don't you have a teacher you can ask?
    But anyway, here's the idea
    For a linear search, you go thru the array element by element, and on each element you call equals(x) to see if that element is equal to what you're searching for (note that primitives use == rather than equals)
    For binary search, note first of all that your data MUST BE COMPARABLE (primative or implement the comparable interface) and MUST BE SORTED.
    Then what you can do if go to the middle of the list, and if what you are searching for is less than that element, go to the middle of the first half of the list (if it's greater, go the the middle of the upper half of the list) and keep breaking the list in half until you've found the element or you know its not there.

  • Difference between Binary search and Linear search

    Dear all,
    If anyone helps me to get the basic difference between binary and Linear search in SAP environment.
    Regards

    Hi,
    In case of linear search system will search from begining.
    that means Example : z table contains single field with values 
    1 2 3 4 5 6 7 8 9 
    if u r searching for a value then system will starts from
    first position. if required value is founded then execution
    will comes out from z table.
    In case of binary search system will starts from mid point.
    if value is not founded then it will search for upper half.
    in  that upper half it will check mid point.like that search
    will takes place.
    Thanks,
    Sridhar

  • I got two arrays how to search and match them???????

    Hi experts plz help me out~
    i got two arrays one contains students id
    and the other one contains students id and marks
    i have to compare these two, match id, and store value next to that students.
    but how to match these two
    one file:
    213 John
    356 Chris
    421 Paul
    the other file
    356 55
    421 67
    213 69
    and so on
    i have to search both and matching IDs and store marks for them
    i ve done string tokenizing part only.................
    help me~~~~~~~~~~~~~

    You can read each file into a Map and have the student ID as a key, then you can iterate over the student map keyset and find marks for each key.
    Mike

  • Search 1 d array of dynamic data

    Hi,
    Is there a reason why the 'Search 1 D Array' function doesn't give the expected results when working on Dynamic data?
    I am trying to use one where it's input array comes from a Comparison VI inside a For loop, and so is an array of 0's & 1's.
    The element that I have set it to look for is 0, a Numeric Constant converted to Dynamic Data Type using the Convert to Dynamic Data function.
    It appears to me that regardless of whether the array contains a 0, the output is always -1, which indicates that a 0 was not present.
    Any assistance much appreciated
    Thanks
    Lama

    Stradis,
    Thanks for your reply.
    I am also using LabVIEW 8.2.1
    The reason that I am using Dynamic Data types is because this is what the Comparison VI require as input, and produce as output.
    I am using one Comparison VI to compare some DMM readings against a spreadsheet of expected values, with it set to equal within tolerance and outputting one result per datapoint. This will put a 0 against any DMM reading that falls outside of range.
    I am using a second Comparison VI in a similar way, but set to output one result for all channels to produce an overall pass or fail result (1 or 0) for each sweep of the DMM.
    The DMM is set to measure resistance, 2 wire mode and the two wires are routed through two switching matrixes. I am connecting one of the DMM inputs to the first wire and measuring between it and the remainig wires in turn, via the second switching matrix. This is what I am calling one sweep. I am then moving the first DMM input to the second wire and repeating the sweep, etc.
    Consequently I get a 1 D Array of dynamic data out of my For loop, and I want to search it to see if it contains any 0's, which would indicate an overall fail. I had hoped to use the 'Search 1 D Array' function to do this, and if it returned a -1, to use this as an indication that the equipment under test passed all sweeps of the DMM, but as I said earlier I also get -1 for what should be fail conditions.
    I hope you will forgive the spralling mess that is my code, I know that I need to reduce it to a number of sub VI's etc, but I just wanted to see it work first. Hopefully it is attached,
    Thanks
    Lama
    Attachments:
    DMM & 2 Switch Synchronous Scanning 18.vi ‏646 KB

  • How can I make a server differ between two or more clients?

    How can I make a server differ between two or more clients?
    The clients can connect and talk to the server fine, but how can I make the server talk to one, two or all clients? i.e. what would be a good way to implement this?
    Currently, the server listens for connections like this:
    while (listening) {
    try {
    new ServerThread(this, serverSocket.accept()).start();
    I guess one way would be to add the ServerThreads to a Hashtable with the client ID as key, and then get the ServerThread with the proper client ID, but this seems unnecessary complicated. Any ideas?

    Complicated was perhaps the wrong word, I should have
    written something like it doesn't "feel" right. Or is
    this a common and good way to solve communication
    between a server and multiple clients?Thats pretty much how I do it. I normally use an array or ArrayList of Sockets instead of HashTable, with [0] being the first player etc.... Then you can communicate with exactly who you want. If you want to send bytes to all of them, just send the same thing to each socket individually (or is there a better way to do this?).

  • How do I set Time Machine to alternate between two attached external drives (so that if one fails I will have a separate backup to use)?

    Hi Everyone.
    Thanks in advance for your help.
    Right off the bat let me say I am using Mavericks 10.9.1 on a 2011 Macbook Pro and using all Lacie external hard drives.
    I am trying to get Time Machine to alternate between two attached external hard drives, trying to be safe in case one of the backup drives itself fails.
    I have both drives set in Time Machine.
    From what I gather Time Machine should by default alternate between drives when backing up (I would assume it does one big initial backup on each then subsequent backups are just changes).
    But this is not how it seems to be working and I cannot find a straight answer despite much Googling and Foruming
    Unfortunately it seems to only be backing up to "External Hard Drive 1".
    There have been 4 backups since I set it up, all on "External Hard Drive 1", even though "External Hard Drive 2" is also attached and set in Time Machine.
    I manually clicked "Back Up Now" and it started to work on "External Hard Drive 2" (like I want it to) for a minute but it appears to have stopped and gone back to backing up to "External Hard Drive 1".
    Am I missing something? Does Time Machine only move on to another disk when the first one runs out of space? Do I have to turn one off in order to force it to back up to the other drive (that would be less convenient of course)?
    I am hoping that I am missing something and that it will just alternate between the two. Otherwise it is not the most comforting and thorough backup system as I had hoped when I purchased the additional external hard drive.
    I have a 1TB drive and a 500gig partition on another drive, both dedicated to backups (my Macbook HD is 475gig). It will take awhile for each to fill up and who knows what could happen during that time. Having Time Machine alternate between hard drives would be a nice small bit of security if the worst happened.
    I realize that there are tons of other options for backing up but I just want to use Time Machine if I can.
    Again thank you for your help!

    You cannot use Time Machine in that way. I'm not sure where you heard that Time Machine alternates between drives automatically. What you can do is create a mirrored RAID array for the backup. This automatically duplicates whatever is on one drive onto the other drive.
    Both drives must be the same size, and prefereably, exactly the same make and model. RAIDs can be configured using OS X's Disk Utility.
    RAID Basics
    For basic definitions and discussion of what a RAID is and the different types of RAIDs see RAIDs.  Additional discussions plus advantages and disadvantages of RAIDs and different RAID arrays see:
    RAID Tutorial;
    RAID Array and Server:
    Hardware and Service Comparison.
    Hardware or Software RAID?
    RAID Hardware Vs RAID Software - What is your best option?
    RAID is a method of combining multiple disk drives into a single entity in order to improve the overall performance and reliability of your system. The different options for combining the disks are referred to as RAID levels. There are several different levels of RAID available depending on the needs of your system. One of the options available to you is whether you should use a Hardware RAID solution or a Software RAID solution.
    RAID Hardware is always a disk controller to which you can cable up the disk drives. RAID Software is a set of kernel modules coupled together with management utilities that implement RAID in Software and require no additional hardware.
    Pros and cons
    Software RAID is more flexible than Hardware RAID. Software RAID is also considerably less expensive. On the other hand, a Software RAID system requires more CPU cycles and power to run well than a comparable Hardware RAID System. Also, because Software RAID operates on a partition by partition basis where a number of individual disk partitions are grouped together as opposed to Hardware RAID systems which generally group together entire disk drives, Software RAID tends be slightly more complicated to run. This is because it has more available configurations and options. An added benefit to the slightly more expensive Hardware RAID solution is that many Hardware RAID systems incorporate features that are specialized for optimizing the performance of your system.
    For more detailed information on the differences between Software RAID and Hardware RAID you may want to read: Hardware RAID vs. Software RAID: Which Implementation is Best for my Application?

Maybe you are looking for

  • Fixed format file!  to_char formatting!

    I'm tryint to create a simple fixed with output file. I am concatenating everything together but having problems when numeric values that are null. And SQL plus keeps putting a 1 space between each field. I'm using this SQL select to_char(p.county,'b

  • Oracle Assets Category-wise Report from FA and GL tables

    Hi, I am developing a customized report (Schedule of Fixed Assets) in the Oracle Assets Module, Which includes Category Wise Opening Balance, additions, adjustments, transfer IN, Transfer OUT and Retirements of Cost and Depreciations. I am using FA t

  • I installed Adobe Reader 9.20.  Docs have lines with black blocks. Help?

         I am not sure what to do.  I upgraded to the 9.20 and have had problems ever since.  I tried uninstalling all adobe products and reinstalling and am having the same problem.  Large portions of text in the documents are "blocked out" with a black

  • Invalid month error sometimes in SQL Developer

    Hi sometimes I get 'Invalid Month error' in SQL developer when I execute the following query select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual; But when I dosconnect session and reconnect, It works fine Any suggestions on how to avoid this

  • Opening mail in safari

    Hi, I am new to the MAC, in Safari when you close or delete an e-mail the next e-mail open is there a way to stop this action. I do not like the mail to open automatically, specially if there is an attachment next. Thank you.