You are on page 1of 3

United​ International ​University

Department of Computer Science and Engineering


Course Code: CSE 5003 Course Title: Data Structure & Algorithm
Mid Term Exam | Duration: 1 hr 45mins | Marks: 30 Section: M

There are ​4​ questions. Answer any ​3​. Each question carries 10 marks.

1. (a) Show the step by step working mechanism of ​descending order Insertion Sort​ for the
data given: 9 8 20 38 22 47 [5]
(b) Sort the following elements in ​ascending order​ using ​any one​ of these two sorting
techniques - ​a. Bubble Sort ​and​ b. Selection Sort. ​[5]
​19 8 20 18 22 77 37
Show the step by step working mechanism of your sorting technique.

2. (a) Draw step by step diagram(s) to show how a new node containing element ​30 ​can be
inserted ​at​ a. first ​and​ b. last ​of a linear linked list. [4]
(b) Show the steps for deleting the node containing element​ 3​ from the following linked list:
[3]

(c) Draw a stack for each of the given stack operation. Perform operations from left to right:
push(5), pop(), push(15), push(7), pop(), push(9), push(5), pop().
You need to draw the current stack after each of these operations.
[3]
3. (a) How many edges are required for a ​directed graph​ having n nodes to be a complete
graph? .​ ​[1]
(b) Find a ​simple cycle​ in the following graph. Also, find the ​degree of node D​ in the graph.
[2]
(c) Now, show the adjacency list for the same graph above​. ​[3]
(d) Consider the following adjacency matrix for a graph. Now draw the graph from the given
matrix. [4]

4. (a) Time complexity of counting sort is O(n), whereas, time complexity of insertion, selection
and bubble sort is O(n​2​) in worst case. Is it possible that that the counting sort performs worse
than the other mentioned sorts for any particular case? Justify your answer.
[1]
(b) Show the ​preorder​ and​ postorder​ traversal of the following tree:
[3]

(c) Show the mechanism of the Binary Search algorithm step by step (calculation of high, lor
and mid) for the search key a) 80 and b) 15 using the data mentioned below :
[6]
10 20 30 40 50 60 70 80 90 100
Consider the following undirected graph:

(a) Show adjacency structure of the above graph.

(b) Show DFS (Depth First Search) sequence of the above graph.

You might also like