question
stringlengths
14
1.87k
choices
listlengths
2
9
answer
stringclasses
4 values
source
stringclasses
3 values
__index_level_0__
int64
0
17k
Church booleans are a representation of booleans in the lambda calculus. The Church encoding of true and false are functions of two parameters: Church encoding of tru: t => f => t Church encoding of fls: t => f => f What should replace ??? so that the following function computes not(b and c)? b => c => b ??? (not b)
[ "(not b)", "(not c)", "tru", "fls" ]
B
custom
17,008
To which expression is the following for-loop translated? for x <- xs if x > 5; y <- ys yield x + y
[ "xs.flatMap(x => ys.map(y => x + y)).withFilter(x => x > 5)", "xs.withFilter(x => x > 5).map(x => ys.flatMap(y => x + y))", "xs.withFilter(x => x > 5).flatMap(x => ys.map(y => x + y))", "xs.map(x => ys.flatMap(y => x + y)).withFilter(x => x > 5)" ]
C
custom
17,009
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int Assuming that elements of multisets are only lowercase letters of the English alpha- bet, what does the secret function compute? def diff(a: Multiset, b: Multiset): Multiset = \t x => Math.abs(a(x) - b(x)) def secret(a: Multiset, b: Multiset) = \t (’a’ to ’z’).map(x => diff(a, b)(x)).sum == 0
[ "Checks if b is a subset of a", "Checks if a and b are disjoint", "Checks if a is a subset of b", "Checks if a and b are equal", "Checks if a and b are empty", "Checks if a is empty" ]
D
custom
17,010
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int The filter operation on a multiset m returns the subset of m for which p holds. What should replace ??? so that the filter function is correct? def filter(m: Multiset, p: Char => Boolean): Multiset = ???
[ "x => if m(x) then p(x) else 0", "x => m(x) && p(x)", "x => if !m(x) then p(x) else 0", "x => if p(x) then m(x) else 0" ]
D
custom
17,011
Consider the program below. Tick the correct answer. def fun(x: List[Int]) = if x.isEmpty then None else Some(x) val lists = List(List(1, 2, 3), List(), List(4, 5, 6)) for \t l <- lists \t v1 <- fun(l) \t v2 <- fun(v1) yield v2
[ "This program does not compile.", "This program compiles and the last statement has type List[Int].", "This program compiles and the last statement has type List[List[Int]].", "This program compiles and the last statement has type List[Option[List[Int]]].", "This program compiles and the last statement has type List[List[Option[Int]]].", "This program compiles and the last statement has type List[Option[Int]].", "This program compiles and the last statement has type List[Some[Int]].", "This program compiles and the last statement has type Some[List[Int]].", "This program compiles and the last statement has type Option[List[Int]]." ]
C
custom
17,012
Church booleans are a representation of booleans in the lambda calculus. The Church encoding of true and false are functions of two parameters: Church encoding of tru: t => f => t Church encoding of fls: t => f => f What does the following function implement? b => c => b (not c) c
[ "not c", "b xor c", "b or c", "b and c", "not(b and c)" ]
B
custom
17,013
Tick the \textbf{true} assertion. Let $X$ be a random variable defined by the visible face showing up when throwing a dice. Its expected value $E(X)$ is:
[ "3.5", "3", "1", "4" ]
C
custom
17,014
Let P be the statement ∀x(x>-3 -> x>3). Determine for which domain P evaluates to true:
[ "-3<x<3", "x>-3", "x>3", "None of the other options" ]
C
custom
17,015
Let P(x) is “x is an elephant” and F(x) is “x flies” and the domain consists of all animals. Translate the following statement into English: ∃!x(P(x) ∧ F(x))
[ "There exists only one elephant that can fly", "There is an animal that flies if it’s an elephant", "All elephants fly", "Some elephants can flyv", "None of the other options" ]
A
custom
17,016
Let p(x,y) be the statement “x visits y”, where the domain of x consists of all the humans in the world and the domain of y consists of all the places in the world. Use quantifiers to express the following statement: There is a place in the world that has never been visited by humans.
[ "∃y ∀x ¬p(x,y)", "∀y ∃x ¬p(x,y)", "∀y ∀x ¬p(x,y)", "¬(∀y ∃x ¬p(x,y))" ]
A
custom
17,017
Which of the following arguments is correct?
[ "All students in this class understand math. Alice is a student in this class. Therefore, Alice doesn’t understand math.", "Every physics major takes calculus. Mathilde is taking calculus. Therefore, Mathilde is a physics major.", "All cats like milk. My pet is not a cat. Therefore, my pet does not like milk.", "Everyone who eats vegetables every day is healthy. Linda is not healthy. Therefore, Linda does not eat vegetables every day." ]
D
custom
17,018
Suppose we have the following function \(f: [0, 2] o [-\pi, \pi] \). \[f(x) = egin{cases} x^2 & ext{ for } 0\leq x < 1\ 2-(x-2)^2 & ext{ for } 1 \leq x \leq 2 \end{cases} \]
[ "\\(f\\) is not injective and not surjective.", "\\(f\\) is injective but not surjective.", "\\(f\\) is surjective but not injective.", "\\(f\\) is bijective." ]
B
custom
17,019
A friend asked you to prove the following statement true or false: if a and b are rational numbers, a^b must be irrational. Examining the case where a is 1 and b is 2, what kind of proof are you using ?
[ "Proof by contradiction", "Proof by counterexample", "Exhaustive proof", "Proof by cases", "Existence proof" ]
B
custom
17,020
If A is an uncountable set and B is an uncountable set, A − B cannot be :
[ "countably infinite", "uncountable", "the null set", "none of the other options" ]
D
custom
17,021
You need to quickly find if a person's name is in a list: that contains both integers and strings such as: list := ["Adam Smith", "Kurt Gödel", 499, 999.95, "Bertrand Arthur William Russell", 19.99, ...] What strategy can you use?
[ "Insertion sort the list, then use binary search.", "Bubble sort the list, then use binary search.", "Use binary search.", "Use linear search." ]
D
custom
17,022
Let \( f : A ightarrow B \) be a function from A to B such that \(f (a) = |a| \). f is a bijection if:
[ "\\( A= [0, 1] \\) and \\(B= [-1, 0] \\)", "\\( A= [-1, 0] \\) and \\(B= [-1, 0] \\)", "\\( A= [-1, 0] \\) and \\(B= [0, 1] \\)", "\\( A= [-1, 1] \\) and \\(B= [-1, 1] \\)" ]
C
custom
17,023
Let \( P(n) \) be a proposition for a positive integer \( n \) (positive integers do not include 0). You have managed to prove that \( orall k > 2, \left[ P(k-2) \wedge P(k-1) \wedge P(k) ight] ightarrow P(k+1) \). You would like to prove that \( P(n) \) is true for all positive integers. What is left for you to do ?
[ "None of the other statement are correct.", "Show that \\( P(1) \\) and \\( P(2) \\) are true, then use strong induction to conclude that \\( P(n) \\) is true for all positive integers.", "Show that \\( P(1) \\) and \\( P(2) \\) are true, then use induction to conclude that \\( P(n) \\) is true for all positive integers.", "Show that \\( P(1) \\), \\( P(2) \\) and \\( P(3) \\) are true, then use strong induction to conclude that \\( P(n) \\) is true for all positive integers." ]
D
custom
17,024
What is the value of \(f(4)\) where \(f\) is defined as \(f(0) = f(1) = 1\) and \(f(n) = 2f(n - 1) + 3f(n - 2)\) for integers \(n \geq 2\)?
[ "41", "45", "39", "43" ]
A
custom
17,025
Which of the following are true regarding the lengths of integers in some base \(b\) (i.e., the number of digits base \(b\)) in different bases, given \(N = (FFFF)_{16}\)?
[ "\\((N)_2\\) is of length 16", "\\((N)_{10}\\) is of length 40", "\\((N)_4\\) is of length 12", "\\((N)_4\\) is of length 4" ]
A
custom
17,026
In a lottery, a bucket of 10 numbered red balls and a bucket of 5 numbered green balls are used. Three red balls and two green balls are drawn (without replacement). What is the probability to win the lottery? (The order in which balls are drawn does not matter).
[ "$$\frac{1}{14400}$$", "$$\frac{1}{7200}$$", "$$\frac{1}{1200}$$", "$$\frac{1}{1900}$$" ]
C
custom
17,027