# Recent questions tagged arrays 1 vote
1
Let $A$ be an array of $31$ numbers consisting of a sequence of $0$’s followed by a sequence of $1$’s. The problem is to find the smallest index $i$ such that $A[i]$ is $1$ by probing the minimum number of locations in $A$. The worst case number of probes performed by an optimal algorithm is $2$ $4$ $3$ $5$
2
If $x$ is a one dimensional array, then $^*(x+i)$ is same as $^*(\&x[i])$ $\&x[i]$ is same as $x+i-1$ $^*(x+i)$ is same as $^*x[i]$ $^*(x+i)$ is same as $^*x+i$
3
Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in a sorted array ? Insertion - $0(1)$, Deletion - $0(1)$, Maximum - $0(1)$, Minimum - $0(1)$ Insertion - $0(1)$, Deletion - $0(1)$, Maximum - $0(n)$, Minimum - $0(n)$ ... , Maximum - $0(1)$, Minimum - $0(1)$ Insertion - $0(n)$, Deletion - $0(n)$, Maximum - $0(n)$, Minimum - $0(n)$
4
Consider a $2$-dimensional array $x$ with $10$ rows and $4$ columns, with each element storing a value equivalent to the product of row number and column number. The array is stored in row-major format. If the first element $x$ occupies the memory location with ... location, which all locations (in decimal) will be holding a value of $10$? $1018,1019$ $1022,1041$ $1013,1014$ $1000,1399$
5
What is the output of the code given below? # include<stdio.h> int main() { char name[]="satellites"; int len; int size; len= strlen(name); size = sizeof(name); printf("%d",len*size); return 0; } $100$ $110$ $40$ $44$
1 vote
6
Given an array of ( both positive and negative ) integers, $a_0,a_1,….a_{n-1}$ and $l, 1<l<n$. Design a linear time algorithm to compute the maximum product subarray, whose length is atmost $l$.
7
.Given an array of distinct integers A[1, 2,…n]. Find the tightest upper bound to check the existence of any index i for which A[i]=i. Ans should be O(log n) right by doing binary search ??
8
i write this program, during initialization of array i given the size as 11 means the number of elements stored in an array is 11. as we know array is not assigned a value of index 12 and above. but in in the program array a is initialized of index from 0 to 19,my question is how the array is initialized with 20 ... ; for(i=0;i<20;i++) { a[i]=i+1; } for(i=0;i<20;i++) { printf("%d\n",a[i]); } }
9
An OS uses virtual memory with paging technique for memory allocation. Which of the following searching technique on given data structure use locality of reference? Linear search on linked list Binary search on array Linear search on array Binary search on linked list
10
A Sorted array of n elements contains 0 and 1 to find out majority of 0 and 1.How much time it will take??? and please explain Meaning -majority of 0 and 1??
1 vote
11
Tell me the difference : &(arr+1) and &arr+1
12
Q.Consider a 2 dimensional array A[40 ... 95, 40 ... 95] in lower triangular matrix representation. If the array is implemented in the memory in the form of row major order and base address of the array is 1000, then the address of A will be ________.
13
14
A two dimensional array is stored in column major form in memory if the elements are stored in the following sequence ... can be calculated as the column number of the element we are looking for summing with the $row \times column$ number of elements. How does the above recurrence relation work?
15
someone please explain this: how does a+1 differs from &a+1 in above code? detailed explanation would be of great help as they incremented &a by 6 and NOT 1
16
what will be the three address code for x=A[i][j] Given A[M][N] and w is word size; t1=i*N; t2=t1+j; t3=t2*w; t4=base address of array A[M][N] t5=t4+t3; x=t5; My doubt here: Is there any need of t4 variable for storing the base address of arrary or we can directly do it as t4=A[t3]; x=t4;
17
Suppose we have an array with base address 2000. Each element of the array occupies 2 bytes. And we want to fetch the first 8 bits of the first element of the array. What will it return? More precisely I want to know what is stored in memory location 2000 to 2001 are stored in binary in the array? 400 401 402 403 404
18
if array declared size is larger than values initialised. Then what value rest memory elements have , 0 or garbage?
19
A)20,60 B)20,10 C)10,60 D)Garbage Value
1 vote
20
main(){ int S = {126,256,512,1024,2048,4096}; int *x=(int *) (&S+1); printf (“%d”,x); } int is 4 bytes; array starts from 2000 . The answer is 2024 I am getting 2004. Please explain the concept. If possible provide a resource.
1 vote
21
Given a 2D array A[40….95, 40...95] in lower triangular representation, size of each element is 1 Byte Array implemented in row major order, base address is 1000 Address of A ?
22
23
This question is in CLRS,if we have a max heap it is always in sorted order(descending) order.And by extension if we have min heap the array is sorted in ascending order.Is this true? I have a counter example for 100,50,20,1,3,10,5,this satisfied max- ... it as an array is it an heapified representation or not? If we heapify after deletion and store max deleted element then we get sorted array.
24
Consider a 2 dimensional array A[40 ..... 95, 40 ..... 95] in lower triangular matrix representation. The size of each element in the array is 1 byte. If the array is implemented in the memory in the form of row major order and base address of the array is 1000, the address of A  will be ________.
25
What does it mean when they say "An array A[1...n] consists of a permutation of numbers 1....n.".? Also I'd be grateful if you give some example.
26
A is a 2D-array with the range [-5....5,3......13] of elements.The starting location is 100. each element accupies 2 memeory cells. Calculate the location of A using column major order and row major order.Does indexing matter??Why C follow $0$ indexing??
27
Predict the value returned by the function MyFunc(). int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i< size; i++) Y = Y + E[i]; for(i=0; i < size; i++) for(j = i; j < size; j++) { Z = 0; for(k = i; k ... of arr $B)$ The maximum element in any sub-array of arr $C)$ Sum of the maximum element in all sub-arrays of array arr $D)$ Sum of all the elements in the array arr
Let arr[] be an array containing n integers. The following algorithm computes the frequency of each element in arr and stores it in another array fre[]. for(i=0;i<n;i++) { count=1; for(j=i+1;j<n;j++) { if(c) { count++; fre[j]=0; } } if(fre[i]!=0) { fre[i]=count; } } Choose the correct expression for C $A) arr[i]<=arr[j]$ $B) arr[i]>=arr[j]$ $C) arr[i]!=arr[j]$ $D) arr[i]==arr[j]$