Question Bank

Rows per page: 1025100

Showing 126–150

Discrete Structures and Algorithms Graph Theory and Combinatorics #9

How many different trees with 5 nodes, labeled with numbers from 1 to 5 exists?

10

273

32

120

125

Discrete Structures and Algorithms Graph Theory and Combinatorics #10

In how many ways can we color the following graph G with three colors?

0

288

336

1874

Discrete Structures and Algorithms Graph Theory and Combinatorics #11

Which of the following graphs are eulerian graphs and which ones are not?

G1 : no; G2, G3 : yes

G1 : yes; G2, G3 : no

G1, G2 : yes; G3 : no

none

all of them are eulerian

Discrete Structures and Algorithms Graph Theory and Combinatorics #12

In the Internet, which is made up of interconnected physical networks of computers, each network connection of a computer is assigned an Internet address. In IPv4 Internet protocol, every Internet address is a 32-bit string, made of a network number (netid) followed by a host number (hostid). There are 3 types of Internet addresses:
(a) Class A: these are of the form: 0b1b2b3b4b7b8netidb9b30b31hostid0\,\underbrace{b_1b_2b_3b_4\ldots b_7b_8}_{\text{netid}}\underbrace{b_9\ldots b_{30}b_{31}}_{\text{hostid}}
(b) Class B: these are of the form: 10b2b3b4b15b16netidb17b30b31hostid10\,\underbrace{b_2b_3b_4\ldots b_{15}b_{16}}_{\text{netid}}\underbrace{b_{17}\ldots b_{30}b_{31}}_{\text{hostid}}
(c) Class C: these are of the form: 110b3b4b5b23b24netidb25b30b31hostid110\,\underbrace{b_3b_4b_5\ldots b_{23}b_{24}}_{\text{netid}}\underbrace{b_{25}\ldots b_{30}b_{31}}_{\text{hostid}}
How many different IPv4 addresses are available for the internet network connections?

2292^{29}

2302312^{30} · 2^{31}

2312^{31}

72297 · 2^{29}

2322^{32}

Discrete Structures and Algorithms Graph Theory and Combinatorics #13

In a drawer there are 8 brown socks and 12 black socks. A child picks socks from the drawer at random in the dark. How many socks must he take out to be sure that he picked at least two black socks?

3

10

14

9

Discrete Structures and Algorithms Graph Theory and Combinatorics #14

How many integer numbers between 1 and 1000 are divisible with 7, but are not divisible with 3?

93

95

92

136

Discrete Structures and Algorithms Graph Theory and Combinatorics #15

Consider the following weighted graph

What is the total weight of a minimum spanning tree of this graph?

229

216

230

234

Discrete Structures and Algorithms Graph Theory and Combinatorics #16

Let GG be a simple undirected graph with nn nodes numbered from 11 to nn, and AGMnA_G ∈ M_n be its adjacency matrix. What is the number of simple undirected graphs with nn nodes labeled from 11
to nn.

2n(n1)/22^{n(n−1)}/2

2n2^n

n(n1)/2n(n − 1)/2

n1n-1

n(n1)n · (n − 1)

Discrete Structures and Algorithms Graph Theory and Combinatorics #17

Let MnM_n be the set of matrices of dimension n×nn×n whose elements are 0 or 1.
For every two matrices A,BMnA,B ∈ M_n and 1kn1 ≤ k ≤ n we define the operations ABA⊕B and AkBA⊙_kB as follows:
AB=CMnA⊕B = C ∈ M_n if C[i][j]=max(A[i][j],B[i][j])C[i][j] = max(A[i][j],B[i][j]) and
AkB=DMnA⊙_kB = D ∈ M_n if D[i][j]=A[i][k]B[k][j]D[i][j] = A[i][k]·B[k][j] for all 1i,jn1 ≤ i, j ≤ n.
Let GG be a simple undirected graph with nn nodes numbered from 11 to nn, and AGMnA_G ∈ M_n be its adjacency matrix.

What is the number of simple undirected graphs with n nodes labeled from 11 to nn ?

2n(n1)/22^{n(n−1)/2}

2n2^n

n(n1)/2n(n − 1)/2

n1n-1

n(n1)n(n − 1)

Discrete Structures and Algorithms Graph Theory and Combinatorics #18

Let MnM_n be the set of matrices of dimension n×nn×n whose elements are 0 or 1.
For every two matrices A,BMnA,B ∈ M_n and 1kn1 ≤ k ≤ n we define the operations ABA⊕B and AkBA⊙_kB as follows:
AB=CMnA⊕B = C ∈ M_n if C[i][j]=max(A[i][j],B[i][j])C[i][j] = max(A[i][j],B[i][j]) and
AkB=DMnA⊙_kB = D ∈ M_n if D[i][j]=A[i][k]B[k][j]D[i][j] = A[i][k]·B[k][j] for all 1i,jn1 ≤ i, j ≤ n.
Let GG be a simple undirected graph with nn nodes numbered from 11 to nn, and AGMnA_G ∈ M_n be its adjacency matrix.
Let InI_n be the identity matrix of dimension n×nn × n, and 1pn1 ≤ p ≤ n.
Consider the following algorithm to compute the matrix
BMn:B=AGIn;B ∈ Mn: B = AG ⊕ In;
for k:=1k := 1 to pp do C=B(BkB);B=C;C = B ⊕ (B ⊙_k B); B = C;

What is the runtime complexity of this algorithm?

Θ(pn2)Θ(p · n^2)

Θ(pn)Θ(p · n)

Θ(pn3)Θ(p · n^3)

Θ(n)Θ(n)

Θ(p2n)Θ(p · 2^n)

Discrete Structures and Algorithms Graph Theory and Combinatorics #19

Let MnM_n be the set of matrices of dimension n×nn×n whose elements are 0 or 1.
For every two matrices A,BMnA,B ∈ M_n and 1kn1 ≤ k ≤ n we define the operations ABA⊕B and AkBA⊙_kB as follows:
AB=CMnA⊕B = C ∈ M_n if C[i][j]=max(A[i][j],B[i][j])C[i][j] = max(A[i][j],B[i][j]) and
AkB=DMnA⊙_kB = D ∈ M_n if D[i][j]=A[i][k]B[k][j]D[i][j] = A[i][k]·B[k][j] for all 1i,jn1 ≤ i, j ≤ n.
Let GG be a simple undirected graph with nn nodes numbered from 11 to nn, and AGMnA_G ∈ M_n be its adjacency matrix.
Let InI_n be the identity matrix of dimension n×nn × n, and 1pn1 ≤ p ≤ n.

Consider the following algorithm to compute the matrix BMn:B=AGInB ∈ M_n: B = A_G ⊕ I_n; for k:=1k := 1 to pp do C=B(BkB);B=C;C = B ⊕ (B ⊙_k B); B = C;
Which of the following assertions holds when B[i][j]=1B[i][j] = 1?

There is a path of length at most p+1p + 1 from node ii to node jj.

There is a path of length pp from node ii to node jj.

There is a path from node ii to node jj which goes through node pp.

There is a path from node ii to node jj which goes through all nodes from the set {1,2,...,p}\{1, 2, . . . , p\}.

Programming Languages and Software Engineering C Language #1

What’s wrong with the sequence:

c
int t[N], *low=t, *mid, *high=&t[N-1]; 
mid = (low+high) / 2;

addition of two pointers is an illegal operation

a pointer can’t be initialized with an array

the initialization of low and high is incorrect

mid can’t be initialized with a real value (when low+high is odd!)

Programming Languages and Software Engineering C Language #2

Knowing that the . and the -> operators have equal precedence, higher than the precedence of the * operator and assuming the following declarations, which of the expressions bellow are correct?

c
struct point { 
    int x, y; 
}; 
struct rectangle{ 
    struct point p1, p2; 
}*r[N];

r[i].p1.x

r[i]->p1.x

(*r[i]).p1.x

*r[i].p1.x

Programming Languages and Software Engineering C Language #3

Which of the following storage classes is implicit, due to the place of the variable’s declaration:

static

auto

register

extern

Programming Languages and Software Engineering C Language #4

Can two functions, neither of whom calls the other, communicate (share data)?

no

yes, through messages

yes, through global variables

Programming Languages and Software Engineering C Language #5

Given float x=2.5; the value of the expression 3.0*x+10/4 is:

10.0

9.5

of type double

of type float

Programming Languages and Software Engineering C Language #6

The type of p, used in the expression p->m is:

pointer to some structure

the type of m

void *

Programming Languages and Software Engineering C Language #7

Knowing that "0123456789" is a C string constant, which is the result of evaluating the expression: "0123456789"[i] if i=10?

the expression is syntactically wrong

undefined

′\0′

of type char

Programming Languages and Software Engineering C Language #8

What would the value of q-p be if:

c
int t[20], *p=t, *q=&t[19];

19

20

t[19]- t[0]

It is illegal to substract a pointer from another pointer!

Programming Languages and Software Engineering C Language #9

What will be the value of variable a (before return) by running the following C code:

c
int main(){ 
    char a, a1=200, a2=110; 
    a = a1 + a2; 
    return 0; 
}

a = 54

a = 310

a = 182

a = −54

Programming Languages and Software Engineering C Language #10

What will be the value of variable “b” after execution of the following code:

c
unsigned char a; 
int b=0; for (a=0; a<256; a++) { 
   b++;
}

there is an infinite loop

0

256

compilation error

-1

Programming Languages and Software Engineering C Language #11

Select the correct statement(s) regarding the following lines:

c
const int a = 12; 
#define b 12

there is no difference between const and define

the const definition will allocate space in memory

b will be processed by the preprocesor and will not appear at compilation

we cannot see in debug the constant b but we can see the constant a

Programming Languages and Software Engineering C Language #12

Which of the following statements will generate a memory allocation:

int x

typedef int integer

struct {char x; long y; short z}

double *p

Programming Languages and Software Engineering C Language #13

Which of the following allocations occupies more space:

int *pi

char *pc

long *pl

double **ppd

none of them (all pointers have the same amount of bytes)

Programming Languages and Software Engineering C Language #14

What will be the output after running the following code :

c
int compute(int x){ 
     static int b=20; 
    b--; 
    return b+x; 
} 
int main (void){ 
    int i; 
    for (i=3;i>=0;i--) 
    printf("%d ",compute(i)); 
    return 0; 
}

22 20 18 16

23 22 21 20

23 21 19 17

3 2 1 0