Wells Forgo Complexity Theory Problems with Solutions

Question 1

Time: 00:00:00
Neelam wants to share her code with a colleague, who may modify it. Thus she wants to include the date of the program creation, the author and other she wants to include the date of the program creation, the author and other information with the program. What component should she use?

Header files

Header files

Iteration

Iteration

Comments

Comments

Preprocessor directive

Preprocessor directive

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

answer is c) Comments

PrepInsta User

IT\'S COMMENTS as it won\'t be executed but remain in source code

Question 2

Time: 00:00:00
What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long.
integer a
pointer c, d
a = 30c = &a
c = &a
d = c
a = a + 10
print *c

30

30

4165

4165

40

40

4166

4166

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
A data type is stored as a 6 bit signed integer. Which of the following cannot be represented by this data type?

-12

-12

32

32

18

18

6

6

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

6 bits means total combinations of bits are 2^6 = 64. That is, 0 to 63. But given data type is signed means -32 to +31 which stores exactly 64 combinations. Now coming to the question, we can not store both 32 and 64. But can store -12, 0.

Question 4

Time: 00:00:00
A language has 28 different letters in total. Each word in the language iscomposed of maximum 7 letters. You want to create a data-type to store a word ofthis language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language.

73

73

7

7

28

28

196

196

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

1 bit- 2 letters 2 bit-4 letters 3 bit-8 letters 4 bit-16 letters 5 bit-32 letters 28 letters>16 and 28 letters<32 array is of size 7 so, 5*7=35bits

Question 5

Time: 00:00:00
A 10-bit unsigned integer has the following range:

0 to 1000

0 to 1000

0 to 1024

0 to 1024

1 to 1025

1 to 1025

0 to 1023

0 to 1023

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

2^10=1024 so range of unsigned integer will be 0 to 1023

Question 6

Time: 00:00:00
Parul takes as input two numbers: a and b. a and b can take integer valuesbetween 0 and 255. She stores a, b and c as 1-byte data type. She writes the following code statement to process a and b and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b, while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?

a = 10 b = 200

a = 10 b = 200

a = 200 b = 10

a = 200 b = 10

a = 50 b = 100

a = 50 b = 100

a = 100 b = 50

a = 100 b = 50

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

0 to 255 integers are accepted when a=10 b=200 c =410 > 255 when a=200 b=10 c=220<255 when a=50 b=100 c=250<255 when a=100 b=50 c=200<255 so, option 1 gives wrong output

Question 7

Time: 00:00:00
Which is used to convert source code to target language

linker

linker

compiler

compiler

executer

executer

loader

loader

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
Tricha wants to store a list of binary data.Which of following data types should she use?

Integer

Integer

Float

Float

Character

Character

Boolean

Boolean

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

Boolean can stores only two values that is true and false or 0 and 1.

Question 9

Time: 00:00:00
Which of the following options is an exception to being a part of composite data types?

Union

Union

Array

Array

Structure

Structure

Stack

Stack

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 10

Time: 00:00:00
The datatype is store as 6 but unsigned integer. Which of the following can't be represented by the this datatype:

-12

-12

0

0

32

32

18

18

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice! \r\n \r\n \r\n","Keep trying! \r\n \r\n \r\n","Not bad! \r\n \r\n \r\n","Good work! \r\n \r\n \r\n","Perfect! \r\n \r\n \r\n"]

Question 1

Time: 00:00:00
If x1(n) is O(y1(n)) and x2(n) is O(y2(n)), then which of the following options is true in context of asymptotic complexity notations?

x1(n) + x2(n) is O(min(y1(n), y2(n)))

x1(n) + x2(n) is O(min(y1(n), y2(n)))

x1(n) + x2(n) is O(max(y1(n), y2(n)))

x1(n) + x2(n) is O(max(y1(n), y2(n)))

x1(n) + x2(n) is O(y1(n)*y2(n))

x1(n) + x2(n) is O(y1(n)*y2(n))

x1(n) + x2(n) is O(y1(n)-y2(n))

x1(n) + x2(n) is O(y1(n)-y2(n))

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
What is space complexity of the program?

Amount of hard disk space required to store the program.

Amount of hard disk space required to store the program.

Amount of hard disk space required to compile the program.

Amount of hard disk space required to compile the program.

Amount of memory required by the program to run.

Amount of memory required by the program to run.

Amount of memory required by the program to compile.

Amount of memory required by the program to compile.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
The time required to insert an element in a stack with linked list implementation is?

O(1)

O(1)

O(log2n)

O(log2n)

O(n)

O(n)

O(nlog2n)

O(nlog2n)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 4

Time: 00:00:00
Choose the correct answer
A Programmer writes an efficient program to sum two square diagonal matrices (matrices with elements only on diagonal). The size of each matrix is nXn. What is the time complexity of Vrinda's algorithm?

Theta (n^2)

Theta (n^2)

Theta (n)

Theta (n)

Theta (n*log(n))

Theta (n*log(n))

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
Rajesh implements queue as a singly-linked linked list. The queue has n elements. The time complexity to ADD a new element to the queue:

O (1)

O (1)

O (log2 n)

O (log2 n)

O (n)

O (n)

O (n log2 n)

O (n log2 n)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 6

Time: 00:00:00
Choose the correct answer
Vibhu is given two codes, A and B, to solve a problem, which have complexity O(n4) and ?(n3) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will Gautam deliver to the client, so that the execution is faster?

Code A

Code A

Code B

Code B

Vibhu cannot determine

Vibhu cannot determine

Both codes have the same execution time, so deliver any.

Both codes have the same execution time, so deliver any.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 7

Time: 00:00:00
A tree has 5 levels and each has either 4 children or no children. All nodes on the same level have the same number of children. How many nodes are there in the tree? (Root is Level 1)

341

341

256

256

1024

1024

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
Surbhi is given two codes, A and B, to solve a problem, which have complexity O(n3) and ?(n4) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will Surbhi deliver to the client, so that the execution is faster?

Code A

Code A

Code B

Code B

Surbhi cannot determine

Surbhi cannot determine

Both codes have the same execution time, so deliver any.

Both codes have the same execution time, so deliver any.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
Rajini is given an efficient code for summing two nXn matrices and putting the result in a third matrix. She is asked to find it's time complexity. She realises that the number of iterations required is more than n. What can she claim with regard to the complexity of the code?

It is O(n)

It is O(n)

It is O(n2)

It is O(n2)

It is Theta(n)

It is Theta(n)

It is Theta(n2)

It is Theta(n2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice! \r\n \r\n \r\n","Keep trying! \r\n \r\n \r\n","Not bad! \r\n \r\n \r\n","Good work! \r\n \r\n \r\n","Perfect! \r\n \r\n \r\n"]

Hey ! Follow us on G+