Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Webpage
Programming in C.
Recursion.
Filter
Recent
Hot!
Most votes
Most answers
Most views
Previous GATE
Featured
Highest voted questions in Programming and DS
172
votes
13
answers
1
GATE IT 2007 | Question: 29
When searching for the key value $60$ in a binary search tree, nodes containing the key values $10, 20, 40, 50, 70, 80, 90$ are traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur on the search path from the root to the node containing the value $60$? $35$ $64$ $128$ $5040$
When searching for the key value $60$ in a binary search tree, nodes containing the key values $10, 20, 40, 50, 70, 80, 90$ are traversed, not necessarily in the order gi...
Ishrat Jahan
38.9k
views
Ishrat Jahan
asked
Oct 29, 2014
DS
gateit-2007
data-structures
binary-search-tree
normal
+
–
168
votes
17
answers
2
GATE CSE 2016 Set 2 | Question: 40
The number of ways in which the numbers $1, 2, 3, 4, 5, 6, 7$ can be inserted in an empty binary search tree, such that the resulting tree has height $6$, is _________. Note: The height of a tree with a single node is $0$.
The number of ways in which the numbers $1, 2, 3, 4, 5, 6, 7$ can be inserted in an empty binary search tree, such that the resulting tree has height $6$, is _________.No...
Akash Kanase
49.5k
views
Akash Kanase
asked
Feb 12, 2016
DS
gatecse-2016-set2
data-structures
binary-search-tree
normal
numerical-answers
+
–
143
votes
12
answers
3
GATE CSE 2016 Set 1 | Question: 41
Let $Q$ denote a queue containing sixteen numbers and $S$ be an empty stack. $Head(Q)$ returns the element at the head of the queue $Q$ without removing it from $Q$. Similarly $Top(S)$ returns the element at the top of $S$ without removing ... = Pop(S); Enqueue (Q, x); end end The maximum possible number of iterations of the while loop in the algorithm is _______.
Let $Q$ denote a queue containing sixteen numbers and $S$ be an empty stack. $Head(Q)$ returns the element at the head of the queue $Q$ without removing it from $Q$. Simi...
Sandeep Singh
34.5k
views
Sandeep Singh
asked
Feb 12, 2016
DS
gatecse-2016-set1
data-structures
queue
difficult
numerical-answers
+
–
130
votes
4
answers
4
GATE CSE 2014 Set 2 | Question: 11
Suppose $n$ and $p$ are unsigned int variables in a C program. We wish to set $p$ to $^nC_3$. If $n$ is large, which one of the following statements is most likely to set $p$ correctly? $p = n * (n-1) * (n-2) / 6;$ $p = n * (n-1) / 2 * (n-2) / 3;$ $p = n * (n-1) / 3 * (n-2) / 2;$ $p = n * (n-1) * (n-2) / 6.0;$
Suppose $n$ and $p$ are unsigned int variables in a C program. We wish to set $p$ to $^nC_3$. If $n$ is large, which one of the following statements is most likely to set...
go_editor
15.4k
views
go_editor
asked
Sep 28, 2014
Programming in C
gatecse-2014-set2
programming
programming-in-c
normal
+
–
129
votes
6
answers
5
GATE CSE 2008 | Question: 46
You are given the postorder traversal, $P$, of a binary search tree on the $n$ elements $1, 2, \dots, n$. You have to determine the unique binary search tree that has $P$ as its postorder traversal. What is the time complexity of the most efficient algorithm ... $\Theta(\log n)$ $\Theta(n)$ $\Theta(n\log n)$ None of the above, as the tree cannot be uniquely determined
You are given the postorder traversal, $P$, of a binary search tree on the $n$ elements $1, 2, \dots, n$. You have to determine the unique binary search tree that has $P...
Kathleen
38.6k
views
Kathleen
asked
Sep 12, 2014
DS
gatecse-2008
data-structures
binary-search-tree
normal
+
–
118
votes
8
answers
6
GATE CSE 2014 Set 3 | Question: 39
Suppose we have a balanced binary search tree $T$ holding $n$ numbers. We are given two numbers $L$ and $H$ and wish to sum up all the numbers in $T$ that lie between $L$ and $H$. Suppose there are $m$ such numbers in $T$. If the tightest upper bound on the time to compute the sum is $O(n^a\log^bn+m^c\log^dn)$, the value of $a+10b+100c+1000d$ is ______.
Suppose we have a balanced binary search tree $T$ holding $n$ numbers. We are given two numbers $L$ and $H$ and wish to sum up all the numbers in $T$ that lie between $L$...
go_editor
31.1k
views
go_editor
asked
Sep 28, 2014
DS
gatecse-2014-set3
data-structures
binary-search-tree
numerical-answers
normal
+
–
110
votes
6
answers
7
GATE CSE 2015 Set 1 | Question: 35
What is the output of the following C code? Assume that the address of $x$ is $2000$ (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x [4] [3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; printf ("%u, %u, %u", x + 3, *(x + 3), *(x + 2) + 3); } $2036, 2036, 2036$ $2012, 4, 2204$ $2036, 10, 10$ $2012, 4, 6$
What is the output of the following C code? Assume that the address of $x$ is $2000$ (in decimal) and an integer requires four bytes of memory.int main () { unsigned int ...
makhdoom ghaya
27.8k
views
makhdoom ghaya
asked
Feb 13, 2015
Programming in C
gatecse-2015-set1
programming
programming-in-c
array
normal
+
–
103
votes
7
answers
8
GATE CSE 2017 Set 1 | Question: 36
Consider the C functions foo and bar given below: int foo(int val) { int x=0; while(val > 0) { x = x + foo(val--); } return val; } int bar(int val) { int x = 0; while(val > 0) { x ... in: Return of $6$ and $6$ respectively. Infinite loop and abnormal termination respectively. Abnormal termination and infinite loop respectively. Both terminating abnormally.
Consider the C functions foo and bar given below:int foo(int val) { int x=0; while(val 0) { x = x + foo(val ); } return val; }int bar(int val) { int x = 0; while(val 0)...
Arjun
25.1k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming-in-c
programming
normal
recursion
+
–
103
votes
11
answers
9
GATE CSE 2004 | Question: 85
A program takes as input a balanced binary search tree with $n$ leaf nodes and computes the value of a function $g(x)$ for each node $x$. If the cost of computing $g(x)$ ... time complexity of the program is? $\Theta (n)$ $\Theta (n \log n)$ $\Theta(n^2)$ $\Theta (n^2\log n)$
A program takes as input a balanced binary search tree with $n$ leaf nodes and computes the value of a function $g(x)$ for each node $x$. If the cost of computing $g(x)$ ...
Kathleen
31.5k
views
Kathleen
asked
Sep 18, 2014
DS
gatecse-2004
binary-search-tree
normal
data-structures
+
–
102
votes
9
answers
10
GATE CSE 2017 Set 1 | Question: 53
Consider the following C program. #include<stdio.h> #include<string.h> void printlength(char *s, char *t) { unsigned int c=0; int len = ((strlen(s) - strlen(t)) > c) ? strlen(s) : strlen(t); printf("%d\n", len); } ... in $string.h$ as returning a value of type $size\_t$, which is an unsigned int. The output of the program is __________ .
Consider the following C program.#include<stdio.h #include<string.h void printlength(char *s, char *t) { unsigned int c=0; int len = ((strlen(s) - strlen(t)) c) ? strlen...
srestha
24.7k
views
srestha
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming
programming-in-c
normal
numerical-answers
+
–
101
votes
7
answers
11
GATE CSE 2002 | Question: 2.12
A weight-balanced tree is a binary tree in which for each node, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the furthest ... which of the following? $\log_2 n$ $\log_{\frac{4}{3}} n$ $\log_3 n$ $\log_{\frac{3}{2}} n$
A weight-balanced tree is a binary tree in which for each node, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the rig...
Kathleen
23.1k
views
Kathleen
asked
Sep 15, 2014
DS
gatecse-2002
data-structures
binary-tree
normal
+
–
100
votes
6
answers
12
GATE IT 2006 | Question: 49
Which one of the choices given below would be printed when the following program is executed ? #include <stdio.h> struct test { int i; char *c; }st[] = {5, "become", 4, "better", 6, "jungle", 8, "ancestor", 7, " ... $\text{etter, u, 6, ungle}$ $\text{cetter, k, 6, jungle}$ $\text{etter, u, 8, ncestor}$
Which one of the choices given below would be printed when the following program is executed ?#include <stdio.h struct test { int i; char *c; }st[] = {5, "become", 4, "be...
Ishrat Jahan
26.9k
views
Ishrat Jahan
asked
Oct 31, 2014
Programming in C
gateit-2006
programming
programming-in-c
normal
structure
+
–
96
votes
6
answers
13
GATE CSE 2016 Set 2 | Question: 15
$N$ items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations ... together? $O(\log^{2} N)$ $O(N)$ $O(N^{2})$ $\Theta\left(N^{2}\log N\right)$
$N$ items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is...
Akash Kanase
34.0k
views
Akash Kanase
asked
Feb 12, 2016
DS
gatecse-2016-set2
data-structures
linked-list
time-complexity
normal
algorithms
+
–
90
votes
11
answers
14
GATE CSE 2014 Set 1 | Question: 12
Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly $4$ nodes is $O(n^a\log^bn)$. Then the value of $a+10b$ is __________.
Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly $4$ nodes is...
go_editor
24.3k
views
go_editor
asked
Sep 26, 2014
DS
gatecse-2014-set1
data-structures
binary-tree
numerical-answers
normal
+
–
89
votes
12
answers
15
GATE CSE 2003 | Question: 64
Let S be a stack of size $n \geq1$. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform $n$ pop operations. Assume that Push and Pop operations take $X$ seconds each, and $Y$ seconds elapse between the end of one such ... S. The average stack-life of an element of this stack is $n(X+Y)$ $3Y+2X$ $n(X+Y)-X$ $Y+2X$
Let S be a stack of size $n \geq1$. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform $n$ pop operations. Assume th...
Kathleen
30.7k
views
Kathleen
asked
Sep 17, 2014
DS
gatecse-2003
data-structures
stack
normal
+
–
88
votes
8
answers
16
GATE CSE 2006 | Question: 49
An implementation of a queue $Q$, using two stacks $S1$ and $S2$, is given below: void insert (Q, x) { push (S1, x); } void delete (Q) { if (stack-empty(S2)) then if (stack-empty(S1)) then { print( Q is empty ); return; } else while (!(stack-empty(S1))){ x=pop ... and $2m\leq y\leq 2n $ $ 2m\leq x<2n $ and $2m\leq y\leq n+m $ $ 2m\leq x<2n $ and $2m\leq y\leq 2n $
An implementation of a queue $Q$, using two stacks $S1$ and $S2$, is given below: void insert (Q, x) { push (S1, x); } void delete (Q) { if (stack-empty(S2)) then if (sta...
Rucha Shelke
32.7k
views
Rucha Shelke
asked
Sep 26, 2014
DS
gatecse-2006
data-structures
queue
stack
normal
+
–
87
votes
7
answers
17
GATE CSE 2017 Set 1 | Question: 13
Consider the following C code: #include<stdio.h> int *assignval (int *x, int val) { *x = val; return x; } void main () { int *x = malloc(sizeof(int)); if (NULL == x) return; x = assignval (x,0); ... and not as shown. compiles successfully but execution may result in dangling pointer. compiles successfully but execution may result in memory leak.
Consider the following C code:#include<stdio.h int *assignval (int *x, int val) { *x = val; return x; } void main () { int *x = malloc(sizeof(int)); if (NULL == x) return...
Arjun
35.1k
views
Arjun
asked
Feb 14, 2017
Programming in C
gatecse-2017-set1
programming-in-c
programming
pointers
+
–
85
votes
11
answers
18
GATE CSE 2017 Set 1 | Question: 08
Consider the C code fragment given below. typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->next; } p->next = m; } Assuming that m and n ... append list m to the end of list n. cause a null pointer dereference for all inputs. append list n to the end of list m for all inputs.
Consider the C code fragment given below.typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->ne...
khushtak
25.4k
views
khushtak
asked
Feb 14, 2017
DS
gatecse-2017-set1
data-structures
linked-list
normal
+
–
85
votes
6
answers
19
GATE IT 2006 | Question: 50
Which one of the choices given below would be printed when the following program is executed? #include <stdio.h> void swap (int *x, int *y) { static int *temp; temp = x; x = y; y = temp; } void printab () { static int i, a = -3, b = -6; i = 0; while (i <= 4) { if ((i++)%2 == 1 ... $a = 12, b = 9$ $a = 3, b = 6$ $a = 3, b = 6$ $a = 6, b = 3$ $a = 15, b = 12$
Which one of the choices given below would be printed when the following program is executed?#include <stdio.h void swap (int *x, int *y) { static int *temp; temp = x; x ...
Ishrat Jahan
25.3k
views
Ishrat Jahan
asked
Oct 31, 2014
Programming in C
gateit-2006
programming
programming-in-c
normal
parameter-passing
+
–
81
votes
6
answers
20
GATE CSE 2003 | Question: 6
Let $T(n)$ be the number of different binary search trees on $n$ distinct elements. Then $T(n) = \sum_{k=1}^{n} T(k-1)T(x)$, where $x$ is $n-k+1$ $n-k$ $n-k-1$ $n-k-2$
Let $T(n)$ be the number of different binary search trees on $n$ distinct elements.Then $T(n) = \sum_{k=1}^{n} T(k-1)T(x)$, where $x$ is $n-k+1$$n-k$$n-k-1$$n-k-2$
Kathleen
22.3k
views
Kathleen
asked
Sep 16, 2014
DS
gatecse-2003
normal
binary-search-tree
+
–
Page:
1
2
3
4
5
6
...
309
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register