How to find out the maximum value of one array

hi all..
I have one array that consists of some elements
so I want the maximum value of the list ...
if anyone knows this please help me..
thanks..

>
If your array is already sorted, you can do a binary
search.
I think there are already methods to do that in
java.util.Arrays. (?)
If not, it's not hard to find an example on the net.
A binary search will be more efficient.1. If your array is already sorted, you do not need a binary search. Either check the value of arr[0] or arr[arr.length - 1] depending on the direction of sorting.
2. If your array is not sorted, try this:
int maxValue = arr[0];
for(int index = 1; index < arr.length; index++)
  if(arr[index] > maxValue)
    maxValue = arr[index];
}

Similar Messages

  • How to find out the maximum value

    Dear all,
    i have one query where in i have to calculate Excise Duty based on the  maximum  sales qantity of all materials with the corresponding sales value... i mean i wil get the maximum value of a individual material no matter how many sales has done.i wil pick up the maximum sales qty and the correspondig sales value....
    This im able to solve by taking the condition as TOP 1..
    Now my question is if the same material qty is sold with differnt value then i have to pick up the  Max value and as usual the sales qty..... plz help me out
    Material              Sales Qty              sales value
           3000                10 kl                   1000INR
           3200                15 kl                   1100 INR
           4000                20 kl                   1000INR
    in this case my query is picking up the max qty of  20 and the value 1000 INR as i had taken TOP 1 on Sales qty ....
    <b>
    But In the below example  for the same material i have to pick up the 3 rd row  where the sales value is maximum and the corresponding sales qty 10 kl</b>
    EX   Material        Sales Qty              sales value
           3000                10 kl                   1000INR
           3000                10 kl                   1100 INR
           3000                10 kl                   1500INR

    Hi,
    U can use the restrict option fo the Material characteristics  for sales value just drag and drop on columns >right click Properties> U have the option Calculated Result as Summation, Maximum, Minimum etc..just choose Maximum for ur case.

  • How to find out the maximum value in a Query within single material

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material which is having more that one transaction..
    EX:
    MATERIAL BILLED VALUE
    x with BILLED VALUE 100
    x with BILLED VALUE120
    y with BILLED VALUE 50
    y with  BILLED VALUE 80
    z with BILLED VALUE 50
    z with BILLED VALUE 60
    in a analyser i have to display X with billed value 120 that is max in X material and
    Y with billed value 80 that is max in Y material and
    Z with billed value 60 that is max in Z material
    In a query all the values are summing up. I.e for X its 220 and Y its 130 and Z its110 but we dont want to get total sum value we want individual values and the maximim of those values.......... 
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Venu,
    In your query try creating a formula, with the value of each record as the key figure in the formula.
    In the aggregation tab select maximum in the exception aggregation dropdown and then select material as the reference characteristic
    then when you include material in the rows it will only display the maximum value.
    cheers
    mark

  • How to find out the maximum value in a Query

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material..
    EX:
    MATERIAL BILLED VALUE
    x                   1000
    y                   3000
    z                   2500
    in a analyser i have to display only Y and 3000
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Hi Venu,
    You may wish to refer the link below:
    http://help.sap.com/saphelp_nw04/helpdata/en/17/82853c2dc5c505e10000000a11405a/content.htm
    Assign points if this is helpful.
    Regards,
    Anil

  • How to find out the maximum length of the characters specified within CLOB

    I have given a table which has a column with datatype CLOB . I want to find out the maximum legth of the string within this variable and also want to print that variable.
    Thanks for your help.

    SELECT
         MAX(DBMS_LOB.GETLENGTH(clob_column))
    FROM
         your_table

  • How to find out the ASCII Values for Spanish character

    Hi,
    I had an requirement to store Spanish character and also need to fileter the records based on the Spanish character.
    Kindly guide me for below.
    To filter the Records which contains spanish characters?
    To get the ASCII Values for the particular column?
    E.g. we can find out the ASCII value of 'a' by using the syntax select ASCII('a') from dual.
    But I want to find the ASCII Values for the particular column value. Ie. name.
    E.g., Client name is "Suresh", I want to the ASCII Values for entire name of "Suresh".
    Kindly do the needful help / Guidance on this.
    Thanks,
    Orahar

    To expand on what I said in my first post, you want to do something along these lines:
    with t (thename) as
      select 'Suresh' from dual
    select thename
         , substr(TheName, level, 1)
         , ascii(substr(thename, level))
      from t
    connect by level <= length(thename);The output of the above query is:
    THENAM S ASCII(SUBSTR(THENAME,LEVEL))
    Suresh S                           83
    Suresh u                          117
    Suresh r                          114
    Suresh e                          101
    Suresh s                          115
    Suresh h                          104
    6 rows selected.Note that the WITH statement is only there to simulate a table for this example. With a table, all you do is get rid of the with and substitute the name "t" for the name of your table (also the name of the column to whatever name the column has in your table).
    Lastly, I suggest you post your question along with, an example table and the output you'd like to get in the PL/SQL forum. There are people there that will give you all kinds of great ways of solving that problem.
    HTH,
    John.

  • How to find out the null values in table

    hi experts,
    my version is oracledb10g:
    i h'd simple doubts.
    for eg:
    create table ex1( e varchar2(20));
    insert into ex1 (null).
    insert into ex1(e)
    count will be: 2
    i can easily found out the value 'e'.
    so my question is:
    how can i found out the null values in the table and i want to delete the null values from the table.

    ADF 7 wrote:
    hi experts,
    my version is oracledb10g:
    i h'd simple doubts.
    for eg:
    create table ex1( e varchar2(20));
    insert into ex1 (null).
    insert into ex1(e)
    count will be: 2That depends what you count. If you issue count(*) you are asking Oracle "how many rows are there". If you issue a count(<column_name>) you are asking Oracle "how many not null values of <column_name> are there".
    ADF 7 wrote:
    i can easily found out the value 'e'.
    so my question is:
    how can i found out the null values in the table and i want to delete the null values from the table.
    delete from <table_name>
    where <column_name> is null;Ideally you'd just place a NOT NULL constraint on the column in question, thereby prohibiting NULL values from entering into the system (assuming your business requirement is that the column MUST always have a value).

  • How to find out the invoice value from a sales order

    Hi All,
    Please can any one hlpe to solve the beloq query.
    Is there any report in SAP , which give you the following.
    Sales order , Total cost incurred , Total revenue recoganised , Total Invoiced , Total collected .
    Thanks ,
    Rajesh

    Dear Waman,
    Thanks a lot for your replay ..
    But i don't have much knowldge about KE 30 report , is there any study meterial available online to configure this \ or study this report .

  • How to find out the max mem can be allocatedTT for 32 bit Win ?

    How to find out the maximum Permanent Data Size and Temporary Data Size that can be allocated for the Oracle Times Ten for 32 bit Windows OS.

    Hi Chris,
    Am I write in saying that this also depends on shared memory setting as well?
    If that is the case, on a platform like window 2003 32-bit, one cannot have more than 4GB of shared memory. Windows Server 2003 includes support for a startup switch (entered in the boot.ini file) that allows the allocation of memory and memory address space. Regardless of the amount of physical memory that is installed on the system, the operating system uses a virtual address space of 4 GB. Out of that amount, by default, 2 GB is allocated to user-mode processes (for example, Oracle or TimesTen) and 2 GB is allocated to kernel-mode processes (for example the operating system and others). In a nutshell on systems that have more than 1 GB of RAM, this startup switch can be used to allocate more memory to applications (3 GB) and less memory to the operating system (1 GB). However, adding adding the /3GB switch to the boot.ini file will not increase the amount of physical RAM memory, the 3GB switch just tells the computer to allocate the existing memory space differently.
    For a 32-bit TimesTen the limit on memory cannot be more than 2GB (PermSize+TempSize). For example on Linux 32-bit I have 1024MB and 512MB for these two parameters.
    Thanks,
    Mich

  • How to find out the amount assigned to WBS element

    Hello Friends,
    Will you please inform how to find out the (amount/value/budget) assigned
    to WBS element
    Which Table it is stored in?
    Thanks in Advance
    Bset Regards
    Diwakar

    Hi Diwakarnd,
    You can use any of the following reports to get the information you require.
    1. <b>S_ALR_87013557</b> - Budget/Actual/Variance
    2. <b>S_ALR_87013558</b> - Budget/Actual/Commitment/Rem Plan/Assigned
    3. <b>S_ALR_87013559</b> - Budget/Distributed/Plan/Distributed
    Some of these reports use a complex selection criteria from various tables which has been grouped together, logically by SAP. The Logical Database table name for PS is <b>PSJ</b>.
    Execute transaction code <b>SE36</b> -> <b>PSJ</b> -> (Subobject : Radio button <b>Structure)</b> -> Click on <b>Display</b>.
    You would see all the underlining tables used.
    I hope the above helps.
    Do not forget to award the points please.
    Regards,
    Jacob

  • How to find out the max/min value of one field corresponding to a second field in HANA through graphical way.

    Hi,
    I am trying to find out the latest delivery date(EINDT)  for each purchasing document (EBELN) through graphical way.
    The view contains other fields apart from the above mentioned two fields.
    When only the two fields (EBELN, EINDT) are there, then in semantics, I can select 'Max' as aggregation to get the maximum value for each document.
    If I do like this, then I need to join more than 3 views and also so many joins in calculation view. Taking so much time for data preview.
    Hence , please help me in getting the solution while the view contains other fields also.
    Thanks in advance.
    Thanks,
    Jyothirmayi

    Hi Sreehari/Vinoth,
    Thank you for your replies.
    if only two fields are then I can get the max/min values of one field corresponding to other field.
    But more than two fields are there with different values, then let me know how to find out the max/min value of a particular filed corresponding to the 2nd field with other fields also should be in the output.
    I hope you understood my issue.Please revert in case of questions.
    Thanks & Regards,
    Jyothirmayi

  • How to find out the structure stored field  value in a standard program

    Hi Gurus,
    Please suggest me how to find out the structure field stores the value in which table.
    Exanple : i have a strutured field in T.code cj31 is BPDY-WERT1 and it is stotring value 10,000,000.00. know i need to find out in which table this value is storing .
    Please suggest me its urgent.
    Thanks in Adavance!!!
    Points will be rewarded.......
    Regards,
    Kranthi

    hi,
       Go to transaction ST05,Click activate trace with filter,Give the transactio name as cj31,Go to the transaction and navigate to the place where the particular field is present, then again go to st05 ,Deactivate the trace and display the trace.
    Now u can see how the data is fetched ,U can even go to display mode of the same transaction cj33
    Thanks
    San

  • How we can find out the default value of the initialization parameters

    Hi All,
    How we can find out the default value of the initilization parameters from oracle database.
    Thanks
    Shiju

    Hi,
    you can find currently used parameter values v$parameter and v$parameter2.
    if default values is different real values then you can see alert.log.
    because in alert.log you will see non default values, rests is default.
    Edited by: admin on May 8, 2010 3:41 AM

  • How find out the duplicate value from each columns.

    I have below four columns,
    How can i find out the duplicate value from each columns.
    with All_files as (
    select '1000' as INVOICE,'2000' AS DELIVERYNOTE,'3000' CANDELINVOICE,'4000' CANDELIVERYNOTE from dual union all
    select '5000','6000','7000','8000' from dual union all
    select '9000','1000','1100','1200' from dual union all
    select '1200','3400','6700','8790' from dual union all
    select '1000','2000','3000','9000' from dual union all
    select '1230','2340','3450','4560' from dual
    SELECT * FROM All_files
    Output should be as per below.
    1000 2000 3000 4000
    9000 1000 1100 1200
    1200 3400 6700 8790
    1000 2000 3000 9000
    Required to check uniqueness in cross columns.
    Thanks.

    Try this (sorry about the formatting)...
    WITH all_files AS (SELECT   '1000' AS INVOICE,
                                '2000' AS DELIVERYNOTE,
                                '3000' CANDELINVOICE,
                                '4000' CANDELIVERYNOTE
                         FROM   DUAL
                       UNION ALL
                       SELECT   '5000',
                                '6000',
                                '7000',
                                '8000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '9000',
                                '1000',
                                '1100',
                                '1200'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1200',
                                '3400',
                                '6700',
                                '8790'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1000',
                                '2000',
                                '3000',
                                '9000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1230',
                                '2340',
                                '3450',
                                '4560'
                         FROM   DUAL),
        t_base
           AS (SELECT      invoice
                        || ','
                        || deliverynote
                        || ','
                        || candelinvoice
                        || ','
                        || candeliverynote
                           str
                 FROM   all_files),
        t_str
           AS (SELECT   str || ',' AS str,
                        (LENGTH (str) - LENGTH (REPLACE (str, ','))) + 1
                           AS no_of_elements
                 FROM   t_base),
        t_n_rows
           AS (    SELECT   LEVEL AS i
                     FROM   DUAL
               CONNECT BY   LEVEL <=
                               (    SELECT   SUM (no_of_elements) FROM t_str)),
        t_build AS (SELECT   t_str.str,
                             nt.i AS element_no,
                             INSTR (t_str.str,
                                    DECODE (nt.i, 1, 0, 1),
                                    DECODE (nt.i, 1, 1, nt.i - 1))
                             + 1
                                AS start_pos,
                             INSTR (t_str.str,
                                    1,
                                    DECODE (nt.i, 1, 1, nt.i))
                                AS next_pos
                      FROM      t_str
                             JOIN
                                t_n_rows nt
                             ON nt.i <= t_str.no_of_elements),
        t_build2
           AS (SELECT   RTRIM (str, ',') AS original_string,
                        SUBSTR (str, start_pos, (next_pos - start_pos))
                           AS single_element,
                        element_no
                 FROM   t_build),
        t_build3
           AS (SELECT   single_element,
                        COUNT( * )
                           OVER (PARTITION BY single_element
                                 ORDER BY single_element)
                           ele_count
                 FROM   t_build2)
    SELECT   DISTINCT INVOICE,
                      DELIVERYNOTE,
                      CANDELINVOICE,
                      CANDELIVERYNOTE
      FROM   all_files, t_build3
    WHERE   ele_count > 1
             AND (   INVOICE = single_element
                  OR DELIVERYNOTE = single_element
                  OR CANDELINVOICE = single_element
                  OR CANDELIVERYNOTE = single_element)I think this will be faster than the previous solution?
    Cheers
    Ben
    Edited by: Munky on Feb 17, 2011 2:11 PM - "I think this will be faster than the previous solution?", nope - it's not :(

  • How to find out the total, subtotal in alv report

    hi dears,
    how to find out the total, subtotal in alv report?
    pls tell me logic ,
    i will be waiting for eply
    regards
    eswar

    Hi,
    <b>ALV Grid List with sub-totals</b>
    REPORT z_demo_alv_sort.
    * This program lists orders (VBAK) with sort and sub-total for        *
    * 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG)            *
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
    *      Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
    *      Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    ***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
    Regards
    Sudheer

Maybe you are looking for