Sunaina
BAN USERI m an intern doing my internship in Business Objects Software India Pvt. Ltd., Bangalore-Karnataka,India
- 0of 0 votes
AnswersGiven an input array of size unknown with all 1's in the beginning and 0's in the end. find the index in the array from where 0's start. consider there are millions of 1's and 0's in the array.i.e array is very big..e.g array contents 1111111.......1100000.........0000000
- Sunaina| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Algorithm
This particular problem is called finding maximum subsequence problem and is a very common problem in data structures and algorithms.
the best poosible solution to this could be something like as follows:-
int maxsubsequence(int a[],int N) /*returns 0 if all entries in the array are negative*/
{
int ThisSum=0;
int MaxSum = 0;
for(int j=0;j<N;j++)
{
ThisSum = ThisSum + A[j];
if(ThisSum > MaxSum)
MaxSum = ThisSum;
if(ThisSum <0)
ThisSum = 0;
}
return MaxSum;
}
Threads are a way for a program(process) to fork (or split) itself into two or more simultaneously (or pseudo-simultaneously) running tasks. The term Thread and process are used interchangeably but in general process is a bigger Aspect of a thread. In the sense that a thread is smaller part of excution of a program or process.
- Sunaina May 17, 2007"Little Endian" means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte LongInt
Byte3 Byte2 Byte1 Byte0
will be arranged in memory of a 16 bit machine as follows:
Base Address+0 Byte0 Byte1
Base Address+1 Byte2 Byte3
"Big Endian" means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as:
Base Address+0 Byte2 Byte3
Base Address+2 Byte0 Byte1
#include <stdio.h>
main()
{
int x=1234;
int Low_Addr = &x; //High_Addr = Low_Addr + 1
if((*Low_Addr) == 12)
Printf("Machine is Big Endian \n");
else
Printf("Machine is little Endian \n");
}
The reflected binary code, also known as Gray code after Frank Gray, is a binary
- Sunaina May 29, 2007for example gray code for 14 is 1001 and for 15 is 1000 they differ in only one digit i.e. for successive numbers 14 and 15 gray codes 1001 and 1000 differ by just 1 digit..similar is situation for any other two successive numbers