• 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 Ömer ÇAKIR

COM 2005 Data Structures Resit Exam, 02.01.2019, 10:00, D-1

Duration : 100 Minutes

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

SIGNATURE : ………...

EVALUATION

[...] ...

Exam Execution Instructions of Faculty of Enginnering should be obeyed. Questions are related to 1,4,12 of Program Learning Outcomes

void insertOrdered(SinglyNode* newNode, SinglyNode* current) {

if(...) {

newNode->next = current->next;

current->next = newNode;

} else

insertOrdered(newNode, current->next);

}

int main() {

SinglyLinkedList list; SinglyNode* newNode;

list.head = new SinglyNode;

list.head->score = 0;

list.head->next = NULL;

newNode = new SinglyNode;

newNode->elem = "Paul"; newNode->score = 720;

list.insertOrdered(newNode, list.head);

newNode = new SinglyNode;

newNode->elem = "Rose"; newNode->score = 590;

list.insertOrdered(newNode, list.head);

newNode = new SinglyNode;

newNode->elem = "Anna"; newNode->score = 660;

list.insertOrdered(newNode, list.head);

newNode = new SinglyNode;

newNode->elem = "Mike"; newNode->score = 1105;

list.insertOrdered(newNode, list.head);

}

1.

Complete the function insertOrdered(). (25P) You’ll loose 5P from wrong answer.

(A) if ((current == NULL)

|| (newNode->score <= current->score))

(B) if ((current->next == NULL)

|| (newNode->score <= current->score))

(C) if ((current == NULL)

|| (newNode->score <= current->next->score))

(D) if ((current->next == NULL)

|| (newNode->score <= current->next->score))

8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 2.

Assume that the numbers above are inserted into a binary tree. Assuming again that another 3 new binary trees are generated by the output of the inorder, preorder and postorder traversals of this binary tree, which of these 3 new trees is exactly the same as the first binary tree?

(25P)

Yanlış cevaptan 5P kırılacaktır.

(A) inorder (B) preorder

(C) postorder

(2)

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

DoublyNode* newNode = new DoublyNode;

newNode->elem = e;

newNode->score = i;

DoublyNode* current = header->next;

while (current != trailer) {

if (newNode->score >= current->score) current = current->next;

else

break;

}

newNode->next = current;

newNode->prev = current->prev;

... = ...;

... = ...;

}

3.

Considering the two lines of the insertOrdered() function that are indicated by “...“, which of the following

choises add a node to a doubly linked list erroneously?

(25P) You’ll loose 5P from wrong answer.

(A) current->prev->next = newNode;

newNode->next->prev = newNode;

(B) current->prev->next = newNode;

current->prev = newNode;

(C) current->prev = newNode;

current->prev->next = newNode;

(D) newNode->prev->next = newNode;

newNode->next->prev = newNode;

(E) newNode->next->prev = newNode;

newNode->prev->next = newNode;

2 5

4 7

6 9

11

10 13

12 15

14 1

3

4.

Insert 8 into a Splay tree above left. Write the final splay tree above right. (25P)

Referanslar

Benzer Belgeler

2 The Intel 8080 Microprocessor Instruction Set 3 The Intel 8080 Microprocessor Instruction Set 4 Assembly language, program writing, examples 5 Assembly language, program

Course Objectives To give the the fundamental organization of the computers To teach the MIPS assembly language programming Learning Outcomes When this course has been completed

3 An ability to apply mathematical foundations, algorithmic principles, and computer engineering techniques in the modelling and design of computer-based systems. 3 4 An

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

Suggest an improvement in the node (has left/right child) deletion algorithm to obtain a balanced tree... Which one of the following choises for the

About relational database's concepts, the pieces of database systems, how the pieces fit together, multi-tier computing architecture and multiple databases, dbase and paradox..

When the above version of the the MsgBox function is used, a rectangular forrn (we will learn later on that this type of form is called a dialog box) is presented to the user, display