search
Log In

Recent questions and answers in Programming

24 votes
9 answers
1
Aliasing in the context of programming languages refers to multiple variables having the same memory location multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable
answered Oct 18 in Programming Pmona 4.8k views
3 votes
1 answer
2
Consider the following program fragment: int d = 0; int i,j,k; for(i=1; i<31; ++i) for(j=1; j<31; ++j) for(k=1; k<31; ++k) if(((i+j+k)%3) == 0) d=d+1; printf("%d",d); The number of additions performed by the above program fragment is? a. 27,000 b. 27,000 x 3 c. 27,000 x 3 + 9,000 d. 9,930 + 2,700 x 3
answered Oct 16 in Programming arun yadav 442 views
1 vote
3 answers
3
1 vote
2 answers
4
Consider the following program segment int main ( ) { char ∗ str = “GATECS”; printf (“%d”, madeeasy (str)); return 0; } int madeeasy (int ∗ p1) { int ∗ p2 = p1; while (∗++p1); return (p1 – p2); } The output of the above program will be ______. Assume that the object of data type int occupies 2 bytes
answered Oct 15 in Programming arun yadav 344 views
45 votes
8 answers
5
Consider the following pseudo code, where $x$ and $y$ are positive integers. begin q := 0 r := x while r ≥ y do begin r := r - y q := q + 1 end end The post condition that needs to be satisfied after the program terminates is $\{ r = qx + y \wedge r < y\}$ $\{ x = qy + r \wedge r < y\}$ $\{ y = qx + r \wedge 0 < r < y\}$ $\{ q + 1 < r - y \wedge y > 0\}$
answered Oct 13 in Programming Musa 6.5k views
15 votes
8 answers
6
1)The number of min heap trees are possible with 15 elements such that every leaf node must be greater than all non-leaf nodes of the tree are ________. -------------------------------------------------------------------------------------------------------------------------- 2)The number of min heap trees are possible with 15 elements_________________
answered Oct 6 in Programming Shashank Rustagi 2.1k views
3 votes
1 answer
7
In the following procedure Integer procedure P(X,Y); Integer X,Y; value x; begin K=5; L=8; P=x+y; end $X$ is called by value and $Y$ is called by name. If the procedure were invoked by the following program fragment K=0; L=0; Z=P(K,L); then the value of $Z$ will be set equal to $5$ $8$ $13$ $0$
answered Sep 26 in Programming VIDYADHAR SHELKE 1 568 views
0 votes
2 answers
8
What is difference between $pop\left ( \right )$,$empty Stack\left ( \right )$,$delete Stack\left ( \right )$? Can all be performed in $O\left ( 1 \right )$ time?
answered Sep 26 in Programming arun yadav 196 views
0 votes
3 answers
9
Runtime stack doesnot contain (A) Local variables (B) Static Variables (C) Parameter Passed (D) Return Address
answered Sep 25 in Programming arun yadav 270 views
1 vote
6 answers
10
39 votes
4 answers
11
double foo(int n) { int i; double sum; if(n == 0) { return 1.0; } else { sum = 0.0; for(i = 0; i < n; i++) { sum += foo(i); } return sum; } } The space complexity of the above code is? $O(1)$ $O(n)$ $O(n!)$ $n^n$
answered Sep 22 in Programming Amcodes 8.6k views
1 vote
1 answer
12
Narendra is traveling from point A to point B and there are n toll posts along the way. Before starting the journey, Narendra is given, for each post 1 ≤ i < j ≤ n, the feeto travel from post i to post j. The goal is to minimize the travel cost. The most ... . The answer is given to be (C). Is it like this has been solved using Dijkstra using fibonacci heaps? Am I thinking in correct direction?
answered Sep 19 in Programming pranshu27 52 views
34 votes
5 answers
13
The function f is defined as follows: int f (int n) { if (n <= 1) return 1; else if (n % 2 == 0) return f(n/2); else return f(3n - 1); } Assuming that arbitrarily large integers can be passed as a parameter to the function, consider the following statements. The ... different values of $n \geq 1$. Which one of the following options is true of the above? i and iii i and iv ii and iii ii and iv
answered Sep 18 in Programming Jainsuyash 4.6k views
2 votes
3 answers
14
Following declaration of an array of struct, assumes size of byte, short, int and long are $1,2,3$ and $4$ respectively. Alignment rule stipulates that $n$ - byte field must be located at an address divisible by $n$, the fields in the struct are not rearranged, padding is used to ensure ... $8$, what is the total size of $C$, in bytes? $150$ $160$ $200$ $240$
answered Sep 17 in Programming shivam001 482 views
0 votes
2 answers
15
Output of following program? #include<stdio.h> int main() { int *ptr; int x; ptr=&x; *ptr=0; printf("x=%d\n",x); printf("*ptr=%d\n",*ptr); *ptr+=5; printf("x=%d\n",x); printf("*ptr=%d\n",*ptr); (*ptr)++; printf( x=%d\n",x); printf("*ptr=%d\n",*ptr); return 0; } $x=0$ $^*ptr=0$ ... $^*ptr=0$ $x=5$ $^*ptr=5$ $x=$garbage value $^*ptr=$garbage value $x=0$ $^*ptr=0$ $x=0$ $^*ptr=0$ $x=0$ $^*ptr=0$
answered Sep 13 in Programming Himanshu Kumar Gupta 86 views
2 votes
3 answers
16
What is the time complexity for insertion in binary tree in worst case? O(1) O(log n) O(n) O(n log n)
answered Sep 11 in Programming Sanandan 465 views
1 vote
3 answers
17
What is the time complexity to delete an arbitrary node from binary heap? O(n) O(log n) O(1) O(n log n)
answered Sep 11 in Programming Sanandan 537 views
1 vote
2 answers
18
Following is C like Pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. void fun(int n) { Stack S;//Say it creates an empty stack S while(n>0) { // This line pushes the value of n%2 to stack S; Push(&S,n%2); n=n ... $n$ in reverse order. Prints binary representation of $n$. Prints the value of $\log n$. Prints the value of $\log n$ in reverse order.
answered Sep 6 in Programming Himanshu Kumar Gupta 152 views
2 votes
1 answer
19
Consider the following C program. #include <stdio.h> main() { int arr[] = {1, 1, 2, 4, 8, 16, 32, 64}; int i, j, val, t = 16; unsigned char c; for (i = 0; i < 256; i++) { c = i; val = 0; for (j = 0; j < 8; j++) val = val + ((c >> j) & 0x1)*arr[j]; if (val == t) printf("%d\n", i); } } Trace the execution of the code inside the for loop indexed by i when i = 35.
answered Sep 5 in Programming Falahamin 158 views
0 votes
1 answer
20
What will be the output of the following C program? If you think it will give a runtime error, you need to mention it. In either case, your answer must include proper justifications without which no credit will be given. #include<stdio.h> main() { unsigned char i, j, a[]={1, 2, 3, 4, 5}; int n; i=j=n=5; while ... =%d, n=%d\n", i, j, n); while(j-- !=0) a[0]+=n; printf("j=%d, a[0]=%d\n", j, a[0]); }
answered Sep 5 in Programming Falahamin 87 views
0 votes
4 answers
22
Consider 3 dimensional Array A[90] [30] [40] stored in linear array in column major order. If the base address starts at 10, The location of A [20] [20] [30] is ________. (Assume the first element is stored at A[1][1][1] and each element take 1 memory location)
answered Aug 30 in Programming shailesh32767 292 views
1 vote
2 answers
23
Consider the tree T in which left subtree contains half of the maximum number of nodes possible in the avl tree of height 6 and right subtree contains one 3rd of the minimum number of nodes possible in Avl tree of height 6.What will be total number of nodes in T? Edit:- I am getting 75.5 as answer.Now i am not sure whether to pick 75 ot 76
answered Aug 27 in Programming Bikki_gupta 452 views
0 votes
1 answer
25
0 votes
1 answer
26
true/false ? ) if stack is implemented as a array,all operation push ,pop ,is emptystack(),delete stack() can be performed in constant time. )if stack is implemented as a linked list ,all operation ,is emptystack(),delete stack() can be performed in constant time.
answered Aug 23 in Programming Himanshu Kumar Gupta 293 views
3 votes
4 answers
27
Consider an array $A\left[20, 10\right]$, assume $4$ words per memory cell and the base address of array $A$ is $100$. What is the address of $A\left[11, 5\right]$ ? Assume row major storage. $560$ $565$ $570$ $575$
answered Aug 21 in Programming Musa 4.9k views
1 vote
3 answers
28
A three dimensional array in 'C' is declared as int A[x][y][z]. Here, the address of an item at the location A[p][q][r] can be computed as follows: (where w is the word length of an integer) &A[0][0][0]+w(y*z*q+z*p+r) &A[0][0][0]+w(y*z*p+z*q+r) &A[0][0][0]+w(x*y*p+z*q+r) &A[0][0][0]+w(x*y*q+z*p+r)
answered Aug 21 in Programming Musa 1.9k views
0 votes
1 answer
29
Consider an initially empty hash table of length 10. Following set of keys are inserted using open addressing with hash function h(k) = k mod 10 and linear probing. The number of different insertion sequence of the key values using the given hash function and linear probing will result in the hash table shown in above? (given ans is 128 but i am getting 288)
answered Aug 21 in Programming Himanshu Kumar Gupta 171 views
1 vote
3 answers
30
What is the correct way to round off $x$, $a$ $\text{float}$ to an $\text{int}$ value? $y=(\text{int})(x+0.5)$ $y=\text{int} (x+0.5)$ $y=(\text{int}) x+0.5$ $y=(\text{int})(\text{int})x+0.5)$
answered Aug 20 in Programming nocturnal123 211 views
1 vote
8 answers
31
Find the output of the following $“C”$ code : Main() { int x=20, y=35; x=y++ + x++; y=++y + ++x; printf (“%d, %d\n”, x, y); } $55, 93$ $53, 97$ $56, 95$ $57, 94$
answered Aug 19 in Programming nocturnal123 476 views
1 vote
2 answers
32
After $3$ calls of the $c$ function bug ( ) below, the values of $i$ and $j$ will be : int j = 1; bug () { static int i = 0; int j = 0; i++; j++; return (i); } $i = 0, j = 0$ $i = 3, j = 3$ $i = 3, j = 0$ $i = 3, j = 1$
answered Aug 19 in Programming nocturnal123 393 views
2 votes
6 answers
33
What error would the following function give on compilation? f(int a, int b) { int a; a=20; return a; } Missing parenthesis is $\textit{return}$ statement. Function should be defined as $\text{int f(int a, int b)}$ Redeclaration of $a$. None of these.
answered Aug 19 in Programming jordan17 581 views
3 votes
4 answers
34
4 votes
4 answers
35
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$
answered Aug 17 in Programming Vishwajeet Deulkar 670 views
0 votes
5 answers
36
A binary search tree in which every non leaf node has non empty left and right subtrees is called a strictly binary tree . Such a tree with 19 leaves cannot have more than 37 nodes has exactly 37 nodes has exactly 35 nodes cannot have more than 35 nodes
answered Aug 17 in Programming Musa 2.5k views
2 votes
4 answers
37
Consider the following recursive C function that takes two arguments unsigned int rer(unsigned int n, unsigned int r){ if(n>0)return(n%r + rer(n/r,r)); else retturn 0; } What is the return value of the function $rer$ when it is called as $rer(513,2)$? $9$ $8$ $5$ $2$
answered Aug 16 in Programming immanujs 399 views
0 votes
1 answer
38
Consider the hashing table with m' slots and n' keys. If the expected number of probes in an unsuccessful search is 3, the expected number of probes in successful search is _____(Up to 2 decimals) Ans. 1.647 Here by default which hashing should be considered? ... the formula given here in the table http://cs360.cs.ua.edu/notes/hashing_formulas.pdf With linear hashing, I am getting around 1.61
answered Aug 9 in Programming Sherrinford03 332 views
0 votes
2 answers
39
Suppose we are implementing quadratic probing with a Hash function, $Hash(y) = X$ $mode$ $100$. If an element with key $4594$ is inserted and the first three locations attempted are already occupied, then the next cell that will be tried is : $2$ $3$ $9$ $97$
answered Aug 6 in Programming AkashChandraGupta 778 views
To see more, click for all the questions in this category.
...