wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FINALS Data Structure and algorithm

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?

a)

ABCD

b)

DCBA

c)

DCAB

d)

ABDC

2.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

3.

LIFO stands for

a)

List of Outputs

b)

Last in First Out

c)

First in Last Out

d)

None of them

4.
What kind of Data structure would you expect to find utilised to store operations in a CPU?
a)
Stack
b)
Queue
c)
List
d)
Tree
5.

It use pointer to link nodes.

a)

Variable

b)

Link List

c)

Pointer

d)

Trees

6.

A FIFO structure implemented as a ring where the front and rear pointers can wrap around the end of the start of the array.

a)

Linear Queue

b)

Circular Queue

c)

Priority Queue

7.
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
8.
Which of the following is NOT a Type of Data Structures?
a)
Arrays
b)
Tables
c)
Stacks
d)
Trees
9.

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)

10.

Which of these data structures is LIFO?

a)

Stack

b)

Queue

c)

Binary Tree

d)

Double linked list

11.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
12.

Example of linear data structure except

a)

array

b)

tree

c)

queue

d)

stack

13.
The first element in an array is always element 1.
a)
False
b)
True
14.
Arrays always have the same...
a)
data types
b)
text types
c)
numbers
d)
types of data
15.
Arrays are collection of the same data type under a single identifier.
a)
True
b)
False
16.
Values in arrays cannot be changed.
a)
False
b)
True
17.
The first and last elements of an array declared as scores[10] is...
a)
scores[0], scores[9]
b)
scores[1], score [11]
c)
scores[4], scores[3]
d)
score[0], score[9]
18.
myArray[0] + myArray[1] adds the first two values in an array together.
a)
True
b)
False
19.
Array elements can be used the same as any other variable.
a)
True
b)
False
20.
When an array is declared it will always be empty.
a)
False
b)
True
21.
The structure of an array cannot be changed once it is created.
a)
False
b)
True
22.
Loops are useful for cycling through an array.
a)
True
b)
False
23.

If for an algorithm time complexity is given by O(n) then complexity of it is:

a)

linear

b)

exponential

c)

constant

d)

none of the mentioned

24.

Data in the data structures are processed by operations like insertion, deletion, sorting, merging and ______________

a)

A. Traversing

b)

B. Searching

c)

C. Retrieval

d)

D. Both A and B

25.

If the insertion and deletion happens from both the ends then the deletion is called a ______

a)

Deque

b)

Enqueue

c)

peek

d)

full

26.

If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?

a)

CBA

b)

ABDC

c)

ABCD

d)

DCAB

27.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

Prints all nodes of linked lists

b)

Prints alternate nodes of Linked List

c)

Prints all nodes of linked list in reverse order

d)

Prints alternate nodes in reverse order

28.

Efficiency of an algorithm is measured by

a)

Time and Space complexity

b)

Speed and Capacity complexity

c)

Speed and Space complexity

d)

Time and Capacity complexity

29.

Which of the following data structures are mutable?

a)

Array

b)

List

c)

Tuple

d)

Enum

30.

It refers to collection of variables, possibly of several different data types connected in various ways.

a)

Database

b)

Arrays

c)

Data Structures

d)

Abstraction

31.

Data that a variable can hold in a programming language, all programming language has a set of it.

a)

Algorithms

b)

Variables

c)

Data Types

d)

Programming

32.

Finite set of instructions that specify a sequence of operations to be carried out

a)

Flowcharting

b)

Algorithms

c)

Procedure

d)

Pseudocodes

33.

Linear Search checks every element of a list one at a time in sequence, also called as sequential search.

a)

MAYBE

b)

TRUE

c)

FALSE

d)

None of the Choices

34.

Which of the following definitions of Array Terms is CORRECT?

a)

Elements - individual data / items in an array indicated by the array name followed by its dimensions appears in a square brackets

b)

Index - each variable or cell in an array

c)

Dimensions - an integer from 1 - n called dimensioned variables

d)

All of the Choices

35.

What is returned by values[5]?

a)

6

b)

9

c)

8

d)

12

36.

A Queue can only store 6 data items. The Queue has sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?

a)

0

b)

1

c)

2

d)

3

37.

A Queue can only store 6 data items. The Queue has sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point if a deQueue operation is performed.

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

38.

In terms of an array, what is an index?

a)

he first element in an array

b)

A value which points to a data element in an array

c)

A list of all the elements in an array

39.

Does Abstracts Data Types support the programmer's efficiency?.

a)

Yes

b)

No

40.

choose the two types of the Data

a)

Primitive Data Type

b)

return

c)

User defined Data

d)

void

41.

What is an algorithm?

a)

placeholders for representing data

b)

is a sequence of instructions or a set of rules that are followed to complete a task.

c)

Something that comes somewhere in between formatted English and computer program code

d)

The arrangement of and relations between

the parts or elements of something.

42.

Correct code to define a list C++?

a)

Int[] scores = {15, 29, 4, 50};

b)

int scores [4]= {15, 29, 4, 50}

c)

int scores = (15, 29, 4, 50)

d)

none of the above

43.

It use pointer to link nodes.

a)

Variable

b)

Trees

c)

Pointer

d)

Link List

44.

In doing shell sort algorithm, what will you do after you swapped the values using the Knuth's formula and the interval of 1?

a)

Sort the remaining sub list using bubble sort

b)

Identify the pivot value then implement merge sort

c)

Use insertion sort

d)

all of the above

45.

Why do we use the isFull() function in a queue?

a)

A. to identify if the list has any available position, so we can add if there is or send an overflow error message otherwise

b)

B. to detect the size of the list then resize it when necessary to adjust the size of the queue

c)

both A and B

d)

no answer

46.

It talks about arranging data in a particular format, whether ascending or descending.

a)

Searching

b)

Stacking

c)

Queueing

d)

Sorting

47.

Bonus question: what is the significance of learning Data Structures and understanding the use of algorithm in day to day life as an IT person?

4 lines
48.

What is the degree of vertex 4?

a)

3

b)

4

c)

5

d)

7

49.

Which two vertices are adjacent vertices?

a)

5 is adjacent to 6

b)

3 is adjacent to 6

c)

4 is adjacent to 1

d)

3 is adjacent to 2

50.

The graph represents the following vocabulary term.

a)

Cycle

b)

Path

c)

Complete Graph

d)

Complete Bipartite Graph

51.

What is the weight of the shortest path from A to F?

a)

5

b)

7

c)

9

d)

11

52.

Which vertices are adjacent to E?

a)

B and C

b)

B, C, D, and A

c)

B

d)

A, B, C, D, F, G

53.

Which is an example of a disconnected graph?

a)
b)
c)
d)
e)

None are disconnected graphs

54.

Which of the following is not a style of graph traversal in computing?

a)

Breadth-First

b)

Depth-First

c)

Height-First

55.

Which method of graph traversal makes use of a stack?

a)

Depth-First

b)

Breadth-First

56.

Which method of graph traversal makes use of a queue?

a)

Depth-First

b)

Breadth-First

57.

Which order of traversal is correct using depth-first?

a)

A B C G D E F

b)

A B D C E C G

58.

Which of the following beginnings to a graph traversal would not be correct for depth-first?

a)

A B C G

b)

A D F

c)

A E D F

d)

A B D C

59.

Which order of traversal is correct using breadth-first?

a)

A B D E C F G

b)

A B C G D E F

60.

A has been visited what happens next

a)

Visit B

b)

Visit D

c)

Visit E

d)

Visit C

61.

With breadth-first traversal, which node will be visited next?

a)

C

b)

F

c)

G

62.

A _________ is a simple path is which the first and last vertices are same

a)

Cycle

b)

Circular