• Sonuç bulunamadı

BIL 205 Data Structures Midterm Exam I, 18.11.2011 Time :

N/A
N/A
Protected

Academic year: 2021

Share "BIL 205 Data Structures Midterm Exam I, 18.11.2011 Time :"

Copied!
1
0
0

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

Tam metin

(1)

Karadeniz Technical University Department of Computer Engineering

Lecturer Ömer ÇAKIR

BIL 205 Data Structures

Midterm Exam I, 18.11.2011 Time : 100 Minutes

Rules to be Observed During the Exam

1. Cell phones are not allowed to use as a calculator or a clock. They must be closed and placed in pocket.

2. Questions might be asked in first 20 minutes. Each student has a chance to ask questions 1 time.

3. Sign this paper after writing your number and name. You will bring this paper with you.

NUMBER : NAME : SIGNATURE :

void DoublyLinkedList::Bordo() {

header->next->next->prev = header;

trailer->prev->next = header->next;

header->next->prev = trailer->prev;

trailer->prev = header->next;

header->next = header->next->next;

trailer->prev->next = trailer;

}

void main() {

DoublyLinkedList list;

list.addBack("Omer");

list.addBack("Oguzhan");

list.addBack("Fatih");

list.addBack("Ali Osman");

list.Bordo();

list.print();

}

1.

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

void DoublyLinkedList::Mavi(DoublyNode* node) {

if (node->next == trailer) {

cout << node->elem << endl;

}

else Mavi(node->next);

}

void main() {

DoublyLinkedList list;

list.addBack("Omer");

list.addBack("Oguzhan");

list.addBack("Fatih");

list.addBack("Ali Osman");

list.Mavi(list.header);

}

2.

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

int linearF(int a, int b, int c, int n) {

if (n <= 2) return c;

else return ...;

}

int tripleF(int k) {

if (k <= 2) return k;

return tripleF(k-1) + tripleF(k-2) + tripleF(k-3);

}

void main() {

int linF = linearF(0, 1, 2, 7);

cout << "linearF = " << linF << endl;

int tripF = tripleF(7);

cout << "tripleF = " << tripF << endl;

}

3.

Complete linearF() that is equivalent linear recursive version of tripleF(). (25 P)

int binarySum(int A[], int i, int n) {

if (n == 1) return A[i];

else {

int Sum = binarySum(A, i, n/2 ) + binarySum(A, i + n/2, n/2 );

cout << "Sum = " << Sum << endl;

return Sum;

} }

void main() {

int A[8] = {1,2,3,4,5,6,7,8};

binarySum(A, 0, 8);

}

4.

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

Referanslar

Benzer Belgeler

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

b) addBelowRootModified() isimli fonksiyon, veriler aşağıdaki sırada eklendiğinde doğru çalışırken yukarıda main() fonksiyonundaki gibi eklenince yanlış

1. Cell phones are not allowed to be used as a calculator or a watch. They must be switched off and placed in pocket. Questions might be asked in the first 20 minutes. Each student

tripleF() isimli fonksiyonun lineer recursive eşdeğeri olacak şekilde linearF()’te .... ile gösterilen yerlere gerekli

tripleF() isimli fonksiyonun lineer recursive eşdeğeri olacak şekilde linearF()’te .... ile gösterilen yerlere gerekli

Identifying the domain and all asymptotes, investigating all critical points, inter- vals where the curve is increasing and where it is decreasing, points of in‡ections and

ATTENTION:Each question has only one correct answer and is worth one point.. Be sure to fill in completely the circle that corresponds to your answer on the