wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA Finals

Total questions: 87

Worksheet time: 57mins

Name
Class
Date
1.

This operation adds an item to the queue.

a)

Dequeue

b)

Enqueue

c)

Pop

d)

Push

2.

It represents the hierarchical nature of a structure in a graphical form.

a)

Linked List

b)

Queue

c)

Stack

d)

Tree

3.

It is the number of child nodes in a subtree.

a)

Degree

b)

Depth

c)

Level

d)

Subtree

4.

Which Java package contains the Queue interface?

a)

java.awt

b)

java.oi

c)

java.util

d)

javax.swing

5.

If a tree consists of nodes where each has two (2) child nodes at most, what is it called?

a)

Binary Tree

b)

Dual Tree

c)

Double Tree

d)

Twin Tree

6.

This operation removes an item from the top of the stack.

a)

Peek

b)

Pop

c)

Pull

d)

Push

7.

It is an ordered list in which the first element added is the first element retrieved or removed.

a)

Linked List

b)

Queue

c)

Stack

d)

Tree

8.

Which Java package contains the Stack class?

a)

java.awt

b)

java.oi

c)

java.util

d)

javax.swing

9.

What is the process of visiting all the nodes in a specific order?

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Traversal

10.

What do you call a node that has no child nodes?

a)

Internal Node

b)

Parent Node

c)

Leaf Node

d)

Root Node

11.

It is the measure of a node's distance from its root.

a)

Degree

b)

Edge

c)

Level

d)

Subtree

12.

It is a tree within a tree.

a)

Degree

b)

Depth

c)

Level

d)

Subtree

13.

This is the tree's highest level.

a)

Degree

b)

Depth

c)

Edge

d)

Subtree

14.

This operation removes an item from the queue.

a)

Dequeue

b)

Enqueue

c)

Pop

d)

Push

15.

This operation adds an item to the top of the stack.

a)

Peek

b)

Pop

c)

Pull

d)

Push

16.

Which method should be used if you need to dequeue an item in Java without encountering an exception?

a)

element()

b)

offer()

c)

poll()

d)

remove()

17.

Which represents the root node in the given file path? C:\Users\bpena\Desktop\Midterm

a)

C.

b)

Users

c)

bpena

d)

Midterm

18.

Which of the following is NOT a step in evaluating a postfix expression?

a)
  • If the token is an operator, push it to the stack.

b)
  • If the token is an operator, perform two (2) pop operations.

c)
  • Classify the token as operand or operator.

d)
  • Push the result of the two (2) popped operands to the stack after performing the required operation.

19.
  1. Which of the following is NOT a step in converting an infix into a postfix expression?

a)
  • If the token is an operand, append it to the postfix expression.

b)
  • If the token is an operator, push it to the stack if empty.

c)
  • If a left parenthesis is encountered, pop all the elements until a right parenthesis is encountered.

d)
  • Classify the token as operand or operator.

20.

What is the tree's depth?

a)

0

b)

1

c)

2

d)

3

21.
  1. Which of the following is a correct import statement in Python?

a)
  • deque from collections import

b)
  • from collections import deque

c)
  • import collections from deque

d)
  • import from collections deque

22.

How many one-level subtree does the tree have?

a)

0

b)

1

c)

2

d)

3

23.

Complete the Java code below.

Queue queue = new LinkedList();

_____.offer("Ma'am BK");

a)

add

b)

LinkedList

c)

Queue

d)

queue

24.

How many nodes are represented in the given file path? C:\Users\bpena\Downloads\Midterm

a)

1

b)

2

c)

4

d)

5

25.

How many directories represent child nodes in the given file path? C:\Users\bpena\Documents\Midterm

a)

1

b)

2

c)

4

d)

5

26.

Which directory represents the leaf node in the given file path? C:\Users\bpena\Documents\Midterm

a)

C:

b)

Users

c)

bpena

d)

Midterm

27.

Which method should be used if you need to identify the first item in a queue?

a)

enqueue()

b)

offer()

c)

peek()

d)

poll()

28.

Which causes an error in the following statements?

Stack stack = new Stack();

stack.push();

a)

Stack

b)

stack

c)

new

d)

push()

29.

How many directories represent parent nodes in the given file path? C:\Users\bpena\Desktop\Midterm

a)

1

b)

2

c)

4

d)

5

30.

Which of the following is NOT an example of a palindrome?

a)

data

b)

eve

c)

madam

d)

refer

31.

Consist of a set of vertices (nodes) and a set of edges (relations) between the pairs of vertices.

a)

Graph

b)

Priority Queue

c)

Map

d)

Set

32.

As presented in the graph, what are the vertices (V)?

a)

{A, B, C, D, E}

b)

{ {A, B}, {A, C}, {C, D}, {D, E} }

c)

{A, B, C, d, E}

d)

{ {A, B}, {A, C}, {C, D}, {A, E} }

33.

As presented in the graph, what are the edges (E)?

a)

{ {A, B}, {A, C}, {C, D}, {A, D} }

b)

{ {A, B}, {A, C}, {C, D}, {D, E} }

c)

{ {A, B}, {A, C}, {B, C}, {C, D} }

d)

{ {A, B}, {A, C}, {C, D}, {A, E} }

34.

Digraph is also known as?

a)

Directed Graph

b)

Undirected Graph

c)

Mixed Graph

d)

Simple Graph

35.

Vertices is also known as?

a)

Nodes

b)

Relations

c)

Edges

d)

Lines

36.

Edges is also known as?

a)

Nodes

b)

Relations

c)

Vertices

d)

Lines

37.

Weighted Graph

a)

Consist of edges that are associated with values.

b)

Consist of vertices that are associated with values.

c)
  • Consist of edges that have no values.

d)
  1. Consist of edges that are connected in a circular pattern.

38.

Which is true about Vertex?

a)

A vertex is adjacent to another vertex if there is an edge to it from that other vertex.

b)
  • A vertex is adjacent to another vertex if they are the same vertex.

c)
  • A vertex is adjacent to another vertex if there is no edge between them.

d)
  1. A vertex is adjacent to another vertex if it is part of a different graph.

39.

What are the edges?

a)

{ {A, B}, {B, C}, {C, E}, {D, B}, {E, D} }

b)

{ {A, B}, {B, C}, {C, E}, {D, B}, {E, B} }

c)

{ {A, B}, {B, C}, {C, D}, {D, B}, {E, D} }

d)

{ {D, B}, {B, C}, {C, E}, {D, B}, {E, D} }

40.

Adjacent of A?

a)

B and C

b)

C and E

c)

A and D

d)

B

41.

Which is true about Degree?

a)

The degree of a vertex is the number of edges which has that vertex as an endpoint.

b)

The degree of a vertex is the number of vertices connected to it.

c)

The degree of a vertex is the number of edges that do not connect to it.

d)
  1. The degree of a vertex is the total number of vertices in the graph.

42.

What is the Degree of Vertex A?

a)

2

b)

1

c)

3

d)

4

43.

What is the Degree of Vertex A?

a)

2

b)

1

c)

3

d)

4

44.

What is the Degree of Vertex E?

a)

2

b)

1

c)

3

d)

4

45.

Is a sequence of adjacent vertices.

a)

Path

b)

Graph

c)

Node

d)

Edge

46.

Is a square matrix with dimensions equivalent to the number of vertices in the graph.

a)

Adjacency Matrix

b)

Adjacency List

c)

Path

d)

Degree

47.

It is used to indicate whether pairs of vertices are adjacent or not.

a)

Adjacency Matrix

b)

Adjacency List

c)

Path

d)

Degree

48.

Uses an array of lists to represent a graph.

a)

Adjacency Matrix

b)

Adjacency List

c)

Path

d)

Degree

49.

It is used to indicate whether pairs of vertices are adjacent or not.

a)

Adjacency Matrix

b)

Adjacency List

c)

Path

d)

Degree

50-54.

Identify the elements in the Adjacency Matrix

50.

1

(a)  

51.

2

(a)  

52.

3

(a)  

53.

4

(a)  

54.

5

(a)  

55-59.

Identify the elements missing in the Adjacency List

55.

A

(a)  

56.

B

(a)  

57.

C

(a)  

58.

D

(a)  

59.

E

(a)  

60.

Which Java package contains the Graph class?

a)

ArrayList<ArrayList> name = new ArrayList<>();

b)

ArrayList<ArrayList> name = new ArrayList<>():

c)

ArrayList<ArrayList> name = new ArrayList()<>;

d)

Graph<Graph> name = new Graph<>();

61.

Is the process of arranging data in specific order.

a)

Sorting

b)

Filtering

c)

Searching

d)

Grouping

62.

Every pair of adjacent items is compared and items are swapped until they are in order.

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Shell Sort

63.

The smallest unsorted item is chosen and then swapped with the item in the next position to be filled.

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Shell Sort

64.

The comparison applies to adjacent items and previously scanned items.

a)

Merge Sort

b)

Selection Sort

c)

Insertion Sort

d)

Shell Sort

65.

Utilizes a decreasing interval sequence to sort elements, often starting with a sequence like N/2, N/4, ..., 1, and eventually applying Insertion Sort when the interval reaches 1

a)

Merge Sort

b)

Selection Sort

c)

Insertion Sort

d)

Shell Sort

66.

The list is divided into sorted sub-lists then combined into a single sorted list.

a)

Merge Sort

b)

Selection Sort

c)

Insertion Sort

d)

Shell Sort

67.

How would you declare and initialize a Sorting in Java?

a)

ArrayList values = new ArrayList();

b)

Sort values = new Sort();

c)

Sort <Sort> values = new Sort<>();

d)

ArrayList values = new Sort();

68.

ArrayList values = new ArrayList();

Collections.addAll(values, 5, 1, 10);

Collections.sort(value);

a)

1, 5, 10

b)

Error

c)

5, 1, 10

d)

10, 1, 5

69.

ArrayList values = new ArrayList();

Collections.addAll(values, 5, 1, 10);

Collections.sort(values);

a)

1, 5, 10

b)

Error

c)

5, 1, 10

d)

10, 1, 5

70.

values = [1, 7, 4]

values.sort(values)

a)

Error

b)

1, 4, 7

c)

1, 7, 4

d)

4, 1, 7

71.

values = [1, 7, 4]

values.sort()

a)

Error

b)

1, 4, 7

c)

1, 7, 4

d)

4, 1, 7

72.

Is the science of training machines to perform human tasks.

a)

Artificial Intelligence

b)

R.U.F.F.Y AI

c)

Machine Learning

d)

Machine Learning Model

73.

Which of the following is not a subset of AI?

a)

Reasoning

b)

Natural Language Processing

c)

Machine Learning

d)

Quantum Computation

74.

Making inferences based on data.

a)

Reasoning

b)

Natural Language Processing

c)

Planning

d)

Quantum Computation

75.

Understanding both written text and human speech.

a)

Reasoning

b)

Natural Language Processing

c)

Planning

d)

Quantum Computation

76.

Acting autonomously and flexibly to construct a sequence of actions to reach a final goal.

a)

Reasoning

b)

Machine Learning

c)

Planning

d)

Quantum Computation

77.

Is a form of artificial intelligence that enables a system to learn from data, identify patterns, and make decisions with minimal human intervention.

a)

Reasoning

b)

Machine Learning

c)

Planning

d)

Quantum Computation

78.

Common examples of machine learning Except

a)

When you search and view products in an online shopping site, you may encounter other similar products that you may find interesting the next time you go online.

b)

Virtual assistants like Siri and Alexa, are asked over voice when you need to find information.

c)

Transportation apps suggest faster routes and computes prices of rides based on the rider demand.

d)

Calculators perform basic arithmetic operations (addition, subtraction, multiplication, division) based on predefined rules and user input.

79.

Which of the following is not a purpose of machine learning?

a)

Classification

b)

Clustering

c)

Prediction

d)

Data Entry

80.

Classifying an item into a distinct set of categories (Ex. Recognizing the object in an image)

a)

Classification

b)

Clustering

c)

Prediction

d)

Data Entry

81.

Grouping items with common properties (Ex. Facebook suggesting people to add in a group)

a)

Classification

b)

Clustering

c)

Prediction

d)

Data Entry

82.

Forecasting future values (Ex. Demand for products around holiday season)

a)

Classification

b)

Clustering

c)

Prediction

d)

Data Entry

83.

Is the output generated when you train your machine learning algorithm with data.

a)

Artificial Intelligence

b)

R.U.F.F.Y AI

c)

Machine Learning

d)

Machine Learning Model

84.

The machine is provided with an established set of data (labeled data).

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning

85.

The machine is provided with a set of data but is not provided with a specific answer (unlabeled data). The machine may identify trends of similarity through clustering.

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning

86.

The machine learns from a dataset that includes both labeled and unlabeled data, usually most

unlabeled.

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning

87.

The machine learns through trial and error. It is often used for robotics, gaming, and navigation. It has three (3) primary components.

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning

88.

What are the categories of Supervised Learning under Machine Learning Model? (2)

a)

Classification

b)

Regression

c)

Inference

d)

Insertion

89.

Predicting the values of a continuous variable.

Ex. Weather forecasting provides a prediction on the weather based on historical weather patterns and the current conditions.

Supervised Learning under Machine Learning Model?

a)

Classification

b)

Regression

c)

Inference

d)

Insertion

90.

What are the components of Reinforcement Learning under Machine Learning Model? (3)

a)

Agent

b)

Environment

c)

Action

d)

Equation

91.

The learner or decision maker (self-driving car)

a)

Agent

b)

Environment

c)

Action

d)

Equation

92.

Everything the agent interacts with (streets other cars, human drivers, etc.)

a)

Agent

b)

Environment

c)

Action

d)

Equation

93.

What the agent can do (drive, pick lane, etc.)

a)

Agent

b)

Environment

c)

Action

d)

Equation

94.

Identifying whether an e-mail is a spam or not is an example of which machine learning model?

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning

95.

A self-driving car is an example of which machine learning model?

a)

Supervised Learning

b)

Unsupervised Learning

c)

Semi-Supervised Learning

d)

Reinforcement Learning