• Sonuç bulunamadı

1. 75 Minutes Karadeniz Technical University Department of Computer Engineering Lecturer Omer CAKIR COM 205 Data Structures Resit Exam, 01.22.2015, 13:00, D-1 Time :

N/A
N/A
Protected

Academic year: 2021

Share "1. 75 Minutes Karadeniz Technical University Department of Computer Engineering Lecturer Omer CAKIR COM 205 Data Structures Resit Exam, 01.22.2015, 13:00, D-1 Time :"

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 Resit Exam, 01.22.2015, 13:00, D-1

Time : 75 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 bitOrder(Node* v) {

if (v->left != NULL) {

cout << v->elt << " ";

bitOrder(v->left);

} else

cout << v->elt << " ";

if (v->right != NULL) bitOrder(v->right);

}

void main() {

LinkedBinaryTree Tree;

Tree.addRoot();

Tree.root->elt = 8;

Tree.addBelowRoot(Tree.root, 4);

Tree.addBelowRoot(Tree.root, 12);

Tree.addBelowRoot(Tree.root, 2);

Tree.addBelowRoot(Tree.root, 6);

Tree.addBelowRoot(Tree.root, 10);

Tree.addBelowRoot(Tree.root, 14);

Tree.addBelowRoot(Tree.root, 1);

Tree.addBelowRoot(Tree.root, 3);

Tree.addBelowRoot(Tree.root, 5);

Tree.addBelowRoot(Tree.root, 7);

Tree.addBelowRoot(Tree.root, 9);

Tree.addBelowRoot(Tree.root, 11);

Tree.addBelowRoot(Tree.root, 13);

Tree.addBelowRoot(Tree.root, 15);

cout<< "Preorder Traversal : " ; bitOrder(Tree.root);

}

1.

What is output of the program above? (40P)

(2)

void addFront(const int& i) {

add(header->next, i);

}

void add(DoublyNode* v, int& i) {

DoublyNode* u = new DoublyNode;

u->score = i;

u->prev = v->prev;

v->prev = u;

v->prev->next = u;

u->next = v;

}

void main() {

DoublyLinkedList list;

list.addFront(750);

list.addFront(720);

}

2.

Which one is the list after addFront() function calls?

(You’ll loose 5Ps from wrong answer)

(30P) (A)

750 720

Header Trailer

(B)

720 750

Header Trailer

(C)

750 720

Header Trailer

(D)

720 750

Header Trailer

(E)

750 720

Header Trailer

8 4

2 6

5

12

10 14

9 13

1

24 20

18 22

19 23

28

26 30

27 31

16

if( p->right != NULL) //p points to node to be deleted {

temp = p->right;

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

p->elt = temp->elt;

if(temp->right != NULL) {

temp->par->left = temp->right;

temp->right->par = temp->par;

} else {

temp->par->left = NULL;

}

delete temp;

return;

}

3.

Draw the tree after deleting 24 according to the code above? Draw whole tree, not only deleted part. (30P)

Referanslar

Benzer Belgeler

lines of the function insertOrdered() that inserts nodes in ascending order into a circularly linked list by score value. a) What does the gList() function do?.

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

Complete removeOrdered() function above that removes an element from a doubly

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