Code2Duo

Code2Duo

University

15 Qs

quiz-placeholder

Similar activities

Вопросы по алгоритмам и программированию

Вопросы по алгоритмам и программированию

University

20 Qs

Итоговый тест по С

Итоговый тест по С

University

20 Qs

2F-3 | Python Quiz | 14/11/2024

2F-3 | Python Quiz | 14/11/2024

University

20 Qs

PPL (QUIZ 6) Memory Management Quiz

PPL (QUIZ 6) Memory Management Quiz

University

20 Qs

Abstracciones procedimentales

Abstracciones procedimentales

University

10 Qs

Java Quiz I

Java Quiz I

University

17 Qs

Session 15 + 16 : Function

Session 15 + 16 : Function

University

13 Qs

Les pointeurs et structures en C

Les pointeurs et structures en C

University

10 Qs

Code2Duo

Code2Duo

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

Svethaa Lingeshwaran

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

#include <stdlib.h>

int main()

{

 int *pInt;

 int **ppInt1;

 int **ppInt2;

 pInt = (int*)malloc(sizeof(int));

 ppInt1 = (int**)malloc(10*sizeof(int*));

 ppInt2 = (int**)malloc(10*sizeof(int*));

 free(pInt);

free(ppInt1);

 free(*ppInt2);

 return 0;

}

Choose the correct statement with respect to above C program.

  • malloc() for ppInt1 and ppInt2 isn’t correct. It’ll give compile time error.

free(*ppInt2) is not correct. It’ll give compile time error

  • C) free(*ppInt2) is not correct. It’ll give run time error.

) No issue with any of the malloc() and free() i.e. no compile/run time error.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following program : 

print('{0:.2}'.format(1.0 / 3))

  • 0.333333

0.33

  • 0.333333:-2

 Error

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code? 

print(tuple[1:3] if tuple == ( 'abcd', 786 , 2.23, 'john', 70.2 ) else tuple())

  • ( \'abcd\', 786 , 2.23, \'john\', 70.2 )

  • abcd

  • (786, 2.23)

  • None of the above

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Postorder traversal of a given binary search tree, T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 Which one of the following sequences of keys can be the result of an in-order traversal of the tree T?

9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95

  9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29

29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95

A)   95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following program that attempts to locate an element x in a sorted array a[ ] using binary search. Assume N>1. The program is erroneous. Under what conditions does the program fail?

def find(a, n, x):

    i = 0

    j = n

    while i < j:

        k = (i + j) // 2

        if a[k] < x:

            i = k + 1

        else:

            j = k

    if i < len(a) and a[i] == x:

        print("x is in the array")

    else:

        print("x is not in the array")

x is the last element of the array a[]

x is greater than all elements of the array a[]

Both of the Above

x is less than the last element of the array a[]

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Output Prediction:

What will be the output of this Python code?

def mystery(s):

    return s[::-1] if len(s) % 2 == 0 else s[1::2]

print(mystery("abcdef"))

print(mystery("12345"))

fedcba and 24

abcdef and 24

fedcba and 135

fabcde and 13

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Matrix Transposition

What will be the output of the following code?

matrix = [[1, 2], [3, 4], [5, 6]]

transpose = [[row[i] for row in matrix] for i in range(2)]

print(transpose)

[[1, 3, 5], [2, 4, 6]]

[[1, 2], [3, 4], [5, 6]]

[[1, 2, 3], [4, 5, 6]]

[[1, 4], [2, 5], [3, 6]]

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?