0% found this document useful (1 vote)
556 views15 pages

CS301 Fall 2022 Data Structures Exam

The document appears to be a sample exam paper for a data structures course. It contains 38 multiple choice questions testing knowledge of data structures concepts like trees, heaps, hashing, graphs, and their applications. The questions cover topics such as AVL trees, compilers, symbol tables, image processing, and various hashing and collision resolution techniques.

Uploaded by

ABDUL WAHAB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
556 views15 pages

CS301 Fall 2022 Data Structures Exam

The document appears to be a sample exam paper for a data structures course. It contains 38 multiple choice questions testing knowledge of data structures concepts like trees, heaps, hashing, graphs, and their applications. The questions cover topics such as AVL trees, compilers, symbol tables, image processing, and various hashing and collision resolution techniques.

Uploaded by

ABDUL WAHAB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Sample Paper

FINALTERM EXAMINATION
Fall 2022
CS301 - Data Structures

Time: 90 min
Marks: 60

Question No: 1 (Marks: 01) - Please choose the correct option

AVL Tree is invented in the year ____________.

A. 1960
B. 1961
C. 1962
D. 1963

Question No: 2 (Marks: 01) - Please choose the correct option

Inserting a node at the right most place would make root’s balance factor ____________.

A. -1
B. -2
C. 1
D. 2

Question No: 3 (Marks: 01) - Please choose the correct option

As compared to BST, the root node in AVL tree is ___________.

A. 0
B. Null
C. Constant
D. Changeable
Question No: 4 (Marks: 01) - Please choose the correct option

In AVL Tree, _______________ traversal gives sorted sequence in ascending order.

A. Inorder
B. Pre-order
C. Post-order
D. Level order Traversal

Question No: 5 (Marks: 01) - Please choose the correct option

_______________ converts assembly language code into machine code i.e. 0s & 1s.

A. Interpreter
B. Compiler
C. Converter
D. Assembler

Question No: 6 (Marks: 01) - Please choose the correct option

After deleting node 15 from above tree, how many rotations do we need to balance the
AVL tree?

A. One Single Rotation


B. One Double Rotation
C. No Rotation
D. Two Single Rotations
Question No: 7 (Marks: 01) - Please choose the correct option

Compiler converts the C++ code into ________________.

A. Assembly language
B. Visual Basic
C. Java
D. Bytecode

Question No: 8 (Marks: 01) - Please choose the correct option

Which one of the following is the application of an Expression Tree?

A. MS Word
B. 2D Paint
C. Spreadsheets
D. Outlook

Question No: 9 (Marks: 01) - Please choose the correct option

What is the height balancing factor in AVL tree?

A. Difference between left and right subtree heights


B. Sum of left and right subtree heights
C. Product of left and right subtree heights
D. Log of left and right subtree heights

Question No: 10 (Marks: 01) - Please choose the correct option

The technique of using binary trees in data compression is referred to as ________.

A. Huffman encoding
B. Heap
C. Graph
D. BST
Question No: 11 (Marks: 01) - Please choose the correct option

What will be the number of external nodes in a binary tree that has 31 internal nodes?

A. 30
B. 31
C. 32
D. 33

Question No: 12 (Marks: 01) - Please choose the correct option

What type of nodes are found in an expression tree?

A. Operators and operands


B. Functions and variables
C. Numbers and symbols
D. Numbers and operands

Question No: 13 (Marks: 01) - Please choose the correct option

What is the maximum number of nodes that a complete binary tree of height 'h' can have?

A. 2^h
B. 2^(h+1) - 1
C. 2^(h-1)
D. 2^h+1

Question No: 14 (Marks: 01) - Please choose the correct option

A max-heap is stored in an array as H = [49, 39, 36, 31, 27, 21, 35, 12].
What is the result of deleting 49 from this heap?

A. [39, 31, 36,12, 27, 21, 35]


B. [39, 36, 31, 27, 21, 35, 12]
C. [39, 36, 12, 31, 27, 35, 21]
D. [39, 35, 31, 36, 12, 27, 21]
Question No: 15 (Marks: 01) - Please choose the correct option

How many types of heap are there?

A. 2
B. 3
C. 4
D. 5

Question No: 16 (Marks: 01) - Please choose the correct option

Heap can be used as ________________

E. Priority queue
F. Stack
G. A decreasing order array
H. Normal Array

Question No: 17 (Marks: 01) - Please choose the correct option

Suppose Min heap is implemented by using an array. Which one of the following array
cannot be a Min heap?

A. 17, 19, 21, 23, 25, 29, 31


B. 17, 21, 19, 25, 23, 31, 29
C. 17, 25, 19, 29, 31, 21, 23
D. 17, 25, 21, 31, 29, 19, 23

Question No: 18 (Marks: 01) - Please choose the correct option

In deletMin method, before calling the percolatedown method( ) the ____ element of the
array will be placed as the root element of the tree.

A. first
B. second
C. third
D. last
Question No: 19 (Marks: 01) - Please choose the correct option

In union operation, the _____ can be used to name the set.

A. Root
B. Left child
C. Right child
D. Leaf node

Question No: 20 (Marks: 01) - Please choose the correct option

Which of the following method takes an array along with its size as an argument and
constructs a heap out of it?

A. Insert( )
B. Buildheap( )
C. Percolatedown()
D. IncreaseKey( )

Question No: 21 (Marks: 01) - Please choose the correct option

How many properties will an equivalent relationship satisfy?

A. 1
B. 2
C. 3
D. 4

Question No: 22 (Marks: 01) - Please choose the correct option

The ___________ method constructs a heap using a single item while maintaining heap
order.

A. Insert( )
B. Buildheap( )
C. Percolatedown()
D. IncreaseKey( )
Question No: 23 (Marks: 01) - Please choose the correct option

Inside the insert method of min heap, we will call the ________ method.

A. isFull()
B. isEmpty()
C. getmin()
D. IncreaseKey( )

Question No: 24 (Marks: 01) - Please choose the correct option

Suppose a relation R = {(2, 2), (5, 5), (5, 2), (5, 5), (6, 6)} on S = {2, 5, 6}. Here R is
known as _________

A. equivalence relation
B. reflexive relation
C. symmetric relation
D. transitive relation

Question No: 25 (Marks: 01) - Please choose the correct option

Which part of the code performs the union of two sets in Union by Size method?

A. The find operation


B. The loop in the find operation
C. The union operation
D. The comparison in the if-condition

Question No: 26 (Marks: 01) - Please choose the correct option

What happens to the number of levels in the trees after a union operation in Union by
Size method?

A. The number of levels increases


B. The number of levels decreases
C. The number of levels remains the same
D. The number of levels cannot be determined
Question No: 27 (Marks: 01) - Please choose the correct option

How is the root node identified in Union by Size method?

A. By setting its parent to -1


B. By setting its parent to the number of nodes in the tree in negative form
C. By finding the node with negative parent
D. By finding the node with positive parent

Question No: 28 (Marks: 01) - Please choose the correct option

How is a raw digital image stored in numbers?

A. Between 0 and 255


B. Between 0 and 4
C. Between 0 and 10
D. Between 0 and 100

Question No: 29 (Marks: 01) - Please choose the correct option

What does the number 0 in the matrix example represent?

A. Gray color
B. Black color
C. White color
D. Red color

Question No: 30 (Marks: 01) - Please choose the correct option

What is the purpose of threshold value in image segmentation?

A. To determine the color of the pixels


B. To group the pixels based on their intensity
C. To calculate the texture of the image
D. To determine the size of the image
Question No: 31 (Marks: 01) - Please choose the correct option

What is a symbol table in compilers?

A. A data structure used to store information about identifiers in the source code.
B. A tool used to debug the code.
C. A technique for compressing the code.
D. A way to generate machine code from the source code.

Question No: 32 (Marks: 01) - Please choose the correct option

What is the function of the union/find algorithm in image segmentation?

A. To convert an image into a binary form


B. To combine pixels into sets based on their values
C. To divide an image into different parts
D. To make a program for image processing

Question No: 33 (Marks: 01) - Please choose the correct option

Suppose a hash table already contains some numbers using the key “K” and hash function
K % 13. If the number 37 is already in the hash table, then adding which of the following
number will cause a collision?

A. 1141
B. 1142
C. 1143
D. 1144

Question No: 34 (Marks: 01) - Please choose the correct option

In open addressing to resolve the collision in hashing we ____________.

A. Check next position one by one to find an empty place


B. Check odd positions to find an empty place
C. Check even positions to find an empty place
D. Open addressing is not a collision resolution technique
Question No: 35 (Marks: 01) - Please choose the correct option

Which of the following technique is/are used by compiler to construct a symbol table?

A. Hashing
B. Linked List
C. Binary Search Tree
D. All Hashing, Linked list and BST are used

Question No: 36 (Marks: 01) - Please choose the correct option

Data structure which is used to search an element in constant time is called ___________.

A. Linked List
B. Binary Search Tree
C. AVL Tree
D. Hashing

Question No: 37 (Marks: 01) - Please choose the correct option

Which of the following is not a collision avoidance technique?

A. Linear Probing
B. Rehashing
C. Linked list
D. Increase the size of table

Question No: 38 (Marks: 01) - Please choose the correct option

Selecting a card from deck of cards and arranging them in an order is an example of
_________.

A. Insertion sort
B. Selection sort
C. Merge sort
D. Heapsort
Question No: 39 (Marks: 01) - Please choose the correct option

Which of the following sorting algorithm do not use swapping technique while sorting
the data?

A. Insertion sort
B. Selection sort
C. Merge sort
D. Quicksort

Question No: 40 (Marks: 01) - Please choose the correct option

Which of the following sorting algorithm uses pivot value to split the array?

A. Selection sort
B. Insertion sort
C. Merge sort
D. Quicksort

Question No: 41 (Marks: 03)

Explain the scenario with the help of a diagram, in which balance factor of an AVL Tree
root node comes out to be -1.

Answer
Question No: 42 (Marks: 03)

Consider the following heap:

11
/ \
6 10
/ \ / \
4 3 8 9
/
2

(a) Is it a heap? Justify with solid reason


(b) Show the array representation of this tree.

Answer

Question No: 43 (Marks: 03)

Define and explain the disjoint set with examples.

Answer

Question No: 44 (Marks: 03)

What is the purpose of Image Segmentation?

Answer

Question No: 45 (Marks: 03)

How does the union/find algorithm work in image segmentation?

Answer
Question No: 46 (Marks: 03)

Consider the C++ code of “hashFunc” given below, if fruit name “banana” is passed to
this function as an argument then what will be return value of “hashFunc”?

Note: The ASCII code of a = 97, b = 98 and n = 110.

int hashFunc(char* s) {
int i, sum = 0;

for(i=0; i<strlen(s); i++) {


sum = sum + s[i];
}
return sum % 11;
}

Answer

Question No: 47 (Marks: 05)

Construct AVL tree by inserting the following data (read the from left to right):
14,17,11,7,53,4,13,12,8,60,19,16,20
Just show the final tree, you don’t need to show all steps.

Answer

Question No: 48 (Marks: 05)

Construct Huffman tree from the following data:

Answer
Question No: 49 (Marks: 05)

In case of implementing minimum heap, write down the code of perculateDown()


method.

Answer

Question No: 50 (Marks: 05)

Consider the C++ code of a sort algorithm given below. If array showing in table is
passed to sorting algorithm, then what will be the index of “29” after execution of code?

void mySort(int *arr, int N) {

int temp;

for (int i = 0; i < N - 1; i++) {


int min = i;

for (int j = i + 1; j < N; j++) {


if (arr[j] < arr[min])
min = j;
}

temp = arr[min];
arr[min] = arr[i];
arr[i] = temp;

if(i == 3)
break;
}
}

29 27 18 13 87 66 52 51 12 36
0 1 2 3 4 5 6 7 8 9

Give only one index, giving more than one indexes will be considered incorrect solution.

Answer
Best of Luck 

You might also like