• Sonuç bulunamadı

Karadeniz Technical University Department of Computer Engineering

N/A
N/A
Protected

Academic year: 2021

Share "Karadeniz Technical University Department of Computer Engineering "

Copied!
2
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

Karadeniz Technical University Department of Computer Engineering

Lecturer Omer CAKIR

COM 205 Data Structures

Condition Exam, 30.01.2014, 10:00, D-1 Time : 90 Minutes

NUMBER : ……… NAME : ………...

Rules to be Obeyed During the Exam SIGNATURE : ………...

EXAM GRADE

[

...

]

...

1. Cell phones are not allowed to be used as a calculator or a watch. They must be switched off and placed in the pocket.

2. Brief information about the exam will be given at the begining, then no one is not allowed to ask a question during the exam.

3. Do not to forget to sign this paper after writing your number and name.

void right(int i, int p, int n, int k, int s) {

s += i;

if(n == k) {

cout << s << endl;

return;

}

else right(i+p, p, n+1, k, s);

}

void down(int i, int p, int n, int k) {

if(n == k) cout << i << endl;

else right(i, p, 1, k, 0);

if(i == 1) return;

else down(i/2, p/2, 1, k*2);

}

void main() {

down(8, 16, 1, 1);

}

Output

1. What is the output of the program above? (25P)

1 2 3 4 5 6 7

2. Insert the elements above into a Heap according to the code below.

Hint  root is max element instead of min. (25P)

bool isLess(const int& e, const int& f) {

if(e<f) return true; else return false;

}

void insert(const int& e) {

T.addLast(e);

Position v = T.last();

while (!T.isRoot(v)) {

Position u = T.parent(v);

if (isLess(*v, *u)) break;

T.swap(v, u);

v = u;

} }

(2)

2 4 6 1 3 5

3. Insert elements above into a Splay Tree. (25P)

4

2 6

1 3 5 7 8 9

4. Remove 5 from the 2-3-4 Tree above. (25P)

Referanslar

Benzer Belgeler

We construct a family of partition identities which contain the following identi- ties: Rogers-Ramanujan-Gordon identities, Bressoud’s even moduli generalization of them, and

Given 6 pictures of different people, and 3 descriptions of 3 of these pictures, the student will be able to identify which description belongs to which picture and be able

 Students will be asked to report their observations and results within the scope of the application to the test report immediately given to them at the end of

 Students will be asked to report their observations and results within the scope of the application to the test report immediately given to them at the end

Students have to obey Engineering Faculty Exam Execution Instructions.. Assume that the numbers above are inserted into a

Assume that numbers of each choice are inserted into a seperate binary tree.. In this case one tree is different from

Students have to obey Engineering Faculty Exam Execution Instructions.. Assume that the numbers above are inserted into a

Exam Execution Instructions of Faculty of Enginnering should be obeyed.. Complete the