• 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 Final Exam, 04.01.2020, 10:00

Duration : 100 Minutes

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

SIGNATURE : ………...

EXAM GRADE

[...] ...

Students have to obey Engineering Faculty Exam Execution Instructions.

Questions are related to 1,4,12 of Program Learning Outcomes

void traverse(TreeNode* v) {

if (v->left != NULL) {

// (A)

traverse(v->left);

// (B) }

if (v->right != NULL) {

// (C)

traverse(v->right);

// (D) }

}

1.

Some lines are labeled as (A) (B) (C) (D) in the function traverse() above. Assuming these lines are like cout << v->elem << " "; two of the outputs will be same. Which outputs are same and what is the output?

(25P)

(A) (B) (C) (D)

Output

8 4

2 6

3

5 7

12

10 14

9 11 13 15 1

2.

Assume that numbers of each choice are inserted into a seperate binary tree. In this case one tree is different from others. Which is the different one? (25P)

(A)

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

(B)

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

(C)

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

(D)

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

(E)

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

(F)

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

(G)

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

(H)

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

(I)

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

(J)

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

(2)

void insertOrdered(string& e, 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) newNode->next->prev = newNode;

current->prev->next = newNode;

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

current->prev = newNode;

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

newNode->next->prev = newNode;

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

newNode->prev->next = newNode;

8

4

2 6

12 10 14

24

20 17 22 16

33 34 26 29

28 30 32 31

4.

Delete 16 from 2-3-4 tree above. After deletion draw the whole tree.

Hint → Replace 17 with 16. (25P)

Referanslar

Benzer Belgeler

• Search in binary trees requires O(log n) time in the average case, but needs O(n) time in the worst-case, when the. unbalanced tree resembles a

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

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

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

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