Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Spanning Tree - Data Structures - Exam, Exams of Data Structures and Algorithms

Main points of this exam paper are: Spanning Tree, Space Provided, Data Structure, Partial Credit, Items Requires, Spanning Tree, Implementation

Typology: Exams

2012/2013

Uploaded on 04/07/2013

sethuraman_h34rt
sethuraman_h34rt 🇮🇳

4.3

(8)

159 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 13
CSE 326, Data Structures
Sample Final Exam
Instructions:
The exam is closed book, closed notes.
Unless otherwise stated, N denotes the number of elements in the data structure
under consideration.
Answer each problem in the space provided.
Show your work to ensure partial credit.
Time: 110 minutes
Problem Max Points Score
1 14 (2x7)
2 18 (3x6)
3 4
4 7
5 9
6 16
7 8
8 4
9 8
10 4
Total 92
Name:
Email ID:
Section:
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Spanning Tree - Data Structures - Exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

CSE 326, Data Structures

Sample Final Exam

Instructions :  The exam is closed book, closed notes.  Unless otherwise stated, N denotes the number of elements in the data structure under consideration.  Answer each problem in the space provided.  Show your work to ensure partial credit.

Time: 110 minutes

Problem Max Points Score

1 14 (2x7)

2 18 (3x6)

Total 92

Name:

Email ID:

Section:

  1. [14 points total, 2 points each] True/False. Circle True or False below. You do not need to justify your answers.

a Linear probing is equivalent to double hashing with a secondary hash function of h 2 ( k ) = 1.

True False

b. If T 1 (N) = O(f(n)) and T 2 (N) = O(f(n)), then T 1 (N) = O(T 2 (N)). True False

c. Building a heap from an array of N items requires Ω(N log N) time.

True False

d. Dijkstra’s algorithm for shortest path and Prim’s minimum spanning tree algorithm have the same big-Oh worst case running time.

True False

e. Both Prim’s and Kruskal’s minimum spanning tree algorithms work correctly if the graph contains negative edge weights.

True False

f. For large input sizes, mergesort will always run faster than insertion sort (on the same input).

True False

g. Merging heaps is faster with binary heaps than with leftist or skew heaps, because we only need to concatenate the heap arrays and then run BuildHeap on the result.

True False

  1. [18 points total] Short Answer Problems: Be sure to answer all parts of the question!!

a) [3 points] Which ADT do binomial queues implement? If we forget simplicity of implementation, are they better than binary heaps? Are they better than leftist heaps? Justify your answer.

f) [3 points] Fill in the blank in the following text to make the statement true.

In the union/find data structure of N items, if we use union-by-size without path compression , then any combination of M union and/or find operations takes at most _________________ time.

  1. [4 points total] Minimum spanning tree (MST) Given a weighted, undirected graph with |V| nodes, answer the following as best as possible, with a brief explanation. Assume all weights are non-negative.

a) [2 points] If each edge has weight ≤ w , what can you say about the cost of an MST?

b) [2 points] If the cost of an MST is c , what can you say about the shortest distances returned by Dijkstra’s algorithm when run with an arbitrary vertex s as the source?

  1. [7 points total] Disjoint Sets:

Consider the set of initially unrelated elements 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.

a.) (5 pts) Draw the final forest of up-trees that results from the following sequence of operations using on union-by-size. Break ties by keeping the first argument as the root.

Union(0,2), Union(3,4), Union(9,7), Union(9,3), Union (6,8), Union(6,0), Union(12,6), Union(1,11), Union(9,6).

b.) (2 pts) Draw the new forest of up-trees that results from doing a Find(4) with path compression on your forest of up-trees from (a).

b) [2 points] Draw the binary min heap that results from doing 2 deletemins on the heap you created in part a). You are only required to show the final heap, although if you draw intermediate heaps please circle your final result for ANY credit.

c) [1 point] What is the null path length of the root node in the last heap you drew in part b) above?

d) [2 points] List 2 good reasons why you might choose to use a skew heap rather than a leftist heap.

  1. [16 points total] Graph Manipulations:

Use the following graph for this problem. Where needed and not determined by the algorithm, assume that any algorithm begins at node A.

B

D

A

C

E

a) (4 pts) Draw both the adjacency matrix and adjacency list representations of this graph. Be sure to specify which is which.

b) (2 pts) Give two valid topological orderings of the nodes in the graph.

7) [8 points] Splay trees

Imagine that the following operations are performed on an initially empty splay tree: Insert(1), Insert(10), Insert (5), Insert (3), Insert (7), Insert (13), Find (3). Show the state of the splay tree after performing each of the above operations. Be sure to label each of your trees with what operations you have just completed.

  1. [4 points ] Draw the contents of the hash table in the boxes below given the following conditions:

The size of the hash table is 12. Open addressing and quadratic probing is used to resolve collisions. The hash function used is H(k) = k mod 12

What values will be in the hash table after the following sequence of insertions? Draw the values in the boxes below, and show your work for partial credit.

33, 10, 9, 13, 12, 45

10) [4 points] B-trees

Given the following parameters:

Disk access time = 1milli-sec per byte 1 Page on disk = 1024 bytes Key = 16 bytes Pointer = 4 bytes Data = 128 bytes per record (includes key)

(4 pts) What are the best values for: M = L =