search
Log In

Recent questions tagged arrays

1 vote
1 answer
1
Let $A$ be a square matrix of size $n\times n$. Consider the following program. What is the expected output? C=100 for i=1 to n do for j=1 to n do { Temp=A[i][j]+C A[i][j]=A[j][i] A[j][i]=Temp-C } for i=1 to n do for j=1 to n ... ]); The matrix $A$ itself. Transpose of matrix $A$. Adding $100$ to the upper diagonal elements and subtracting $100$ from diagonal elements of $A$. None of the option.
asked Mar 30 in DS Lakshman Patel RJIT 67 views
1 vote
2 answers
2
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$
asked Mar 30 in Algorithms Lakshman Patel RJIT 69 views
0 votes
2 answers
3
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$
asked Mar 30 in Programming Lakshman Patel RJIT 143 views
0 votes
5 answers
4
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)$
asked Mar 24 in Algorithms jothee 115 views
3 votes
5 answers
5
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[0][0]$ 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$
asked Jan 13 in DS Satbir 1.1k views
4 votes
3 answers
6
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$
asked Jan 13 in Programming Satbir 548 views
1 vote
1 answer
7
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$.
asked Aug 27, 2019 in Algorithms Shaik Masthan 425 views
2 votes
1 answer
8
.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 ??
asked May 21, 2019 in Algorithms Hirak 327 views
0 votes
2 answers
9
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]); } }
asked Apr 7, 2019 in Programming shiva0 248 views
0 votes
0 answers
10
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
asked Mar 2, 2019 in Programming srestha 257 views
0 votes
1 answer
11
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??
asked Feb 19, 2019 in DS sandeep singh gaur 210 views
1 vote
2 answers
12
Tell me the difference : &(arr+1) and &arr+1
asked Feb 17, 2019 in Programming Ahsanul Hoque 382 views
2 votes
0 answers
13
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[66][50] will be ________.
asked Jan 27, 2019 in Programming Badayayash 222 views
0 votes
0 answers
14
asked Jan 22, 2019 in Algorithms bts1jimin 68 views
0 votes
0 answers
15
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?
asked Jan 7, 2019 in DS kauray 172 views
3 votes
0 answers
16
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
asked Dec 22, 2018 in Programming Markzuck 436 views
0 votes
0 answers
17
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;
asked Dec 22, 2018 in Compiler Design Shivam Kasat 115 views
0 votes
1 answer
18
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
asked Dec 19, 2018 in DS Sweta Shaw 205 views
0 votes
1 answer
19
if array declared size is larger than values initialised. Then what value rest memory elements have , 0 or garbage?
asked Dec 17, 2018 in Programming bunty choudhary 87 views
0 votes
0 answers
20
1 vote
2 answers
21
main(){ int S[6] = {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.
asked Dec 11, 2018 in Programming Shamim Ahmed 243 views
1 vote
1 answer
22
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[66][50] ?
asked Dec 11, 2018 in DS Shamim Ahmed 173 views
0 votes
0 answers
23
0 votes
0 answers
24
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.
asked Nov 15, 2018 in DS sripo 563 views
0 votes
1 answer
25
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[66] [50] will be ________.
asked Nov 1, 2018 in DS Ankish Gupta 3 236 views
0 votes
2 answers
26
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.
asked Nov 1, 2018 in Numerical Ability Mizuki 169 views
0 votes
1 answer
27
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[0][8] using column major order and row major order.Does indexing matter??Why C follow $0$ indexing??
asked Oct 22, 2018 in Programming Lakshman Patel RJIT 331 views
0 votes
0 answers
28
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
asked Oct 22, 2018 in Programming Lakshman Patel RJIT 77 views
...