Question about Computers & Internet

# Binary search example program in finding a value in multidimensional array in binary search

Posted by on

• Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that gotÂ 5 achievements.

Novelist:

An expert who has written 50 answers of more than 400 characters.

Scholar:

An expert who has written 20 answers of more than 400 characters.

• Expert

Here's a nice article with some examples.

http://www.tbray.org/ongoing/When/200x/2003/03/22/Binary

And another - examples at the end of long boring explanations:

http://en.wikipedia.org/wiki/Binary_search

If you still have problems, tell me what language you're using.

Posted on Jul 18, 2008

## 1 Suggested Answer

Hi,
A 6ya expert can help you resolve that issue over the phone in a minute or two.
Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
The service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
Good luck!

Posted on Jan 02, 2017

×

my-video-file.mp4

Complete. Click "Add" to insert your video.

×

## Related Questions:

### How to change a decimal value to binary number in fx-85GT PLUS ? Thanks!!

Let's do the preocess so it will work on any calculator.

As an example, convert 68 from decimal to binary.

The decimal columns are 10^0, 10^1, 10^2, 10^3, etc.

The binary columns are 2^0, 2^1, 2^2, 2^3, etc.

Flipping to the normal left to right, we get 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0.

64 32 16 8 4 2 1

We divide our number, 68, by 64, and get 1 with a remainder of 4. We next divide our remainder by 32, 16, 8, and finally 4, where we get 1 with no reminder.

In binary, this works out to 1000100. To check, we multiply the ones by the respective column values and get 64 + 4 = 68.

Good luck.

Paul

Feb 28, 2016 | Casio FX-85GT Plus Scientific Calculator...

### Write a program c that declares an array of 100 elements to hold these values. Read the values in from the file and store them in successive elements of the array. Keep track of how many numbers are read...

That appears to be an intermediate question in a programming class. Best read the book, the answer is not what is important the process of getting the answer is what you are trying to learn.

May 17, 2017 | Office Equipment & Supplies

### How to convert binary with point to decimal

1) Look at the following numbers before trying to convert binary to decimal. Each of them represent the value in a binary number from left to right.
128-64-32-16-8-4-2-1

2) Look at your binary number, for this example lets use 10010010. For each one add the corresponding number from step 1, the number you come out with is the conversion.

So: 10010010 -> 128+16+2 -> 146
10010010 = 146

Jul 03, 2011 | Office Equipment & Supplies

### Declare 2 arrays with 5 as index value of each. the user will input values to the first array(user-defined). Transfer value of the first array to the second array.Get the sum of the second...

You could do this by creating two arrays as such:
int firstArray[5]; int secondArray[5]
and then the sum variable:
int sum = 0;
then you could do a for loop to find the sum of the second array:

Feb 22, 2011 | Microsoft Visual C++ Professional Edition...

### Hwo can i solved a bineary search problam in c++

first arrange your array in ascending order.and keep the two variables one for starting index and one for last index
then check your number with center(center = (first index + last index))/2 element of array.
if it is lager then center element then set first index = center,
if smaller then last index = center
else you got the number..

Jul 25, 2010 | Borland Turbo C++ Suite 1.0...

### C++ poker program

Hi.

I suggest creating an Array of Cards (cardOne,cardTwo,etc. to five)

If you can enter them in one at a time, after declaring the array, assign the values to the array.

cin < cardOne; (Psuedo code by the way, hope you don't mind)

Afterwards, you'll have an array with 5 cards.

Declare what full houses, flushes, etc would require.
Use an if statement (If you don't mind lots of code) to compare the entered Array against possible hands.

I didn't necessarily give you any specific C++ code. However, if you Google C++ user input, you should find plenty of commands that may help you.

Good Luck

(And not sure about Linear search to be honest, you can use a Linear search, but if you did it the way I explained, you just have to compare hand to a series of conditionals.)

Sep 23, 2009 | Computers & Internet

### Visual basic program for binary search technique

This sounds like "homework".

A binary-search requires an "ordered" table of values.
Sort your values into the proper order.

LET TOP=1; * Point to first element in the table.
LET BOT=1000; * Point to the *LAST* item in the table.

LOOPHERE:

LET BINARY = 2;

LET MIDDLE=FLOOR((TOP+BOT)/BINARY);

IF VALUE(MIDDLE) = KEY THEN STOP;

IF KEY < VALUE(MIDDLE)
THEN TOP = MIDDLE;
ELSE BOTTOM = MIDDLE;

IF TOP = BOTTOM THEN STOP;

GOTO LOOPHERE;

END;

Mar 08, 2009 | Microsoft Windows Vista Home Premium with...

### Please Solve this C++ Program

Write a program to prompt the user to input several lines of input. A line of inputs is terminated by '*'. For each readline of input the program should output:(use pointer notation for the array) . The total # of words . The lenght of the longest word in the line At the end the program should output: . The total number of words read in all lines of input . The lenght of the longest word read in all lines of input

Jan 19, 2009 | Computers & Internet

### C++ programs

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier
Initializing arrays. When declaring a regular array of local scope (within a function, for example), if we do not specify otherwise, its elements will not be initialized to any value by default, so their content will be undetermined until we store some value in them. The elements of global and static arrays, on the other hand, are automatically initialized with their default values, which for all fundamental types this means they are filled with zeros
include <iostream>
using namespace std;

int billy [] = {16, 2, 77, 40, 12071};
int n, result=0;

int main ()
{
for ( n=0 ; n<5 ; n++ )
{
result += billy[n];
}
cout << result;
return 0;
}
multidimensional array pseudo-multidimensional array #define WIDTH 5 #define HEIGHT 3 int jimmy [HEIGHT][WIDTH]; int n,m; int main () { for (n=0;n<HEIGHT;n++) for (m=0;m<WIDTH;m++) { jimmy[n][m]=(n+1)*(m+1); } return 0; } #define WIDTH 5 #define HEIGHT 3 int jimmy [HEIGHT * WIDTH]; int n,m; int main () { for (n=0;n<HEIGHT;n++) for (m=0;m<WIDTH;m++) { jimmy[n*WIDTH+m]=(n+1)*(m+1); } return 0; }
and now for trignometry
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
int factorial(int);
int n = 3, i = 1;
double x, x2, b, PI, r;
char choice;
//r = x * (PI / 180)

cout<<"Please enter an angle value => ";
cin>>x;
cout<<"Is the angle value in Degree or Radian?"<<endl;
cout<<"Type D if its in degree "<<endl;
cout<<"Type R if its in radian "<<endl;
cin>>choice;

if((choice = 'R')||(choice = 'r'))
do{
i++; n = 3; x2 = 0; b = x2;
{
if(i == 1)
x2 = x - (pow(x,n) /factorial(n));
n = n + 2;
};
else
{
x2 = (x2 + ((pow(x,n)) /(factorial(n))) - (pow(x,n+2)) / (factorial(n+2)));
n = n + 4;
}

}while(abs(b - x2) > 0.000001);
else
//convert it to r

r = x * PI /180;

//cout<<"error occured/n";
cout<<"sin(x) = "<<x2<<endl;

return 0;
}

Mar 24, 2008 | ArcMedia JavaScript Source Code 3000 Pro...

## Open Questions:

#### Related Topics:

65 people viewed this question

## Ask a Question

Usually answered in minutes!

Level 3 Expert

Level 3 Expert