Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Binary search -Java achieve     - Oracle 11g creates virtual private directory RMAN-06004 ORA-00942 error handling (Database)

- MySQL and Oracle time zone settings compare (Database)

- Upgrade Goldengate to (Database)

- Oracle 10g in the unique and index problems (Database)

- Nginx Load Balancing (standby) + Keepalived (Server)

- Java memory-mapped file MappedByteBuffer (Programming)

- JavaScript file loader LABjs API Explanation (Programming)

- mysql_config_editor encryption and decryption of the new features of MySQL realization (Database)

- The execution order of Oracle WHERE condition is not from right to left (Database)

- Linux Operating System Security Management describes the top ten tricks (Linux)

- Modify MySQL character encoding under Linux (Database)

- How to use the command line ftp upload and download files (Linux)

- How to use GRUB2 files directly from the hard disk to run ISO (Linux)

- Linux system firewall defense network attacks (Linux)

- 29 practical examples Linux system / network administrator of nmap (Linux)

- impdp error ORA-31631, ORA-39122 (Database)

- Under Linux using Magent + Memcached cache server cluster deployment (Server)

- Snort build a secure Linux server (Linux)

- VirtualBox - Linux system virtual machine shared folders (Linux)

- Debian 7.8 system installation and configuration process (Linux)

  Binary search -Java achieve
  Add Date : 2018-11-21      
  Binary search is for a small to an array of large sorted to find a number val, first comparison to be looking for the number of val and intermediate value, if greater than the median, then in the middle right of the value to find; if the ratio of the median small , then the median left to find. It has been recursion. You know where to find val. If not found, then the output sequence there is no relevant data.

package com.PengRong.A;

public class BinaryFind {

    public static void main (String [] args) {
        // TODO Auto-generated method stub
        int [] arr = {1, 5, 9, 56, 78, 80, 85, 99}; // Note that the array needs from small to large sorted.
        // If more data needs to be sorted by the sorting algorithm can use binary search Hair
        BinFind binfin = new BinFind ();
        binfin.binaryFind (0, arr.length-1, 85, arr);

class BinFind
    / **
    * @param Left left array subscript
    * @param Right and an array subscript
    * @param Arr an array reference
    * @param Val to be looking for a few
    * @ Functions: a bunch of numbers to find whether there val number, call the binary search method provided that this is an orderly sequence arr
    * /
    public void binaryFind (int left, int right, int val, int [] arr)
        // Binary search is actually through the array must be such that no more than the right of the left subscript subscript
        if (left < = right)
            // Find the middle number
            int pivot = arr [(left + right) / 2];
            // If you're looking for the number is smaller than the median in the middle of the left to find value
            if (val < pivot)
                binaryFind (left, (left + right) / 2-1, val, arr);
            } Else if (val> pivot)
                // If you are looking for a number greater than the median in the middle right of the value to find
                binaryFind ((left + right) / 2 +1, right, val, arr);
            } Else if (val == pivot)
                System.out.println ( "found in the array sequence" + val + "this number, its index is:" + ((left + right) / 2));
            System.out.println ( "I'm sorry the number you are looking for is not in the array sequence");


- Exploring the Android Listview display confusion (Programming)
- Ubuntu 14.04 LTS to compile the source code Android4.4.2 (Linux)
- Getting Started with Linux system to learn: how to install USB webcams come in raspberry (Linux)
- MySQL5.6.17 compiler installation under CentOS (Database)
- Linux protobuf-c (Linux)
- Linux Network Programming - raw socket programming (Programming)
- OpenGL Programming Guide (8th edition of the original book) - compute shader (Programming)
- Fedora 20 Installation and Configuration (Linux)
- C ++ based socket communication TCP and UDP (Programming)
- MySQL uses mysqld_multi to deploy stand-alone multi-instance detail procedures (Database)
- Zookeeper cluster deployment (Server)
- Ubuntu install Wireshark (Linux)
- Oracle 11g partition maintenance (two) - Coalescing Partitions (Database)
- CentOS 6.5 configuration SSDB 1.8.0 (Server)
- Unable to solve the official version of Android Studio online update problem (Linux)
- Java memory analysis tool uses detailed MAT (Programming)
- Emacs install clojure development environment (Linux)
- Create the container and run the application Docker (Server)
- apt-get install openstack pkg Troubleshooting (Linux)
- CentOS7 compile and install Tengine + PHP + MariaDB notes (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.