wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA Quiz # 1

Total questions: 50

Worksheet time: 57mins

Name
Class
Date
1.

A series of values stored in memory is called ___

a)

an array

b)

a tree

c)

a matrix

d)

a struct

2.

Almost all programming languages start arrays at ___

a)

index 0

b)

index 1

c)

index 2

d)

the null character

3.

Arrays of characters, like letters, numbers, punctuation and other written symbols, are called ___

a)

structs

b)

vectors

c)

strings

d)

groups

4.

int nums[ ] =

{2, 3, 5, 8, 9, 11};

How would you access the fourth element in nums

a)

nums[8]

b)

nums[3]

c)

nums(4)

d)

nums(3)

5.

Which of these is not a data structure?

a)

Stack

b)

Array

c)

Integer

d)

List

6.
What is a data structure?
a)
A method of arranging data
b)
A way of keeping data without an order?
c)
A "stack" only
d)
There is no formal definition for "Data Structure"
7.
Ordered collection of data items of the same type referred to collectively by a single name 
a)
List
b)
Array
c)
Variables
d)
Constants
8.

Data Structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

a)

True

b)

False

9.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
10.
Storage for data defined in terms of set of operations to be performed on the data 
a)
Arrays
b)
Variables
c)
Abstract Data Types
d)
Algorithms
11.

Based on the following statements, which are the leaf nodes?

ArrayList<Integer> minHeap = new ArrayList<>();

Collections.addAll(minHeap, 2, 4, 5, 7, 8);

a)

5, 7, and 8

b)

4, 5, and 7

c)

2, 4, and 5

d)

7 and 8

12.

Set A = { 1, 3, 5, 7 }

Set B = { 2, 3, 4, 5 }

The difference of sets A and B (A - B) is _______?

a)

{ 3}

b)

{ 5 }

c)

{ 1, 7 }

d)

{ 3, 5}

13.

Are basic data structures provided by programming languages to represent single values, such as integers, floating-point numbers, characters, and booleans.

(a)  

14.

are higher-level data structures that are built using primitive data types and provide more complex and specialized operations.

(a)  

15.

set of step-by-step instructions to solve a given problem or achieve a specific goal.

(a)  

16.

A data structure is not worth much if you cannot search through it or manipulate it efficiently using algorithms, and the algorithms. TRUE/ FALSE

a)

TRUE

b)

FALSE

17.

is about finding efficient ways to store and retrieve data, to perform operations on data, and to solve specific problems. TRUE/ FALSE

a)

TRUE

b)

FALSE

18.

DSA are used in virtually every software system, from operating systems to web applications. TRUE/ FALSE

a)

TRUE

b)

FALSE

19.

A measure of the amount of time an algorithm takes to run, depending on the amount of data the algorithm is working on.

(a)  

20.

This measure of the amount of memory an algorithm uses, depending on the amount of data the algorithm is working on.

(a)  

21.

A mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Used in this tutorial to describe the time complexity of an algorithm.

(a)  

22.

A programming technique where a function calls itself.

(a)  

23.

A method of solving complex problems by breaking them into smaller, more manageable sub-problems, solving the sub-problems, and combining the solutions. Recursion is often used when using this method in an algorithm.

(a)  

24.

A simple and straight forward way an algorithm can work by simply trying all possible solutions and then choosing the best one.

(a)  

25.

are very useful for introducing algorithms.

(a)  

26.

What is the output of this program?

a)

0

b)

1

c)

120

d)

None of the above

27.

What is the returned value of recMethod(5)?

a)
68
b)
70
c)
75
d)
82
28.

What is returned as a result of the call mystery(4,6)?

a)
2
b)
3
c)
4
d)
1
29.

What is the output of this program?

a)

24

b)

30

c)

120

d)

720

30.

What is the action of method mystery2?

a)

a+b

b)

a*b

c)

ab

d)

ba

e)

a!

31.

What is printed as a result of the call stringMaker("COMPSCI")?

a)
COMPSCI
COMPSC
COMPS
COMP
COM
CO
C
b)
COMPSCI
OMPSCI
MPSCI
PSCI
SCI
CI
I
c)
CO
COM
COMP
COMPS
COMPSC
COMPSCI
d)
C
CO
COM
COMP
COMPS
COMPSC
COMPSCI
32.

Which expression represents the result of calling recurs(11,4)? 

a)
x + y
b)
x * y
c)
xy-2
d)
yx+2
33.

Which of the following is the best definition of a recursive method?

a)
A method that iterates itself exactly 5 times.
b)
A method that invokes itself by name within the method.
c)
A method that will never iterate infinitely.
d)
A method that cannot be called more than once.
34.

What value is returned as a result of the call mysterious(x)?

a)
x * (x+1)
b)
2x
c)
2(x-1)
d)
x+1
35.

What does the following code segment print?

a)

5 4 3 2 1

b)

-5 -4 -3 -2 -1

c)

-4 -3 -2 -1 0

36.

How many times does the following method print a *?

a)

9

b)

6

c)

7

d)

10

37.

What does the code print?

a)

1 2 3 4

b)

1 2 3 4 5

c)

0 1 2 3 4

d)

0 1 2 3 4 5

38.

What is printed when the code segment is executed?

a)

0 2 4 6 8 10 12 14 16 18

b)

0 6 12 18

c)

1 4 7 10 13 16 19

d)

4 10 16

39.

What will the output of the following code segment be?


int a = 1, b = 2;

System.out.println(++a+”,”+b++);

a)

1,2

b)

2,2

c)

2,3

d)

3,3

40.

What will the following program segment display?


for(int a = 2; a <= 10; a += 3)

System.out.print(a+””);

a)

2 5 8

b)

2 5

c)

2 5 8 11

d)

2

41.

This expression is executed by the for loop only once, regardless of the number of iterations.

a)

a. initialization expression

b)

b. test expression

c)

c. update expression

d)

d. preincrement expression

42.

This statement causes a loop to terminate early.

a)

a. continue

b)

b. break

c)

c. switch

d)

d. none of the above

43.

This type of loop has no way of ending and repeats until the program is interrupted.

a)

a. indeterminate

b)

b. interminable

c)

c. infinite

d)

d. timeless

44.

The while loop is this type of loop.

a)

pretest

b)

posttest

c)

prefix

d)

postfix

45.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

46.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

47.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

48.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

49.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

50.

In total, how many times is the inner loop executed?

a)

5

b)

10

c)

15

d)

50

e)

Infinite Loop