• Sonuç bulunamadı

Karadeniz Technical University Department of Computer Engineering Lecturer Omer CAKIR COM 205 Data Structures Final Exam, 01.10.2013, 10:00, D-1, D-8 Time : 100 Minutes

N/A
N/A
Protected

Academic year: 2021

Share "Karadeniz Technical University Department of Computer Engineering Lecturer Omer CAKIR COM 205 Data Structures Final Exam, 01.10.2013, 10:00, D-1, D-8 Time : 100 Minutes"

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

Final Exam, 01.10.2013, 10:00, D-1, D-8 Time : 100 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 print1(DoublyNode* node) {

cout << node->elem << endl;

if (node->next == trailer) return;

else print1(node->next);

}

void print2(DoublyNode* node) {

if (node == trailer) return;

else print2(node->next);

cout << node->elem << endl;

}

void main() {

DoublyLinkedList list;

list.insertOrdered("Paul", 720); // küçükten list.insertOrdered("Rose", 590); // büyüğe list.insertOrdered("Anna", 660); // sıralı ekle

list.print1(list.header->next); //(1) list.print2(list.header->next); //(2) list.print3(list.trailer->prev); //(3) list.print4(list.trailer->prev); //(4) }

1.

a) Write down the outputs of the functions print1() and print2() when called with header->next parameter in the main() function. (10P)

print1() Print2()

b) Write down print3() that is equavalent to print1() and print4() that is equavalent to print2() when called both with trailer->prev parameter in the main() function.

Hint  Answers take 3 lines.

void print3(DoublyNode* node) // print1() {

//5P //5P //5P }

void print4(DoublyNode* node) // print2() {

//5P //5P //5P }

void removeOrdered(const string& e, const int& i) {

DoublyNode* current = header->next;

while (current != trailer) {

if((current->elem == e) && (current->score == i)) {

...;

...;

delete current;

return;

}

current = current->next;

}

cout << e << " is not found" << endl;

}

2.

Complete removeOrdered() function above that removes an element from a doubly linked list. (10P)

(2)

6 5 4 3 2 1 7

3.

Insert the elements above into a splay tree? (20P)

8 4

2 6

3 5 7

12

10 14

9 11 13 15 1

24 20

18 22

19 21 23

28

26 30

25 27 29 31 17

16

4 2

1 3

6

5 7

12 16

10 14

11 13 15 9

20 18

17 19

22

21 23

28

26 30

25 27 29 31

4.

Complete codes below that deletes 8 and 24 from binary tree like above. (30P)

if( p->left != NULL && p->right != NULL) {

if(parent->left == p) {

parent->... = p->...;

p->... = parent;

temp = p->...;

while(temp->... != NULL) temp = temp->...;

temp->... = p->...;

temp->... = temp;

} else {

parent->... = p->...;

p->... = parent;

temp = p->...;

while(temp->... != NULL) temp = temp->...;

temp->... = p->...;

temp->... = temp;

}

delete p;

}

Referanslar

Benzer Belgeler

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

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

Write words from dictionary.txt to relative.txt using Hash() function to calculate relative addresses and linear probing as a collision resolving method.. In addition,

Write words from dictionary.txt to relative.txt using Hash() function to calculate relative addresses and linear probing as a collision resolving method.. In addition,

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

Brief information about the exam will be given at the begining, then no one is not allowed to ask a question during the exam.. print2() calls itself

insertOrdered() that insert elements with ascending order into a doubly linked list gives an error because line sequence of one or more code block written in bold is changed.. Write

Write the sentences from dictionary.txt to relative.txt like above using Hash() function above.. Use linear probing as a collision