• Sonuç bulunamadı

Soru Toplam Puan Not

N/A
N/A
Protected

Academic year: 2022

Share "Soru Toplam Puan Not"

Copied!
6
0
0

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

Tam metin

(1)

A grubu

Pamukkale ¨Universitesi Bilgisayar M¨uhendisli˘gi

Programlama Dilleri Ara Sınav Cevap Ka˘gıdı 26.04.2016

O˘¨grenci Numarası : Adı Soyadı :

Sınav ¸coktan se¸cmeli ve klasik olmak ¨uzere iki kısımdan olu¸smaktadır. C¸ oktan se¸cmeli kısmın cevapları optik okuyucuya uygun cevap ka˘gıtları ¨uzerine i¸saretlenecektir. ˙Ilk 30dk sonunda optik cevap ka˘gıtları toplanacaktır. Kalan klasik soruları bu s¨ureden sonra cevaplayabilirsiniz.

Grubunuzu i¸saretlemeyi unutmayınız!

Soru 26 27 28 29 30 Toplam

Puan 10 10 10 10 10 50

Not

1. C dilinde de˘gerlendirilen 9*12-4*2-3*5 ifadesinin sonucu ne olacaktır?(What is the result when 9*12-4*2-3*5 expression is evaluated in C?)

A. 115 B. 85 C. 101 D. 108

2. Prolog dilinde aritmetik bir ifadenin de˘gerlendirilmesi i¸cin a¸sa˘gıdaki hangi komut kullanılır?(To force evaluation of an arithmetic term in Prolog, you must use the built-in predicate .) A. equals B. force C. is D. evaluate

3. Tip kontrol¨un¨u ¸calı¸sma zamanına ¨otelemenin getirisi nedir?(The real benefit of deferring type checking until runtime is .)

A. daha y¨uksek program g¨uvenli˘gi(higher program safety) B. daha iyi programcı ver- imlili˘gi(greater programmer efficiency) C. daha iyi ¸calı¸sma zamanı verimlili˘gi(greater runtime efficiency) D. daha y¨uksek program g¨uvenilirli˘gi(higher program reliability)

4. Prolog dilinde bir liste a¸sa˘gdaki hangi semboller ile ¸cevrelenir?(A list is written in Prolog using to enclose the items.)

A. ’ ’ (single quotes) B. [ ] (square brackets) C. { } (curly braces) D. ” ” (double quotes)

5. A¸sa˘gıdaki programlama dillerinden hangisi fonksiyonel paradigmaya uymaz?(Which of the be- low is not a sample of functional programming languages?)

A. Scheme B. Haskell C. Curry D. Ada

6. Prolog dilinde [X,Y|Z] = [1,2,3] ifadesi ¸calı¸stırıldı˘gında Y’nin de˘geri ne olur?(What is the value of Y when [X,Y|Z] = [1,2,3] is evaluated in Prolog?)

A. [1,2,3] B. 2 C. 1 D. [2]

7. Fonksiyonel programlama i¸cin a¸sa˘gıda bahsedilen ifadelerden hangisi yanlı¸stır?(Which of the following statements about functional programming languages is incorrect?)

A. Saf fonksiyonel programlamada d¨ong¨uler ¨ozyinelemeli ¸ca˘grılarla de˘gi¸stirilir(In pure func-

(2)

C. Bir fonksiyonun de˘geri parametrelerinin de˘gerlendirme sırasına ba˘glıdır.(The value of a function depends on the order of evaluation of its parameters.) D. Saf fonksiyonel programlamada d¨ong¨u yoktur.(In pure functional programming, there are no loops.) 8. C dilindeki 3-4*2-2-3 ifadesi Scheme dilinde nasıl ifade edilir?(Which one of the below is the

equivalent of 3-4*2-2-3 C expression in Scheme?)

A. (- 3 (* 4 (- 2 (- 2 3)))) B. (- (- (- 3 (* 4 2)) 2) 3) C. 3 4 2 * - 2 - 3 - D. (- 3 (- (- 3 (* 4 2)) 2))

9. Scheme dilinde i¸ceri˘gi ((x y) s (t)) olan L listesi i¸cin (cdr (car L)) ¸calı¸stırılınca geriye ne d¨oner?(Given a list L in Scheme with contents of ((x y) s (t)). What will be returned if the command (cdr (car L)) is executed?)

A. (t) B. (x y) C. (y) D. (x)

10. De˘gi¸skenler, kullanarak bir isim ve tip kazanırlar.(Variables are given names and data types using a .)

A. paket(package) B. bildirim(declaration) C. yapı(structure) D. fonksiyon(function) 11. Prolog dilinde bir ¸c¨oz¨um bulunsa bile d¨ong¨uler olu¸sturmak i¸cin ve tekrarlı aramalar yapmak

i¸cin hangi komut kullanılır?(To force Prolog to perform loops and repetitive searches, we must force backtracking even when a solution is found by using the built-in predicate .)

A. fail B. parent C. is D. repeat

12. Scheme dilinde sembolleri veri tipleri olarak ifade etmek i¸cin a¸sa˘gıdaki anahtar kelimelerden hangisi kullanılır?(To express symbols as a data type in Scheme, use the keyword .) A. exclamation B. form C. symbol D. quote

13. A¸sa˘gıdakilerden hangisi Scheme dilinde bir fonksiyon olu¸sturmak i¸cin kullanılır?(The is used in Scheme to create a function.)

A. lambda ¨ozel bi¸cimi(lambda special form) B. letrec ¨ozel bi¸cimi(letrec special form) C. let ¨ozel bi¸cimi(let special form) D. procedure ¨ozel bi¸cimi(procedure special form)

14. C¸ o˘gu mantıksal programlama dilleri kendilerini adı verilen, y¨uklem hesabının bir alt k¨umesi ile sınırlarlar.(Most logic programming systems restrict themselves to a particular subset of predicate calculus called .)

A. algoritmalar(algorithms) B. horn ¨onermesi(Horn clauses) C. kontrol ¨onermesi(control clauses) D. aksiyomatik ¨onerme(axiomatic clauses)

15. map a¸sa˘gdakilerden hangisine bir ¨ornektir?(A map is an example of a(n) .)

A. API B. yineleyici(iterator) C. ¨ust seviye fonksiyon(higher-order function) D. yordam(procedure)

16. A¸sa˘gıdaki dillerin hangisinde statik tip tanımlaması yoktur?(All of the following languages are statically typed except .)

A. C++ B. Ada C. C D. Python

(3)

17. C++ .

A. kabul edilen standartları yoktur(does not have an accepted set of standards) B. nesne tabanlı bir dildir(is an object-oriented language) C. fonksiyonel bir dildir(is a func- tional type language) D. yagın kullanıma sahip de˘gildir(is not widely used)

18. A¸sa˘gıdakilerden hangisi kaynak kodu girdi olarak alır ve ¸calı¸stırılabilir bir programa d¨on¨u¸st¨ur¨ur?(A(n) takes source code as input and translates it into a program that is executable.)

A. y¨ukleyici(loader) B. yorumlayıcı(interpreter) C. derleyici(compiler) D. ba˘glayıcı(linker) 19. A¸sa˘gıdaki dillerden hangisi statik tip tanımlamasına sahiptir?(Of the following languages, which

is a statically typed language?)

A. Ada B. Smalltalk C. Lisp D. Python

20. Prolog dilinde cut(!) i¸slemi a¸sa˘gıdakilerden hangisi i¸cin kullanılır?(In Prolog, the cut operator is used to .)

A. a˘ga¸ctaki bir dalı ba¸ska bir a˘gaca ta¸sımak(move a node from one tree to another) B. bir- birinin kopyası olan dalları budamak(prune duplicates from a tree) C. a˘ga¸ctaki aramayı durdurmak i¸cin(stop a search of a tree) D. a˘ga¸ctan bir d¨u˘g¨um¨u ¸cıkarmak(remove a node from a tree)

21. A¸sa˘gıdaki ifadelerden hangisi iki de˘gi¸skene de˘ger atayıp bu de˘gerleri ¸carpmak i¸cin kullanılan Scheme ifadesidir?(Which of the following correctly assigns values to two variables and then multiplies them in the Scheme programming language?)

A. (let (x 5) (y 3)) (* x y) B. (let (x 5 y 3) (* x y)) C. let (x 5) (y 3) (* x y) D. (let ((x 5) (y 3)) (* x y))

22. A¸sa˘gıdaki programlama dili ikililerinden hangisinde liste tanımlaması aynıdır?(Which of the programming language pairs below has the same list definition?)

A. Scheme-Haskell B. Prolog-Scheme C. Haskell-Prolog D. ML-C

23. Python ba¸slangı¸cta i¸cin tasarlanmı¸stır.(Python was originally designed for .)

A. geni¸s ¨ol¸cekli sistemler(large scale systems) B. uzman programcılar(expert programmers) C. bilim adamları, m¨uhendisler ve programcı olmayan di˘gerleri(scientists and en- gineers and other non-programmers) D. zamanın ¨onemli oldu˘gu sistemler(time-critical systems)

24. Diziler a¸sa˘gıdaki soyutlamalardan hangisidir?(An array is considered to be a .)

A. basit kontrol soyutlaması(basic control abstraction) B. basit veri soyutlaması(basic data abstraction) C. yapısal veri soyutlaması(structured data abstraction) D. birim soyutlaması(unit abstraction)

25. Lisp programlama modeline dayanır(Lisp is based on the model of computation.) A. fonksiyonel(functional) B. anlamsal(semantic) C. buyurucu(imperative) D. yo- rumlamalı(interpretive)

(4)

26. (10P) A¸sa˘gıdaki metinde ka¸c defa work kelimesinin ge¸cti˘gini ve toplam kelime sayısını bulup sonucu ekrana yazdıran python kodunu yazınız.(Write a python code that finds how many times does “work” appear in the text and total word count. Print the values to the screen.)

t e x t = ”””

work work work work work work , he s a i d me h a f f i work work work work work work , he s e e me do me

d i r t d i r t d i r t d i r t d i r t d i r t , So me p u t i n work work work work work work , when you ah gon l e a r n l e a r n l e a r n l e a r n l e a r n , meh nuh c a r e i f him h u r t h u r t h u r t h u r t h u r t i n g ”””

w o r k S a y i s i = 0

t o p l a m K e l i m e S a y i s i = 0 f o r k e l i m e in t e x t . s p l i t ( ) :

i f k e l i m e == ” work ” : w o r k S a y i s i += 1 t o p l a m K e l i m e S a y i s i += 1

print ” ’ work ’ k e l i m e s i s a y i s i : ” + s t r ( w o r k S a y i s i ) print ”Toplam k e l i m e s a y i s i : ” + s t r ( t o p l a m K e l i m e S a y i s i )

27. (10P) Toplama, ¸cıkarma ve ¸carpma i¸slemi yapmak i¸cin HesapMakinesi sınıfını ve bu sınıfın uygun metodlarını Ruby dilinde yazın. Yazdı˘gınız sınıfı kullanarak 2*3+(3-4) i¸slemini yapıp sonucu ekrana yazdırın.(Write the HesapMakinesi class that can do the addition, subtraction and multiplication operations in Ruby. Perform the2*3+(3-4) operation using HesapMakinesi class and print the output to screen.)

c l a s s H e s a p M a k i n e s i def t o p l a ( x , y )

return x+y end

def c i k a r ( x , y ) return x−y end

def c a r p ( x , y ) return x∗y end

end

h e s a p = H e s a p M a k i n e s i . new

p u t s h e s a p . t o p l a ( h e s a p . c a r p ( 2 , 3 ) , h e s a p . c i k a r ( 3 , 4 ) )

(5)

28. Prototipi a¸sa˘gıda olan C fonnksiyonu ile dizideki elemanların toplamı hesaplanacaktır:(A func- tion propotype, which calculates the sum of the values in an array, is given below)

i n t t o p l a ( i n t d i z i [ ] , i n t e l e m a n S a y i s i ) ;

(a) (5P) Bu fonksiyonu m¨umk¨un oldu˘gunca fonksiyonel bi¸cimde yazın, ¸c¨oz¨um¨un¨uz d¨ong¨u ve atama i¸slemleri i¸cermesin.(Write this function as functional as possible, your solution shall not include assignmets and loops.)

i n t t o p l a ( i n t d i z i [ ] , i n t e s ) // es−>eleman s a y i s i {

i f ( e s == 1 )

return d i z i [ 0 ] ;

return d i z i [ e s − 1 ] + t o p l a ( d i z i , e s − 1 ) ; }

(b) (5P) a. ¸sıkkında buldu˘gunuz ¸c¨oz¨um¨u kuyruk ¨ozyinelemeli olarak yazın.(Write the func- tion, which you wrote in choice a., tail recursive.)

i n t t o p l a ( i n t d i z i [ ] , i n t e s , i n t toplam ) {

i f ( e s == 0 )

return toplam ;

return t o p l a ( d i z i , e s − 1 , toplam + d i z i [ e s − 1 ] ) ; }

29. A¸sa˘gıdaki λ ifadelerini indirgemeleri adım adım g¨ostererek hesaplayınız.(Calculate the λ ex- pressions below using the appropriate reductions.)

(a) (5P) (λx.λy.x y)(+ 2) 3 (λx.λy.x y)(+ 2) 3

= (λy. + 2 y) 3

= + 2 3

= 5

(b) (5P) (λk. ∗ k k)((λx.λy.x y y) + 3) (λk. ∗ k k)((λx.λy.x y y) + 3)

= ∗ ((λx.λy.x y y) + 3)((λx.λy.x y y) + 3)

= ∗ ((λy. + y y) 3)((λy. + y y) 3)

= ∗ (+ 3 3)(+ 3 3)

= ∗ 6 6

(6)

30. (10P) A¸sa˘gıda verilen prolog kodu dikkate alındı˘gında topla([3,6,5],T). sorgusu sonucunda olu¸san arama a˘gacını ¸ciziniz.(Draw the search tree of topla([3,6,5],T). query using the Prolog code below.)

( 1 ) t o p l a ( [ ] , 0 ) .

( 2 ) t o p l a ( [ B |K] , T): − t o p l a (K, T1 ) ,T i s T1+B .

Referanslar

Benzer Belgeler

B hisse senedinin SCL’ si daha y¨ uksek oldu˘ gu i¸cin onun sistematik riski daha fazladır. SCL’ nin R 2 ’ si (veya korelayon katsayısının karesi) hisse senedi

Cevap: Bir arbitraj fırsatı vardır ¸c¨ unk¨ u beklenen de˘ geri B menkul kıymetinden farklı olan A menkul kıymeti ve betası 0.75 olan risksiz varlık kullanılarak bir portf¨

Bu kablonun kulenin ayaklarını birle¸stiren hatta en yakın noktası 150 m olarak ¨ ol¸ c¨ ul¨ uyor. ˙Iki kule arasındaki kablonun uzunlu˘

(b) Bu e˘ grinin x−ekseni etrafında d¨ ond¨ ur¨ ulmesiyle elde edilen d¨ onel cismin y¨ uzey alanını ifade eden belirli integrali yazınız. (c) Bu e˘ grinin y−ekseni

Gerçeklenen sistemde, öğretmen tarafından sisteme aktarılan ve alan bilgisi içinde bir veritabanı yapısında saklanan ders içeriğinin, her öğrencinin

Bu iki ¸seklin alanları toplamının minimum olması i¸cin her bir par¸canın uzunlu˘ gunun ne olması gerekti˘ gini t¨ urev yardımıyla

U¸c ¨ par¸calı fonksiyon verilen aralıklarında (u¸c noktalar hari¸c) s¨ urekli oldu˘ gunu g¨ or¨ uyoruz... Uzunlu˘ gu 150 cm olan bir tel par¸cası, iki

NOT: Tam puan almak i¸ cin yeterli a¸ cıklama yapılması gerekmektedir. Sınav s¨ uresi