search
Log In

Recent questions tagged arrays

1 vote
1 answer
1
Suppose you are compiling on a machine with $1$-byte chars, $2$-byte shorts, $4$-byte ints, and $8$-byte doubles, and with alignment rules that require the address of every primitive data element to be an integer multiple of the element's size. Suppose further that the compiler is not ... ; double r; int i; } A[10]; /*10 element array of structs */ $150$ bytes $320$ bytes $240$ bytes $200$ bytes
asked Nov 20, 2020 in Programming and DS jothee 132 views
0 votes
2 answers
2
An element in an array $X$ is called a leader if it is greater than all elements to the right of it in $X$. The best algorithm to find all leaders in an array solves it in linear time using a left to right pass of the array solves in linear time using a right to left pass of the array solves it using divide and conquer in time $\theta (n\log n)$ solves it in time $\theta (n^{2})$
asked Apr 2, 2020 in Algorithms Lakshman Patel RJIT 181 views
2 votes
1 answer
3
To sort many large objects or structures, it would be most efficient to place them in an array and sort the array pointers to them in an array and sort the array them in a linked list and sort the linked list references to them in an array and sort the array
asked Apr 2, 2020 in DS Lakshman Patel RJIT 328 views
1 vote
2 answers
4
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, 2020 in DS Lakshman Patel RJIT 351 views
0 votes
3 answers
5
Kadane algorithm is used to find Maximum sum subsequence in an array Maximum sum subarray in an array Maximum product subsequence in an array Maximum product subarray in an array
asked Mar 30, 2020 in DS Lakshman Patel RJIT 269 views
1 vote
2 answers
6
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, 2020 in Algorithms Lakshman Patel RJIT 337 views
0 votes
5 answers
7
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, 2020 in Algorithms jothee 1.1k views
3 votes
5 answers
8
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, 2020 in DS Satbir 2.2k views
4 votes
4 answers
9
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, 2020 in Programming Satbir 853 views
1 vote
1 answer
10
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 540 views
2 votes
1 answer
11
.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 462 views
0 votes
2 answers
12
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 303 views
1 vote
0 answers
13
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 401 views
0 votes
1 answer
14
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 443 views
1 vote
2 answers
15
Tell me the difference : &(arr+1) and &arr+1
asked Feb 17, 2019 in Programming Ahsanul Hoque 539 views
2 votes
0 answers
16
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 297 views
0 votes
0 answers
17
asked Jan 22, 2019 in Algorithms bts1jimin 87 views
0 votes
0 answers
18
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 216 views
3 votes
0 answers
19
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 566 views
0 votes
0 answers
20
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 169 views
0 votes
1 answer
21
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 255 views
0 votes
1 answer
22
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 112 views
2 votes
2 answers
24
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 309 views
1 vote
1 answer
25
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 236 views
0 votes
0 answers
26
0 votes
0 answers
27
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 929 views
...