Questions 81–90 of 106. Imported answers require independent review unless marked reviewed.

Topic practice 106 questionsPage 9 of 11

Question 2

Open question
CSMCQ1 markNeeds review
Consider the following C program:
#include<stdio.h>
struct Uronde{
char x,y,z;
};

int main(){
struct Uronde p = {'1', '0', 'a'+2};
struct Uronde *q = &p;
printf("%c, %c", *((char*)q+1), *((char*)q+2));
return 0;
}
The output of this program is:
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 3

Open question
CSMCQ1 markNeeds review
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.
Diagram for Computer Science and Information Technology question 3

Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 20

Open question
CSNAT1 markNeeds review
The postorder traversal of a binary tree is 8,9,6,7,4,5,2,3,1. The inorder traversal of the same tree is 8,6,9,4,7,2,5,1,3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is ____.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 21

Open question
CSNAT1 markNeeds review
Consider the following C program:
#include <stdio.h>

int counter = 0;

int calc (int a, int b) {
int c;

counter++;
if (b==3) return (a*a*a);
else {
c = calc(a, b/3);
return (c*c*c);
}
}

int main () {
calc(4, 81);
printf("%d", counter);
}
The output of this program is ____.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 29

Open question
CSMCQ2 marksNeeds review
Consider the following C program:
#include<stdio.h>

void fun1(char *s1, char *s2){
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
void fun2(char **s1, char **s2){
char *tmp;
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
}
int main(){
char *str1 = "Hi", *str2 = "Bye";
fun1(str1, str2); printf("%s %s", str1, str2);
fun2(&str1, &str2); printf("%s %s", str1, str2);
return 0;
}
The output of the program above is
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 30

Open question
CSMCQ2 marksNeeds review
Let G be a simple undirected graph. Let T_D be a depth first search tree of G. Let T_B be a breadth first search tree of G. Consider the following statements. (I) No edge of G is a cross edge with respect to T_D. (A cross edge in G is between two nodes neither of which is an ancestor of the other in T_D.) (II) For every edge (u,v) of G, if u is at depth i and v is at depth j in T_B, then

. Which of the statements above must necessarily be true?
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 32

Open question
CSMCQ2 marksNeeds review
Consider the following C code. Assume that unsigned long int type length is 64 bits.
unsigned long int fun(unsigned long int n){
unsigned long int i, j = 0, sum = 0;
for (i = n; i > 1; i = i/2) j++;
for (; j > 1; j = j/2) sum++;
return(sum);
}
The value returned when we call fun with the input

is
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 45

Open question
CSNAT2 marksNeeds review
Consider the following program written in pseudo-code. Assume that x and y are integer.
Count(x, y) {
if (y != 1) {
if (x != 1) {
print("*");
Count(x/2, y);
}
else {
y = y-1;
Count(1024, y);
}
}
}
The number of times that the print statement is executed by the call Count(1024,1024) is _____.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 46

Open question
CSNAT2 marksNeeds review
The number of possible min-heaps containing each value from exactly once is _____.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 2

Open question
CSMCQ1 markNeeds review
Match the following: (P) static char var; (Q) m = malloc(10); m = NULL; (R) char *ptr[10]; (S) register int var;
(i) Sequence of memory locations to store addresses (ii) A variable located in data section of memory (iii) Request to allocate a CPU register to store data (iv) A lost memory which cannot be freed
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer