Question: What is the time complexity of inserting an element at the beginning of a linked list?

Answer: O(1)

Insertion at the beginning involves updating the head pointer, which is a constant time operation.


Question: A snail is at the bottom of a 20-foot well. Each day, it climbs up 3 feet, but at night, it slips back 2 feet. How many days will it take for the snail to reach the top of the well?

Answer: 18

On the 17th day, the snail reaches 17 feet. On the 18th day, it climbs 3 feet to 20 feet and escapes


Question: What is the next number in the sequence: 2, 5, 8, 11, 14?

Answer: 17

The sequence is an arithmetic progression with a common difference of 3. So, the next number is 14 + 3 = 17


Question: The following code is intended to implement a binary search: `low = 0; high = len(arr); while low <= high: mid = (low + high) // 2; if arr[mid] == target: return mid; elif arr[mid] < target: low = mid; else: high = mid` What is the bug?

Answer: The updates to 'low' and 'high' should be 'low = mid + 1' and 'high = mid - 1' respectively

The current code can result in an infinite loop because 'low' and 'high' are not being updated correctly.


Question: A survey found that people who exercise regularly are less likely to be depressed. What can be inferred?

Answer: Exercise may be associated with a lower likelihood of depression.

The survey suggests a correlation between regular exercise and lower depression rates, though it doesn't necessarily prove causation.


Question: A wave has a frequency of 50 Hz and a wavelength of 2 m. What is its speed?

Answer: 100 m/s

Speed = frequency * wavelength = 50 Hz * 2 m = 100 m/s.


Question: A projectile is launched at an angle of 45 degrees to the horizontal with an initial velocity of 20 m/s. What is its maximum height?

Answer: 10 m


Question: Implementing a simple stack using a list, what is the correct operation to pop an element?

Answer: `lst.pop()`

`pop()` without an index removes and returns the last element, which is the top of the stack.


Question: If a cell divides every 24 hours, how many cells will there be after 72 hours if we start with 1 cell?

Answer: 8

The cell divides every 24 hours, so after 72 hours (3 days), it will have divided 3 times. Thus, 1 cell becomes 2, then 4, then 8 cells.


Question: A bat is either in the cave or in the forest. It is not in the forest. Where is the bat?

Answer: In the cave

The statement gives two possibilities and negates one, so the bat must be in the other location.


Question: A rectangle has a length of 8 cm and a width of 5 cm. What is its area?

Answer: 40

The area of a rectangle is length times width. So, 8 cm * 5 cm = 40 square cm.


Question: A buffer solution contains 0.1 M acetic acid (CH3COOH) and 0.1 M sodium acetate (CH3COONa). What is the pH of the solution? (Ka of CH3COOH = 1.8 x 10^-5)

Answer: 4.74

Using the Henderson-Hasselbalch equation: pH = pKa + log([A-]/[HA]), where [A-] = [CH3COONa] = 0.1 M, [HA] = [CH3COOH] = 0.1 M, and pKa = -log(1.8 x 10^-5) = 4.74, we get pH = 4.74 + log(0.1/0.1) = 4.74


Question: No X are Y. Some Z are Y. What can be concluded about X and Z?

Answer: Some Z are not X

Since no X are Y and some Z are Y, those Z that are Y cannot be X, hence some Z are not X.


Question: What is the time complexity of the Dijkstra's algorithm using a binary heap for finding the shortest path in a graph?

Answer: O((n + m) log n)

Dijkstra's algorithm with a binary heap involves extracting the minimum element (O(log n)) n times and updating distances (O(log n)) for each of the m edges, resulting in a time complexity of O((n + m) log n).


Question: A capacitor of capacitance 0.01 F is charged to a potential difference of 10 V. What is the charge stored?

Answer: 0.1

Using the formula Q = CV, where C = 0.01 F and V = 10 V, we get Q = 0.01*10 = 0.1 C.


Question: A certain language has a rule that every sentence must contain the word 'xorvath'. If a sentence is grammatically correct, is it necessarily true that it contains 'xorvath'?

Answer: Yes

The rule states that every sentence must contain 'xorvath', so a grammatically correct sentence by definition contains 'xorvath'.


Question: The following code is intended to check if a graph has a cycle: `visited = set(); for node in graph: if node not in visited: if has_cycle(node, visited, set()): return True` What is missing?

Answer: The 'has_cycle' function is not defined

The code snippet is missing the implementation of the 'has_cycle' function, which is necessary to detect cycles in the graph.


Question: The code for reversing a linked list `ListNode* reverse(ListNode* head) { ListNode* prev = NULL; while (head) { ListNode* next = head->next; head->next = prev; prev = head; head = next; } return head; }` is incorrect. What is the fix?

Answer: Return `prev` instead of `head`

After the loop, `prev` points to the new head of the reversed list, while `head` is NULL.


Question: What is the time complexity of the given algorithm: `def func(n): if n <= 1: return n; return func(n-1) + func(n-2)`?

Answer: O(2^n)

The recursive function has two branches at each step, resulting in a binary tree with a height of n, and thus a time complexity of O(2^n).


Question: The following code is intended to find the first duplicate in an array: `seen = set(); for num in arr: if num in seen: return num; seen.add(num)` What is the bug?

Answer: There is no bug, the code is correct

The code correctly iterates over the array and returns the first duplicate it encounters.


Question: If the function f(x) = x^3 - 2x^2 + x + 1 is divided by x - 1, what is the remainder?

Answer: 1

By the Remainder Theorem, the remainder is f(1) = 1^3 - 2(1)^2 + 1 + 1 = 1 - 2 + 1 + 1 = 1


Question: All humans are mortal. Some mortals are not humans. What can be concluded?

Answer: Some mortals are humans

The statement 'All humans are mortal' directly implies that humans are a subset of mortals, hence some mortals are humans.


Question: What is the sum of the first 10 positive integers?

Answer: 55

The sum of the first n positive integers is given by n(n+1)/2. For n = 10, this is 10*11/2 = 55.


Question: In a Hardy-Weinberg equilibrium, if the frequency of allele 'a' is 0.4, what is the frequency of the genotype 'aa'?

Answer: 0.16

Using the Hardy-Weinberg principle: the frequency of 'aa' = q^2, where q = frequency of 'a' = 0.4. So, q^2 = 0.4^2 = 0.16


Question: If a 'codex' is related to 'books', what is 'atlas' related to?

Answer: maps

A codex is a collection of books, and an atlas is a collection of maps, making the relationship analogous.


Question: A wheel of radius 0.5 m rotates at an angular velocity of 4 rad/s. What is the linear velocity of a point on its rim?

Answer: 2 m/s

Using the formula v = r * ω, where r = 0.5 m and ω = 4 rad/s, we get v = 0.5 * 4 = 2 m/s


Question: If 'cat' is coded as 'dog', 'dog' as 'bird', and 'bird' as 'fish', what is 'dog' coded as?

Answer: bird

Following the given coding pattern, 'dog' is coded as 'bird'.


Question: If every person who is a musician is also an artist, and some artists are famous, does it follow that some musicians are famous?

Answer: Not necessarily

The statement 'some artists are famous' does not guarantee that the artists who are musicians are among those who are famous.


Question: A is to B as C is to D. If A is increased by 20% to become B, how should C be changed to become D?

Answer: Increased by 20%

The relationship between A and B is a 20% increase. To maintain the analogy, C should be increased by 20% to become D.


Question: A buffer solution contains 0.1 M acetic acid and 0.1 M sodium acetate. What is its pH? (Ka of acetic acid = 1.8 * 10^-5)

Answer: 4.74

Using the Henderson-Hasselbalch equation: pH = pKa + log([A-]/[HA]), where [A-] = [HA] = 0.1 M. pKa = -log(1.8 * 10^-5). So, pH = -log(1.8 * 10^-5) + log(0.1/0.1) = 4.74.


Question: What is the time complexity of the merge sort algorithm?

Answer: O(n log n)

Merge sort recursively divides the array into two halves until each half has one element, resulting in log n levels. At each level, it merges the halves, resulting in n operations. Hence, the overall time complexity is O(n log n).


Question: How does the dynamic programming approach improve the time complexity of the Fibonacci sequence calculation?

Answer: By storing and reusing previously computed values, reducing the time complexity from O(2^n) to O(n)

Dynamic programming stores the results of expensive function calls and reuses them when the same inputs occur again, avoiding redundant computation.


Question: Prove that the sum of the reciprocals of the prime numbers diverges. What is the approximate sum of the reciprocals of the prime numbers less than 100?

Answer: 1.77 (approx)

The sum of the reciprocals of the prime numbers less than 100 is approximately 1.77 (this requires computation or approximation). The exact proof of divergence is complex and involves showing that the sum grows without bound as the limit of prime numbers is taken to infinity.


Question: Some artists are musicians. All musicians are creative. What can be inferred?

Answer: Some artists are creative

Since some artists are musicians and all musicians are creative, it follows that those artists who are musicians are creative, hence some artists are creative.


Question: Complete the analogy: Finger is to Hand as Toe is to ?

Answer: Foot

Fingers are part of the hand, and toes are part of the foot.


Question: What is the integral of x^2 from 0 to 1?

Answer: 1/3


Question: Some students are athletes. All athletes are disciplined. Which conclusion can be drawn?

Answer: Some students are disciplined

Since some students are athletes and all athletes are disciplined, it follows that those students who are athletes are disciplined, hence some students are disciplined.


Question: Every athlete is fit. Some athletes are not tall. What can be concluded?

Answer: Some fit people are not tall

Since every athlete is fit and some athletes are not tall, it follows that those athletes who are not tall are fit and not tall.


Question: What is the chemical symbol for gold?

Answer: Au

The chemical symbol for gold is derived from its Latin name, aurum


Question: A wave has a frequency of 50 Hz and a wavelength of 2 m. What is its speed?

Answer: 100 m/s

Using the formula v = fλ, where f = 50 Hz and λ = 2 m, we get v = 50 * 2 = 100 m/s


Question: Identify the odd one out: car, bus, train, apple

Answer: apple

Car, bus, and train are all modes of transportation, while an apple is a type of fruit.


Question: If it's sunny, then it's not raining. It's sunny. What's the weather like?

Answer: It's not raining.

The condition 'if it's sunny, then it's not raining' is met because it's sunny, so we can conclude it's not raining.


Question: For the reaction 2NO + O2 -> 2NO2, if the rate of disappearance of NO is 0.02 M/s, what is the rate of formation of NO2?

Answer: 0.02 M/s

From the stoichiometry of the reaction, the rate of disappearance of NO is equal to the rate of formation of NO2. So, the rate of formation of NO2 = 0.02 M/s.


Question: A DNA sequence is given as ATGCGTA. What is the complementary RNA sequence?

Answer: UACGCAU

To get the complementary RNA sequence, we pair each DNA nucleotide with its complement (A with U, T with A, G with C, C with G) and replace T with U. So, ATGCGTA becomes UACGCAU.


Question: Analyze the time complexity of the recursive function `def fib(n): if n <= 1: return n; return fib(n-1) + fib(n-2)`

Answer: O(2^n)

The function does a lot of repeated computation because it recalculates the same Fibonacci numbers multiple times, leading to exponential time complexity.


Question: A person invests $1000 at a 5% annual interest rate. How much will they have after 2 years?

Answer: 1102.5


Question: If a cell divides every 20 minutes, how many cells will be produced from one cell after 2 hours?

Answer: 64

2 hours = 120 minutes. 120 minutes / 20 minutes per division = 6 divisions. 2^6 = 64 cells.


Question: What is the time complexity of the given algorithm: `for i in range(n): for j in range(i, n): print(i, j)`?

Answer: O(n^2)

The outer loop runs n times, and for each iteration, the inner loop runs from i to n, resulting in a total of n*(n+1)/2 iterations, which simplifies to O(n^2).


Question: Implementing Dijkstra's algorithm, what data structure is typically used to select the next node?

Answer: A priority queue

A priority queue efficiently selects the node with the minimum distance that hasn't been processed yet.


Question: Find the sum of the series: 1 + 1/2 + 1/4 + 1/8 + ...

Answer: 2

This is a geometric series with first term a = 1 and common ratio r = 1/2. The sum of an infinite geometric series is a/(1-r) = 1/(1-1/2) = 2


Question: The statement 'All X are Y' is given. What can be inferred about the relationship between X and Y?

Answer: X is a subset of Y

The statement implies that every element of X is also an element of Y, hence X is a subset of Y.


Question: A 5 kg object is attached to a spring with a spring constant of 100 N/m. If the object is displaced by 0.2 m from its equilibrium position, what is the force exerted by the spring?

Answer: -20

Using Hooke's Law, F = -k * x, where k = 100 N/m and x = 0.2 m, we get F = -100 * 0.2 = -20 N.


Question: Solve for y: y/2 + 2 = 6

Answer: 8

Subtract 2 from both sides to get y/2 = 4. Then, multiply both sides by 2 to get y = 8.


Question: A, B, C, D, and E are standing in a line. A is to the left of B, C is to the right of B, D is to the left of A, and E is to the right of C. Who is in the middle?

Answer: B

From the statements: D is to the left of A, A is to the left of B, so D is to the left of B. B is to the left of C, and C is to the left of E. So, the order is D-A-B-C-E. Thus, B is in the middle.


Question: Solve for x in the equation x^3 - 2x^2 - 5x + 6 = 0.

Answer: 1

One of the roots is 1, obtained by inspection or trial and error.


Question: A bakery sells 250 loaves of bread per day. They make a profit of $0.50 per loaf. How much profit do they make in a day?

Answer: 125

Profit per day = number of loaves sold * profit per loaf = 250 * 0.50 = $125.


Question: If it is true that 'no Ps are Qs' and 'some Qs are Rs', what can be concluded about Ps and Rs?

Answer: Some Rs are not Ps

Since no Ps are Qs, Ps and Qs are mutually exclusive. Some Qs are Rs, so those Rs are not Ps because they are Qs. Thus, at least some Rs (those that are Qs) are not Ps.


Question: What is the sum of the first 5 positive integers?

Answer: 15

The sum of the first n positive integers is given by n(n+1)/2. For n = 5, this equals 5(6)/2 = 15.


Question: The argument 'We need to reduce our carbon footprint because climate change is a serious issue' relies on which assumption?

Answer: That reducing our carbon footprint will help mitigate climate change.

The argument assumes a causal relationship between reducing carbon footprint and mitigating climate change.


Question: Given 'All A are B', 'No B is C', 'Some D are C', what can be concluded about A and D?

Answer: Some D are not A

Since all A are B and no B is C, A cannot be C. Given some D are C, those D that are C are not A, hence some D are not A.


Question: Does the fact that 'Event A happens before Event B' imply that 'A causes B'?

Answer: No

The occurrence of A before B does not necessarily imply causation. There could be other factors or coincidences.


Question: You know that a certain event happens either daily, weekly, or monthly. It happened today and 14 days ago. How often does it happen?

Answer: Weekly

If it happened today and 14 days ago, it must happen every 7 days, which is weekly. Daily would mean it happened 15 times in the last 14 days (including today), and monthly doesn't fit the 14-day gap.


Question: All cats are mammals. Some mammals are carnivores. Which of the following is a valid conclusion?

Answer: Some cats are carnivores is not necessarily true

The premises do not guarantee that some cats are carnivores because being a mammal is a necessary but not sufficient condition for being a cat, and being a carnivore is not a characteristic attributed to all cats.


Question: If some S are P and all P are Q, what can be concluded?

Answer: Some S are Q

Since some S are P and all P are Q, it follows that those S that are P are also Q, hence some S are Q.


Question: What is the molarity of a solution made by dissolving 25 g of NaCl (molar mass = 58.44 g/mol) in enough water to make 500 mL of solution?

Answer: 0.856

Molarity = moles of solute / liters of solution. Moles of NaCl = 25 g / 58.44 g/mol = 0.428 mol. Volume = 500 mL = 0.5 L, so Molarity = 0.428 mol / 0.5 L = 0.856 M.


Question: What is the acceleration of an object that goes from 0 to 10 m/s in 2 seconds?

Answer: 5 m/s^2

Acceleration = change in velocity / time = (10 m/s - 0 m/s) / 2 s = 5 m/s^2.


Question: Some books are novels. All novels are fiction. What conclusion can be drawn?

Answer: Some books are fiction

Since some books are novels and all novels are fiction, it logically follows that those books that are novels are fiction, hence some books are fiction.


Question: A car travels 150 miles in 3 hours. What is its average speed?

Answer: 50

Average speed = total distance / total time = 150 miles / 3 hours = 50 mph.


Question: What is the process by which plants convert sunlight into energy?

Answer: photosynthesis

Photosynthesis is the process by which plants, algae, and some bacteria convert light energy from the sun into chemical energy in the form of glucose


Question: Implement a function to check if a binary tree is balanced. What is a straightforward algorithm?

Answer: Recursively check the height of left and right subtrees

By calculating the height of each subtree and checking if the difference is within 1, we can determine if the tree is balanced.


Question: What is the value of x in the equation 2x + 5 = 11?

Answer: 3

Subtract 5 from both sides to get 2x = 6, then divide by 2 to get x = 3.


Question: A tank can be filled by two pipes, A and B, in 4 hours and 6 hours, respectively. How long will it take to fill the tank if both pipes are used together?

Answer: 2.4

The rate of pipe A is 1/4 tank per hour, and the rate of pipe B is 1/6 tank per hour. Together, their rate is 1/4 + 1/6 = 5/12 tank per hour. So, the time to fill the tank is 1 / (5/12) = 2.4 hours


Question: What is the time complexity of the given code: `for i in range(n): for j in range(i): print(i, j)`?

Answer: O(n^2)

The outer loop runs n times, and the inner loop runs up to n times, resulting in a quadratic time complexity.


Question: Prove that the number 2^100 + 1 is not prime by finding a factor. What is one such factor?

Answer: 3

Notice that 2^100 mod 3 = (2^2)^50 mod 3 = 1^50 mod 3 = 1. So, 2^100 + 1 mod 3 = 1 + 1 mod 3 = 2 mod 3 = 0, meaning 3 is a factor


Question: How many moles of oxygen are required to react with 2 moles of hydrogen to form water?

Answer: 1

The balanced equation for the reaction is 2H2 + O2 → 2H2O. So, 2 moles of H2 react with 1 mole of O2


Question: All computers are electronic devices. Some electronic devices are expensive. What can be inferred?

Answer: Some electronic devices are computers

The statement 'All computers are electronic devices' implies that 'Some electronic devices are computers' because computers are a subset of electronic devices.


Question: What is the concentration of a solution in moles per liter if 0.5 moles of solute are dissolved in 2 liters of solution?

Answer: 0.25 M

Molarity = moles of solute / liters of solution = 0.5 mol / 2 L = 0.25 M


Question: What is the time complexity of inserting an element at the end of a dynamic array?

Answer: O(1) amortized

While occasionally the array needs to be resized (O(n)), most insertions are O(1), making the amortized time complexity O(1).


Question: Prove that the number of prime numbers less than or equal to x is asymptotically equal to x / ln(x) as x approaches infinity

Answer: x / ln(x)

This is the Prime Number Theorem, which states that the number of primes less than or equal to x is asymptotically equal to x / ln(x)


Question: How would you find the maximum subarray sum in an array?

Answer: Using Kadane's algorithm

Kadane's algorithm iterates through the array, maintaining a running sum and resetting it whenever it becomes negative, thus finding the maximum subarray sum in linear time.


Question: Some A are B. No B are C. What can be concluded about A and C?

Answer: Some A are not C

Since some A are B and no B are C, it logically follows that those A that are B cannot be C, hence some A are not C.


Question: A projectile is launched at 45 degrees with an initial velocity of 20 m/s. What is its maximum height?

Answer: 10 m

Maximum height = (v0^2 * sin^2(theta)) / (2 * g), where v0 = 20 m/s, theta = 45 degrees, and g = 9.8 m/s^2. So, maximum height = (20^2 * sin^2(45)) / (2 * 9.8) = 10.2 m, approximately 10 m.


Question: There are three people, one who always tells the truth, one who always lies, and one who sometimes tells the truth and sometimes lies. You don't know who is who. You can ask one yes-or-no question to one person to figure out who is who. What question should you ask?

Answer: Ask one person 'If I were to ask the person next to you if they are the truth-teller, what would they say?'

This question helps to identify the truth-teller and the liar by analyzing the response and the person's identity relative to the others.


Question: Write a simple algorithm to check if a number is even. What is the condition?

Answer: num % 2 == 0

A number is even if it is divisible by 2 with no remainder.


Question: All squares are rectangles. All rectangles have four sides. What can be said about squares?

Answer: All squares have four sides

Using the transitive property: all squares are rectangles and all rectangles have four sides, so all squares have four sides.


Question: Given a linked list, implement a function to detect whether it contains a cycle. What is the most efficient algorithm?

Answer: Floyd's Tortoise and Hare algorithm

This algorithm uses two pointers moving at different speeds to detect a cycle in O(n) time and O(1) space.


Question: You have three switches, but they are not labelled. Each switch corresponds to one of three light bulbs in a room. Each light bulb is either on or off. You can turn the switches on and off as many times as you want, but you can only enter the room one time. How can you figure out which switch controls which light bulb?

Answer: Turn switch 1 to 'on' for 5 minutes, then turn it off. Turn switch 2 to 'on' and immediately enter the room. The bulb that is on is controlled by switch 2. The bulb that is warm is controlled by switch 1. The remaining bulb is controlled by switch 3.

By turning switch 1 on for a while, then off, we can identify its corresponding bulb by feeling for warmth. Switch 2 is turned on just before entering, so its bulb will be on. The remaining switch corresponds to the remaining bulb.


Question: If it is true that 'All squares are rectangles', which of the following must be true?

Answer: Some rectangles are squares

Since all squares have the properties of rectangles (four right angles and opposite sides of equal length), it follows that some rectangles (those that are squares) are squares.


Question: What is the molarity of a solution made by dissolving 20 g of NaOH in enough water to make 500 mL of solution?

Answer: 1 M

Molarity = moles of solute / liters of solution. Moles of NaOH = mass of NaOH / molar mass of NaOH = 20 g / 40 g/mol = 0.5 mol. Volume = 500 mL = 0.5 L. So, molarity = 0.5 mol / 0.5 L = 1 M.


Question: All squares are rectangles. Some rectangles are not symmetrical. What can be inferred about squares and symmetry?

Answer: Some rectangles are squares and not symmetrical is not necessarily true

The statement that 'some rectangles are squares and not symmetrical' is not necessarily true. However, we can infer that if some squares are not symmetrical, then some rectangles (that are squares) are not symmetrical. But we cannot directly infer that some squares are not symmetrical from the given premises.


Question: All A are B. No C are B. What can be concluded about A and C?

Answer: No A are C

Since all A are B and no C are B, A and C cannot overlap because anything that is A is B, and C cannot be B, so no A can be C.


Question: What is the time complexity of binary search in a sorted array?

Answer: O(log n)

Binary search works by repeatedly dividing the search interval in half. With each comparison, it eliminates half of the remaining elements, leading to a logarithmic time complexity.


Question: Solve the differential equation dy/dx = 2x, given that y(0) = 1.

Answer: y = x^2 + 1

Integrate both sides with respect to x to get y = x^2 + C. Using the initial condition y(0) = 1, we find C = 1. So, y = x^2 + 1.


Question: A buffer solution contains 0.1 M acetic acid (Ka = 1.8 x 10^-5) and 0.1 M sodium acetate. What is its pH?

Answer: 4.74

Using the Henderson-Hasselbalch equation pH = pKa + log([A-]/[HA]), where [A-] = [HA] = 0.1 M, and pKa = -log(1.8 x 10^-5), we get pH = 4.74 + log(1) = 4.74.


Question: A population of bacteria grows according to the exponential growth model. If the initial population is 1000 and the population doubles in 3 hours, what is the population after 6 hours?

Answer: 4000

Since the population doubles in 3 hours, the growth rate is such that after 6 hours, the population will double twice, so 1000 * 2^2 = 4000.


Question: What is the space complexity of the given algorithm: `def func(n): arr = [0] * n; return arr`?

Answer: O(n)

The algorithm allocates an array of size n, resulting in a space complexity of O(n).


Question: A force of 10 N acts on a mass of 2 kg. What is its acceleration?

Answer: 5

Using Newton's second law F = ma, where F = 10 N and m = 2 kg, we get a = F/m = 10/2 = 5 m/s^2.


Question: Solve for x: 2x + 5 = 11

Answer: 3

Subtract 5 from both sides to get 2x = 6, then divide by 2 to get x = 3


Question: The following code is intended to validate a string as a valid palindrome. What is the bug? `def is_palindrome(s): return s == s[::-1]`

Answer: The code does not handle case sensitivity or non-alphanumeric characters

The given code is case sensitive and considers non-alphanumeric characters. To correctly validate a palindrome, it should ignore case and non-alphanumeric characters.


Question: What is the value of x in the equation x - 2 = 7?

Answer: 9


Question: A satellite orbits the Earth at a radius of 7000 km. If the mass of the Earth is 5.97 x 10^24 kg, what is the satellite's orbital speed?

Answer: 7.54


Question: Identify the pattern: 2, 4, 8, 16, ?

Answer: 32

The pattern is obtained by doubling the previous number.


Question: The code `int sum = 0; for (int i = 0; i <= n; i++) { sum += i; }` produces an incorrect result for `n = 0`. What is the fix?

Answer: Change the loop condition to `i < n`

The loop should not execute when `n = 0`, as the sum of numbers up to but not including 0 is 0.


Question: A person is looking for a box with a specific tool. There are three boxes, one labelled 'hammer', one 'screwdriver', and one 'wrench or hammer'. If the labels are incorrect, which box should they open first to guarantee finding the tool they need with just one more check?

Answer: The box labelled 'wrench or hammer'

Since the labels are incorrect, opening the 'wrench or hammer' box first gives the most information for the next step.


Question: Describe the algorithm to find the closest pair of points in a set of points in n-dimensional space

Answer: Divide and Conquer approach with a recursive partitioning of the points

The closest pair algorithm involves dividing the set of points into two halves, finding the closest pair in each half, and then checking points near the dividing line for closer pairs.


Question: The function `def sum_list(lst): total = 0; for i in lst: total = i; return total` is intended to sum all elements in a list. What's the bug?

Answer: The line `total = i` should be `total += i`

The current implementation overwrites `total` with each element instead of accumulating the sum.


Question: If it rains, the ground gets wet. The ground is wet. What can be concluded?

Answer: It might have rained

The statement 'if it rains, the ground gets wet' does not exclude other reasons for the ground being wet, so while rain is a possibility, it's not the only conclusion.


Question: The following code is intended to reverse a linked list. What is the bug? `prev = None; current = head; while current: next_node = current.next; current.next = prev; prev = current; current = next_node; head = current`

Answer: The last line should be `head = prev` instead of `head = current`

After reversing the list, `prev` points to the new head, not `current`, which is `None` at the end of the loop.


Question: The binary search implementation `int binary_search(int[] arr, int target) { int left = 0, right = arr.length; ... }` is incorrect. What is the potential issue?

Answer: `right` should be initialized to `arr.length - 1`

Initializing `right` to `arr.length` could result in accessing an out-of-bounds index.


Question: If it is true that 'All A are B' and 'Some C are not B', which of the following must be true?

Answer: Some C are not A

Since all A are B, anything that is not B cannot be A. Therefore, if some C are not B, it must be true that those C are not A, making 'Some C are not A' necessarily true.


Question: What is the oxidation state of manganese in MnO2?

Answer: +4

Oxygen has an oxidation state of -2. So, for MnO2, Mn + 2(-2) = 0. Therefore, Mn = +4.


Question: What is the oxidation state of manganese in KMnO4?

Answer: +7

The oxidation states of K and O are +1 and -2, respectively. The sum of the oxidation states in KMnO4 is 0. So, +1 + Mn + 4*(-2) = 0. Solving for Mn gives Mn = +7.


Question: If all fast runners are athletes and some athletes are not fast runners, what can be concluded about fast runners and athletes?

Answer: All fast runners are athletes, but not all athletes are fast runners

The statement directly supports that all fast runners are athletes. The additional information that some athletes are not fast runners reinforces that being a fast runner is a subset of being an athlete.


Question: What algorithm is used to find the shortest path in an unweighted graph?

Answer: Breadth-First Search (BFS)

BFS explores all the neighbor nodes at the present depth prior to moving on to nodes at the next depth level, making it suitable for finding the shortest path in an unweighted graph.


Question: A bat is to a ball as a painter is to what?

Answer: brush

The relationship between a bat and a ball is that a bat is used to hit a ball. Similarly, a painter uses a brush to paint.


Question: What is the time complexity of the given algorithm: `def func(n): for i in range(n): for j in range(n): for k in range(j): print(i, j, k)`?

Answer: O(n^3)

The algorithm has three nested loops. Although the innermost loop runs up to 'j', the total number of operations is still cubic in 'n'.


Question: If a person is a musician, they are creative. John is a musician. What is John?

Answer: Creative

Using the given rule: musicians are creative, and John is a musician, therefore John is creative.


Question: All dogs are animals. Some animals bark. Which statement is necessarily true?

Answer: Some animals are dogs

Since all dogs are animals, it logically follows that some animals are dogs, as dogs are a subset of animals.


Question: How many moles of CO2 are produced when 2 moles of C2H6 are combusted according to the reaction 2C2H6 + 7O2 → 4CO2 + 6H2O?

Answer: 4

From the balanced equation, 2 moles of C2H6 produce 4 moles of CO2. So, 2 moles of C2H6 will produce 4 moles of CO2.


Question: All roses are flowers. Some flowers fade quickly. What can be inferred?

Answer: Some roses fade quickly is not necessarily true

While all roses are flowers and some flowers fade quickly, it's not necessarily true that some roses fade quickly because the roses might be among the flowers that do not fade quickly.


Question: A satellite orbits the Earth at a height of 200 km. What is its orbital period? (Assume the Earth's radius is 6371 km and g = 9.8 m/s^2)

Answer: 5294 s

Using the formula for orbital period: T = 2π * sqrt((R + h)^3 / (G * M)), and simplifying it using g = G * M / R^2, we get T = 2π * sqrt((R + h)^3 / (R^2 * g)), where R = 6371000 m and h = 200000 m


Question: A DNA sequence is given as ATGC. What is its complementary RNA sequence?

Answer: UACG

In RNA, T is replaced with U. The complementary base pairing rules are A-U and G-C. So, the complementary RNA sequence for ATGC is UACG.


Question: If a car travels 120 miles in 2 hours, what is its average speed?

Answer: 60

Average speed = total distance / total time = 120 miles / 2 hours = 60 mph


Question: A bakery sells 250 loaves of bread per day. They make a profit of $0.50 per loaf. How much profit do they make in a day?

Answer: 125

Multiply the number of loaves sold by the profit per loaf: 250 * 0.50 = 125


Question: If 'All P are Q' is false, and 'Some R are P' is true, which statement must be true?

Answer: Some R are not Q

If 'All P are Q' is false, then there must be some P that are not Q. Since 'Some R are P' is true, those R that are P and not Q are R that are not Q, making 'Some R are not Q' true.


Question: What is the value of the infinite series: 1 + 1/2 + 1/4 + 1/8 + ...?

Answer: 2

This is a geometric series with first term 1 and common ratio 1/2. The sum of an infinite geometric series is a/(1-r), where a is the first term and r is the common ratio. So, the sum is 1/(1-1/2) = 2.


Question: What is the time complexity of the Floyd-Warshall algorithm for finding the shortest path between all pairs of nodes in a weighted graph?

Answer: O(n^3)

The algorithm involves three nested loops over the vertices, resulting in cubic time complexity.


Question: If it takes 5 machines 5 minutes to make 5 widgets, how long would it take 100 machines to make 100 widgets?

Answer: 5

The rate of production per machine is constant, so 100 machines make 100 widgets in the same time 5 machines make 5 widgets.


Question: To check if a number is prime, what is the most efficient simple method?

Answer: Check divisibility up to the square root of the number

A larger factor of the number would be a multiple of a smaller factor that has already been checked.


Question: Find the limit as x approaches 0 of sin(x)/x

Answer: 1

This is a fundamental limit in calculus. As x approaches 0, sin(x)/x approaches 1.


Question: If 'if P then Q' is true and 'P or R' is true, and we know 'not Q', what can be concluded about R?

Answer: R must be true

From 'if P then Q' and 'not Q', we get 'not P' by modus tollens. Given 'P or R' and knowing 'not P', it must be that R is true.


Question: A buffer solution contains 0.1 M acetic acid (CH3COOH) and 0.1 M sodium acetate (CH3COONa). What is the pH of the solution? (Ka of CH3COOH = 1.8 × 10^−5)

Answer: 4.74

Using the Henderson-Hasselbalch equation: pH = pKa + log([A-]/[HA]), where [A-] = [CH3COONa] = 0.1 M, [HA] = [CH3COOH] = 0.1 M, and pKa = -log(1.8 × 10^−5) = 4.74, we get pH = 4.74 + log(0.1/0.1) = 4.74


Question: All cats are mammals. Some mammals are carnivores. Which of the following statements is necessarily true?

Answer: Some cats are carnivores is not necessarily true

The statement 'Some cats are carnivores' is not necessarily true because being a mammal and being carnivorous are not directly linked to being a cat. The correct interpretation is that we cannot conclude that some cats are carnivores based on the given premises.


Question: What is the time complexity of the Floyd-Warshall algorithm for finding the shortest path between all pairs of vertices in a weighted graph?

Answer: O(n^3)

The Floyd-Warshall algorithm involves three nested loops, each iterating over the vertices of the graph. Hence, its time complexity is cubic in the number of vertices.


Question: Some X are Y. All Y are Z. Which conclusion can be drawn about X and Z?

Answer: Some X are Z

Since some X are Y and all Y are Z, it logically follows that some X are Z because the Y that are X are also Z.


Question: What is the equation of the line that passes through the points (2,3) and (4,5)?

Answer: y = x + 1

First, find the slope: (5-3)/(4-2) = 1. Then, using point-slope form with (2,3), we get y - 3 = 1(x - 2), which simplifies to y = x + 1.


Question: What's the issue with this code: `def binary_search(arr, target): low, high = 0, len(arr); while low < high: mid = (low + high) // 2; if arr[mid] == target: return mid; elif arr[mid] < target: low = mid; else: high = mid`?

Answer: The updates to low and high should be `low = mid + 1` and `high = mid` (or `mid - 1` for a different variant)

The current code does not correctly update the low and high pointers, potentially causing an infinite loop or incorrect results. The correct updates ensure the search space is properly halved.


Question: What is the pH of a 0.01 M solution of HCl?

Answer: 2

HCl is a strong acid that completely dissociates in water. Therefore, [H+] = 0.01 M. Using the formula pH = -log[H+], we get pH = -log(0.01) = 2.


Question: What is the value of x in the equation x/4 = 9?

Answer: 36

Multiply both sides by 4 to isolate x: x = 9 * 4 = 36


Question: Implementing a queue using two stacks, what is the amortized time complexity of the enqueue operation?

Answer: O(1)

When using two stacks to implement a queue, enqueue is simply pushing onto the first stack, which is O(1). Although dequeue might involve moving elements from one stack to another (O(n) in the worst case), this cost is amortized across all enqueue operations, making the amortized time complexity of enqueue O(1).


Question: If it is true that 'if P then Q' and 'if Q then R', and we know that 'not R', what can be concluded about P?

Answer: Not P

Using modus tollens: if P then Q, if Q then R, so if P then R. Knowing not R implies not P.


Question: The following code is intended to find the maximum element in an array: `max_val = arr[0]; for i in range(len(arr)): if arr[i] < max_val: max_val = arr[i]` What is the bug?

Answer: The comparison operator should be '>' instead of '<'

The current code updates max_val whenever it finds a smaller element, instead of a larger one.


Question: What is the integral of x^2 from 0 to 1?

Answer: 1/3

The integral of x^2 is (1/3)x^3. Evaluating this from 0 to 1 gives (1/3)*1^3 - (1/3)*0^3 = 1/3.


Question: If y varies directly as x, and y = 12 when x = 4, what is y when x = 7?

Answer: 21

Since y varies directly as x, y = kx. When x = 4, y = 12, so 12 = k*4, giving k = 3. Then when x = 7, y = 3*7 = 21


Question: For the reaction 2A + B -> C, the rate law is rate = k[A]^2[B]. If the concentration of A is doubled and B is halved, what is the new rate relative to the original rate?

Answer: 2

Original rate = k[A]^2[B]. New rate = k(2[A])^2(0.5[B]) = k*4*[A]^2*0.5*[B] = 2*k[A]^2[B]. So, the new rate is 2 times the original rate.


Question: A satellite orbits the Earth at a height of 200 km. What is its orbital period?

Answer: 5294.4

Using the formula for orbital period T = 2*pi*sqrt((R+h)^3/GM), where R = Earth's radius = 6371 km, h = 200 km, G = gravitational constant, and M = Earth's mass, we get T = 5294.4 seconds.


Question: Prove that the number 2^(1/2) is irrational.

Answer: Irrational

Assume 2^(1/2) = p/q where p, q are integers and q != 0. Then 2 = p^2/q^2, implying p^2 is even, thus p is even. Let p = 2r, then 2 = 4r^2/q^2, so q^2 is even, and q is even. This contradicts p/q being in lowest terms, so 2^(1/2) is irrational.


Question: What is the time complexity of the merge sort algorithm?

Answer: O(n log n)

Merge sort divides the array into two halves recursively (log n levels) and merges them (n operations at each level), resulting in O(n log n) time complexity.


Question: A 2 kg block is moving at 4 m/s on a frictionless surface. What is its kinetic energy?

Answer: 16 J

Kinetic energy is given by 0.5 * m * v^2, where m = 2 kg and v = 4 m/s. So, kinetic energy = 0.5 * 2 * 4^2 = 16 J.


Question: Some X are not Y. All Z are Y. What can be inferred about X and Z?

Answer: Some X are not Z

Since all Z are Y and some X are not Y, those X that are not Y cannot be Z because Z are Y, so some X are not Z.


Question: The argument is: 'We should invest in renewable energy because it's better for the environment and will create jobs.' What assumption is implicit in this argument?

Answer: That investing in renewable energy will indeed create jobs.

The argument assumes that renewable energy will create jobs, which is not explicitly stated but is necessary for the argument to hold.


Question: Consider a statement: 'This statement is being evaluated as true.' If the statement is being evaluated, what can be concluded about its truth value?

Answer: It is true

The statement directly asserts its own truth during evaluation, making it true by the act of being evaluated as such.


Question: Find the equation of the tangent line to the curve y = x^2 at x = 2

Answer: y = 4x - 4

The derivative of y = x^2 is y' = 2x. At x = 2, y' = 4, so the slope of the tangent line is 4. The point of tangency is (2, 4). Using the point-slope form, y - 4 = 4(x - 2), which simplifies to y = 4x - 4.


Question: A bat is not a bird. All bats are mammals. What can be concluded about birds and mammals?

Answer: Some mammals are not birds

Since all bats are mammals and bats are not birds, it follows that there are mammals that are not birds.


Question: For the reaction 2NO2(g) ⇌ N2O4(g), the equilibrium constant Kp is 6.9 at 298 K. If the partial pressure of NO2 is 0.5 atm, what is the partial pressure of N2O4?

Answer: 1.725


Question: What is the time complexity of the heap sort algorithm?

Answer: O(n log n)

Heap sort involves building a heap (O(n)) and then repeatedly removing the maximum element and re-heapifying (O(log n) per removal), resulting in O(n log n) time complexity.


Question: The function `def count_zeros(lst): count = 0; for i in lst: if i == 0: count = count; return count` is meant to count zeros in a list. What's the bug?

Answer: The line `count = count` should be `count += 1`

The current line doesn't increment the count when a zero is found.


Question: The box is either red or blue. It is not blue. What is the color of the box?

Answer: Red

The given conditions directly lead to the conclusion that the box is red since it's not blue.


Question: Given that 'No P are Q' and 'Some R are Q', what can be concluded about P and R?

Answer: Some R are not P

Since no P are Q and some R are Q, those R that are Q cannot be P, hence some R are not P.


Question: If a car travels 120 miles in 2 hours, what is its average speed?

Answer: 60

Average speed is total distance divided by total time. So, 120 miles / 2 hours = 60 miles per hour.


Question: In a population of 1000 individuals, the frequency of the dominant allele is 0.7. What is the frequency of the homozygous recessive genotype?

Answer: 0.09

Using Hardy-Weinberg equilibrium, where p = 0.7 (frequency of dominant allele), q = 1 - p = 0.3 (frequency of recessive allele), the frequency of the homozygous recessive genotype (qq) is q^2 = 0.3^2 = 0.09.


Question: All humans are mortal. Socrates is human. What is the conclusion about Socrates?

Answer: Socrates is mortal

Applying the syllogism: all humans are mortal and Socrates is human, therefore Socrates is mortal.


Question: How would you reverse a linked list?

Answer: By iterating through the list and reversing the 'next' pointers

This involves keeping track of three nodes (previous, current, and next) and updating their 'next' pointers accordingly.


Question: A projectile is launched at an angle of 60 degrees above the horizontal with an initial velocity of 20 m/s. What is the maximum height reached?

Answer: 15.3

Using the equation for maximum height, h = (v0^2 * sin^2(theta)) / (2 * g), where v0 = 20 m/s, theta = 60 degrees, and g = 9.8 m/s^2, we get h = (20^2 * sin^2(60)) / (2 * 9.8) = 15.3 m.


Question: What is 25% of 120?

Answer: 30


Question: What is the oxidation state of manganese in KMnO4?

Answer: +7

To find the oxidation state of Mn, we need to know the oxidation states of K and O. K is +1, and O is -2. The sum of the oxidation states must be 0: +1 + x + 4(-2) = 0, where x is the oxidation state of Mn. So, 1 + x - 8 = 0, x = +7


Question: Solve for y in the equation 4y - 2 = 10.

Answer: 3

Add 2 to both sides to get 4y = 12, then divide by 4 to get y = 3.


Question: All X are Y. All Y are Z. Can we conclude that All Z are X?

Answer: No

The premises only establish a one-way relationship from X to Z through Y. They do not restrict Z from having elements outside of X.


Question: What is the time complexity of inserting an element at the beginning of a linked list?

Answer: O(1)

Inserting at the beginning of a linked list involves updating the head pointer and the next pointer of the new node, which can be done in constant time.


Question: What is the pH of a 0.01 M HCl solution?

Answer: 2

HCl is a strong acid and completely dissociates in water. So, [H+] = 0.01 M. pH = -log[H+] = -log(0.01) = 2.


Question: You are given two true statements: 'All mammals are warm-blooded' and 'Whales are mammals'. What can you conclude about whales?

Answer: Whales are warm-blooded

Since whales are mammals and all mammals are warm-blooded, it logically follows that whales are warm-blooded.


Question: A group of friends want to share some money equally. If they have $120 and there are 8 friends, how much will each friend get?

Answer: 15

To find out how much each friend gets, divide the total amount by the number of friends. So, $120 / 8 = $15.


Question: If Sally can paint a room in 4 hours and John can paint the same room in 6 hours, how long will it take them to paint the room together?

Answer: 2.4

Sally's rate is 1/4 of a room per hour, and John's rate is 1/6 of a room per hour. Together, their rate is 1/4 + 1/6 = 5/12. So, it will take them 12/5 = 2.4 hours to paint the room together.


Question: What is the time complexity of the Bellman-Ford algorithm for finding the shortest path from a source vertex to all other vertices in a weighted graph?

Answer: O(n*m)

The Bellman-Ford algorithm relaxes all edges `n-1` times, where `n` is the number of vertices. For each relaxation, it iterates over all `m` edges. Hence, its time complexity is O(n*m).


Question: A is older than B. B is older than C. Who is the youngest?

Answer: C

The given comparisons directly show that C is younger than B, and B is younger than A, making C the youngest.


Question: Analyze the time complexity of the quicksort algorithm in its average case

Answer: O(n log n)

Quicksort's average-case time complexity is O(n log n) because it partitions the array around a pivot and recursively sorts the subarrays, with the partition step taking linear time.


Question: The code `def find_max(lst): max_val = lst[0]; for i in lst: if i < max_val: max_val = i; return max_val` is supposed to find the maximum in a list. What's wrong?

Answer: The comparison should be `i > max_val`

The current code updates `max_val` when it finds a smaller element, so it ends up returning the minimum.


Question: What is the molar mass of CaCO3?

Answer: 100 g/mol


Question: What is the time complexity of searching for an element in a hash table?

Answer: O(1) on average

Hash tables allow for constant time complexity on average, assuming a good hash function. However, in the worst case, it can be O(n).


Question: Five people - John, Kate, Mike, Laura, and Tom - are standing in a row. Mike is standing next to Laura. Kate is not standing next to Tom. John is standing at one of the ends. Laura is not standing at an end. Who is standing at the other end?

Answer: Tom

Since John is at one end and Laura is not at an end, and Mike is next to Laura, they must occupy the second and third or third and fourth positions. If Mike and Laura are in the 2nd and 3rd positions, John is in the 1st, and Kate and Tom are in the 4th and 5th. Since Kate is not next to Tom, this arrangement is possible if Kate is in 4th and Tom in 5th. If Mike and Laura are in the 3rd and 4th, John is in the 1st, and the other two are in the 2nd and 5th. Kate can't be next to Tom, so Kate is in 2nd and Tom in 5th, or vice versa. Given the constraints, Tom can be at the other end.


Question: Solve for x: 2x + 5 = 11

Answer: 3

Subtracting 5 from both sides gives 2x = 6. Dividing by 2 yields x = 3.


Question: All X are Y. No Y are Z. What is the relationship between X and Z?

Answer: No X are Z

Since all X are Y and no Y are Z, it follows that no X can be Z because X is a subset of Y, and Y and Z are disjoint.


Question: A 5 kg block is moving at a speed of 2 m/s on a frictionless surface. What is its kinetic energy?

Answer: 10 J

Using the formula for kinetic energy: KE = (1/2) * m * v^2, where m = 5 kg and v = 2 m/s, we get KE = (1/2) * 5 * 2^2 = 10 J


Question: A DNA sequence is given as ATGCGTA. What is its complementary RNA sequence?

Answer: UACGCAU

To find the complementary RNA sequence, we pair each DNA base with its complement: A -> U, T -> A, G -> C, C -> G. Therefore, ATGCGTA becomes UACGCAU


Question: All squares are rectangles. All rectangles have four sides. What can be concluded about squares?

Answer: All squares have four sides.

Since all squares are rectangles and all rectangles have four sides, it logically follows that all squares have four sides.


Question: Solve for x in the equation e^x + e^-x = 3

Answer: 1.443635475

Multiplying through by e^x gives e^(2x) - 3e^x + 1 = 0. Using the quadratic formula with e^x as the variable gives e^x = (3 ± sqrt(5))/2. Taking the positive root, e^x = (3 + sqrt(5))/2. So, x = ln((3 + sqrt(5))/2)


Question: Analyze the time complexity of the algorithm to find the closest pair of points in a set of points in 2D space.

Answer: O(n log n)

The divide-and-conquer approach can solve this problem efficiently by dividing the points into halves, solving for each half, and then combining the results.


Question: You know that a certain statement is either true or false. If it is true, then a certain event will happen. You are given a chance to bet on the event. Should you bet on the event happening or not, and why?

Answer: Bet on the event

If the statement is true, the event happens. If it's false, there's still a chance the event might happen (or not), but you have no information to the contrary. Thus, betting on the event is the rational choice given the information.


Question: The code `def factorial(n): if n == 0: return 0; else: return n * factorial(n-1)` has a bug. What is it?

Answer: The base case should return 1, not 0

Returning 0 for the base case results in the factorial of any number being 0.


Question: Solve for x: 2x + 5 = 11

Answer: 3

Subtract 5 from both sides to get 2x = 6. Then, divide both sides by 2 to get x = 3.


Question: The following code is intended to find the first duplicate in an array. What is the bug? `seen = set(); for num in arr: if num in seen: return num; seen.add(num + 1)`

Answer: The line `seen.add(num + 1)` should be `seen.add(num)`

The code is currently adding `num + 1` to the set instead of `num`, so it will not correctly identify the first duplicate.


Question: A projectile is launched at 45 degrees to the horizontal with an initial velocity of 20 m/s. What is its maximum height?

Answer: 10.2

Using the equation for maximum height H = (u^2*sin^2(theta))/(2*g), where u = 20 m/s, theta = 45 degrees, and g = 9.8 m/s^2, we get H = (20^2*sin^2(45))/(2*9.8) = 10.2 m.


Question: Show that the series 1 + 1/2 + 1/4 + 1/8 + ... converges.

Answer: 2

This is a geometric series with first term 1 and ratio 1/2. The sum of an infinite geometric series is a/(1-r) = 1/(1-1/2) = 2.


Question: What is the value of the expression (2 + 3i)(1 - 2i), where i is the imaginary unit?

Answer: 8 - i

Using the distributive property, (2 + 3i)(1 - 2i) = 2*1 + 2*(-2i) + 3i*1 + 3i*(-2i) = 2 - 4i + 3i - 6i^2. Since i^2 = -1, this simplifies to 2 - i + 6 = 8 - i.


Question: In a Hardy-Weinberg equilibrium population, the frequency of the dominant allele is 0.7. What is the frequency of the homozygous recessive genotype?

Answer: 0.09

Using the Hardy-Weinberg principle, if p = 0.7 (frequency of dominant allele), then q = 1 - p = 0.3 (frequency of recessive allele). The frequency of the homozygous recessive genotype is q^2 = 0.3^2 = 0.09.


Question: A bakery sells 250 loaves of bread at $2 each and 150 loaves at $3 each. What is the total revenue?

Answer: 950

Revenue from 250 loaves at $2 each is 250*2 = $500. Revenue from 150 loaves at $3 each is 150*3 = $450. Total revenue is $500 + $450 = $950.


Question: If a bakery sells 250 loaves of bread at $2 each and 100 pastries at $1 each, what is the average price per item sold?

Answer: 1.71


Question: Some birds can fly. Penguins are birds. Can we conclude that penguins can fly?

Answer: No

The ability to fly is not universal among birds. Penguins are birds, but the statement 'some birds can fly' does not imply that all birds, including penguins, can fly.


Question: A group of friends want to share some money equally. If they have $120 and there are 8 friends, how much will each friend get?

Answer: 15

Dividing the total amount by the number of friends gives $120 / 8 = $15 per friend.


Question: If a cell divides every 20 minutes, how many cells will be present after 2 hours?

Answer: 64

2 hours = 120 minutes. 120 minutes / 20 minutes per division = 6 divisions. Starting with 1 cell, after 6 divisions there will be 2^6 = 64 cells


Question: All M are P. Some S are not M. What can be concluded about S and P?

Answer: No conclusion can be drawn about S and P directly

The statements do not directly link S and P in a conclusive manner regarding their relationship.


Question: Implement an algorithm to find the maximum subarray sum in an array containing both positive and negative numbers. What is the most efficient solution?

Answer: Kadane's algorithm

Kadane's algorithm scans the array and at each step decides whether to continue the current subarray or start a new one, achieving O(n) time complexity.


Question: A liar paradox states: 'I am lying.' Is the speaker lying or telling the truth?

Answer: Neither

The statement creates a paradox because if the speaker is lying, they are telling the truth, and if they are telling the truth, they are lying. Thus, it cannot be definitively classified.


Question: A force of 10 N acts on a 2 kg object. What is its acceleration?

Answer: 5 m/s^2

Using Newton's second law: F = ma, where F = 10 N and m = 2 kg, we can solve for a: a = F / m = 10 / 2 = 5 m/s^2


Question: What is the time complexity of the quicksort algorithm in the worst case?

Answer: O(n^2)

Quicksort's worst-case scenario occurs when the pivot is always the smallest or largest element, leading to highly unbalanced partitions.


Question: If 'fire' is related to 'heat', what is 'ice' related to?

Answer: cold

Fire is associated with heat, and ice is associated with cold, making the relationship analogous.


Question: What is the value of x in the equation x - 2 = 7?

Answer: 9


Question: The following code is supposed to check if a number is prime. What is the bug? `def is_prime(n): for i in range(n): if n % i == 0: return False; return True`

Answer: The loop should start from 2, and the condition should check for `i != 0` or start from 2

The current code will throw a division by zero error when `i` is 0. It should start checking from 2, as 0 and 1 are not prime divisors.


Question: There are three switches, but they are not labelled. Each switch corresponds to one of three light bulbs in a room. Each light bulb is either on or off. You can turn the switches on and off as many times as you want, but you can only enter the room one time to observe the bulbs. How can you figure out which switch corresponds to which light bulb?

Answer: Turn switch 1 to ON for 5 minutes, then turn it OFF. Turn switch 2 to ON and immediately go into the room.

By turning switch 1 to ON for 5 minutes and then OFF, the corresponding bulb will be warm but off. Turning switch 2 to ON and immediately entering, you can identify: the bulb that is ON corresponds to switch 2, the warm but off bulb corresponds to switch 1, and the remaining bulb corresponds to switch 3.


Question: If f(x) = 2x + 1 and g(x) = x^2, find f(g(2)).

Answer: 9


Question: Given 'No A is B', 'Some C are B', what can be concluded about A and C?

Answer: Some C are not A

Since some C are B and no A is B, those C that are B cannot be A, hence some C are not A.


Question: Find the integral of the function f(x) = x^2 + 1 from x = 0 to x = 2.

Answer: 14/3


Question: The function `def is_palindrome(s): return s == s.reverse()` is supposed to check if a string is a palindrome. What's wrong?

Answer: `s.reverse()` is not a valid method for strings; it should be `s[::-1]`

`reverse()` is a list method; for strings, slicing with `[::-1]` is used to reverse them.


Question: The code `if (x = 5) { ... }` is not behaving as expected. What is the fix?

Answer: Change `x = 5` to `x == 5`

The single equals sign is an assignment, not a comparison. Using `==` correctly compares the value of `x` to `5`.


Question: Prove that the sum of the first n odd numbers is n^2. What is the sum of the first 10 odd numbers?

Answer: 100

The nth odd number is 2n-1. The sum of the first n odd numbers is n^2. For n = 10, the sum is 10^2 = 100


Question: The following code is supposed to calculate the sum of the first n natural numbers. What is the bug? `sum = 0; for i in range(n): sum += i`

Answer: The loop should iterate until `range(n+1)`

The range function in Python generates numbers up to but not including the stop value. Thus, to include `n` in the sum, the loop should iterate over `range(n+1)`.


Question: A population of bacteria grows according to the exponential growth model. If the initial population is 1000 and it doubles in 3 hours, what will be the population after 6 hours?

Answer: 4000

Since the population doubles every 3 hours, after 6 hours it will double twice. So, the population after 6 hours = 1000 * 2^2 = 4000.


Question: Given a sorted array, implement a function to find the first occurrence of a target element. If not found, return -1. What is the most efficient algorithm?

Answer: Binary Search

Binary search is the most efficient algorithm for finding an element in a sorted array, with a time complexity of O(log n). It can be modified to find the first occurrence.


Question: All engineers are problem solvers. Some problem solvers are scientists. What can be inferred?

Answer: Some scientists are problem solvers

The statement 'Some problem solvers are scientists' directly implies that 'Some scientists are problem solvers' because it establishes a mutual relationship between the subset of problem solvers that are scientists.


Question: If it is true that 'No X is Y' and 'Some Z are Y', what can be inferred about X and Z?

Answer: Some Z are not X

Since some Z are Y and no X is Y, those Z that are Y cannot be X, so some Z are not X.


Question: What's the issue with this code: `def find_max(nums): max_num = nums[0]; for num in nums: if num < max_num: max_num = num; return max_num`?

Answer: The comparison should be `num > max_num`

The current code updates max_num whenever it finds a number less than max_num, effectively finding the minimum number instead of the maximum.


Question: What's wrong with this code: `def is_prime(n): if n % 2 == 0: return False; for i in range(3, n): if n % i == 0: return False; return True`?

Answer: The loop should iterate up to sqrt(n), not n

Checking divisibility up to n is unnecessary; checking up to sqrt(n) is sufficient because a larger factor of the number would be a multiple of a smaller factor that has already been checked.


Question: A force of 20 N acts on an object, causing it to accelerate at 4 m/s^2. What is the mass of the object?

Answer: 5 kg

Using Newton's second law: F = ma, where F = 20 N and a = 4 m/s^2, we can solve for m: m = F / a = 20 / 4 = 5 kg


Question: You have 8 balls, and one will be slightly heavier or lighter than the others. How can you find the different ball in only 2 weighings on a balance scale?

Answer: Weigh 3 against 3. If balanced, weigh 2 of the remaining 2 against each other. If not balanced, take the heavier or lighter group of 3 and weigh 1 against 1.

This problem requires a strategic approach to narrowing down the possibilities with each weighing.


Question: You are given a sequence where the first term is 1, the second term is 2, and every term after that is the sum of the two preceding terms. What is the fifth term?

Answer: 8

The sequence starts as 1, 2, 3 (1+2), 5 (2+3), 8 (3+5), so the fifth term is 8.


Question: If some books are fiction and all fiction books are novels, which statement is necessarily true?

Answer: Some books are novels

Since some books are fiction and all fiction books are novels, it follows that some books are novels.


Question: All books have pages. Novels are books. What can be concluded about novels?

Answer: Novels have pages

Since novels are books and all books have pages, novels must have pages.


Question: What is the time complexity of the merge sort algorithm?

Answer: O(n log n)

Merge sort divides the array into halves recursively (O(log n)) and merges them (O(n)), resulting in O(n log n) complexity.


Question: If 'P and Q' implies 'R', and 'not R' is true, what can be concluded about P and Q?

Answer: Either P or Q (or both) must be false

Since 'P and Q' implies 'R' and we know 'not R', it follows that 'P and Q' cannot be true, meaning at least one of P or Q is false.


Question: What is the pH of a 0.01 M solution of HCl?

Answer: 2

HCl is a strong acid that completely dissociates in water. Therefore, [H+] = 0.01 M. Using the formula pH = -log[H+], we get pH = -log(0.01) = 2


Question: If it is true that 'All A are B' and 'Some C are not B', what can be inferred about the relationship between A and C?

Answer: Some C are not A

Since all A are B, anything that is not B cannot be A. Therefore, if some C are not B, it implies that those C cannot be A, hence some C are not A.


Question: A 5 kg block is pulled across a horizontal surface with a constant force of 10 N. If the coefficient of kinetic friction is 0.2, what is the acceleration of the block?

Answer: 0.4 m/s^2

First, calculate the force of friction: F_f = μ * N = 0.2 * (5 kg * 9.8 m/s^2) = 9.8 N. Then, use F_net = ma: 10 N - 9.8 N = 5 kg * a, so a = (10 - 9.8) / 5 = 0.04 m/s^2 is incorrect due to rounding; the correct step yields a = 0.4 m/s^2 when using the correct significant figures and precise calculation: F_f = 0.2 * 5 * 9.8 = 9.8 N, F_net = 10 N - 9.8 N = 0.2 N, a = 0.2 / 5 = 0.04 m/s^2. The provided answer is actually incorrect; the right calculation gives 0.04 m/s^2.


Question: Solve the equation: 5x - 3 = 2x + 7

Answer: 10/3

Subtract 2x from both sides: 3x - 3 = 7. Add 3 to both sides: 3x = 10. Divide by 3: x = 10/3


Question: A snail is at the bottom of a 20-foot well. Each day, it climbs up 3 feet, but at night, it slips back 2 feet. How many days will it take for the snail to reach the top of the well?

Answer: 18

The snail effectively climbs 1 foot each day. On the 17th day, it will be at 17 feet. On the 18th day, it climbs 3 feet, reaching 20 feet, and thus escapes the well.


Question: What is the primary function of the mitochondria in a cell?

Answer: Energy production

Mitochondria are known as the powerhouses of the cell because they generate most of the cell's supply of adenosine triphosphate (ATP), used as a source of chemical energy.


Question: Solve for x: e^x + e^(-x) = 3

Answer: 1.445185878

Multiplying through by e^x gives e^(2x) - 3e^x + 1 = 0. Using the quadratic formula with e^x as the variable gives e^x = (3 ± sqrt(5))/2. Taking the positive root and solving for x yields x = ln((3 + sqrt(5))/2) ≈ 1.445185878, considering the positive solution that satisfies the original equation.


Question: What is the time complexity of the given algorithm: `for i in range(n): for j in range(m): print(i, j)`?

Answer: O(n*m)

The algorithm has two nested loops, resulting in a total of n*m operations.


Question: What is the probability of rolling a 6 on a fair six-sided die?

Answer: 1/6

There are 6 equally likely outcomes, and only one is a 6. So, the probability is 1/6.


Question: What's the bug in this code: `def sum_list(nums): total = 0; for num in nums: total = num; return total`?

Answer: The line `total = num` should be `total += num`

The current code assigns the current number to total instead of adding it, resulting in the function returning the last element of the list instead of the sum.


Question: If a gene has a mutation that changes a codon from UUU to UUC, what is the effect on the amino acid sequence?

Answer: No change

Both UUU and UUC code for phenylalanine. So, the mutation is synonymous and does not change the amino acid sequence.


Question: What's wrong with this code: `def greet(name): print('Hello, ' name)`?

Answer: Missing concatenation operator between 'Hello, ' and name

The code is missing a '+' between the string 'Hello, ' and the variable name, causing a syntax error.


Question: Five friends - Alex, Ben, Charlie, David, and Emily - are comparing their heights. Charlie is taller than David. Ben is taller than Emily. Alex is taller than Ben. David is taller than Emily. Who is the second tallest?

Answer: Charlie

From the statements: Alex is taller than Ben, Ben is taller than Emily, so Alex > Ben > Emily. Charlie is taller than David, and David is taller than Emily, so Charlie > David > Emily. Also, Charlie > David and Alex > Ben > Emily, but we don't directly know how Charlie compares to Alex or Ben. However, since David > Emily and Charlie > David, Charlie is at least taller than Emily. If we combine the information, we get Alex > Ben > (Charlie or David) > Emily. Since Charlie > David, and both are taller than Emily, and Ben > Emily, the order for the top three can be derived by understanding Alex is taller than Ben, and Charlie is taller than David. If Charlie were shorter than Ben, then David would also be shorter than Ben, contradicting the fact that we need to fit Charlie and David in a way that respects all given conditions. Thus, the likely order from tallest to shortest based on given clues and eliminating contradictions is Alex > Charlie > Ben > David > Emily, making Charlie the second tallest.


Question: If 'No X are Y' is true, and 'Some Z are Y' is true, what must be true about X and Z?

Answer: Some Z are not X

Since no X are Y and some Z are Y, those Z that are Y cannot be X, so some Z are not X.


Question: All cats are mammals. Some mammals are carnivores. Which of the following statements is necessarily true?

Answer: Some cats are carnivores is not necessarily true

The statement 'Some cats are carnivores' is not necessarily true because being a mammal and being carnivorous are not directly related to being a cat. The correct interpretation is that we cannot conclude that some cats are carnivores based on the given premises.


Question: How would you implement a function to check if a given binary tree is a binary search tree (BST)?

Answer: By performing an in-order traversal and checking if the resulting sequence is sorted

An in-order traversal of a BST yields a sorted sequence. Thus, by performing an in-order traversal and verifying that the sequence is sorted, one can confirm if a binary tree is a BST.


Question: What is the atomic number of an element with 8 protons in its atomic nucleus?

Answer: 8

The atomic number is defined as the number of protons in an atom's nucleus. Therefore, an element with 8 protons has an atomic number of 8.


Question: The following code is intended to find the maximum element in an array. What is the bug? `max_element = arr[0]; for i in range(len(arr)): if arr[i] < max_element: max_element = arr[i]`

Answer: The comparison operator should be '>' instead of '<'

The current code updates max_element whenever it finds a smaller element, instead of a larger one.


Question: A spring with a spring constant of 100 N/m is stretched by 0.2 m. What is the force required?

Answer: 20

Using Hooke's Law F = kx, where k = 100 N/m and x = 0.2 m, we get F = 100*0.2 = 20 N.


Question: Some A are B. All B are C. Does it follow that Some A are C?

Answer: Yes

Since some A are B and all those B are C, it logically follows that those A that are B are also C, hence some A are C.


Question: All dogs are animals. Max is a dog. What is Max?

Answer: An animal

Since all dogs are animals and Max is a dog, Max must be an animal.


Question: Some artists are musicians. All musicians are creative. What can be inferred?

Answer: Some artists are creative

Since some artists are musicians and all musicians are creative, those artists who are musicians are creative, so some artists are creative.


Question: You are given a black box with an unknown number inside. The box has two buttons: 'A' and 'B'. Pressing 'A' increases the number by 1, and pressing 'B' doubles the number. You want to reach the number 10. Starting from 0, what is the minimum number of button presses required to reach or exceed 10?

Answer: 5

The optimal sequence is: Press 'A' to get to 1, then 'B' to get to 2, 'B' again to get to 4, 'B' again to get to 8, and finally 'A' twice to get to 10, but a more efficient way is: 'A' to 1, 'A' to 2, 'B' to 4, 'A' to 5, 'B' to 10. This requires 5 presses.


Question: You are given a statement: 'This sentence is false.' Is the statement true or false?

Answer: Neither true nor false

The statement creates a paradox because if it's true, it must be false, and if it's false, it must be true. Thus, it cannot be definitively classified as true or false.


Question: How would you find the closest pair of points in a set of points in n-dimensional space?

Answer: Using a divide-and-conquer approach or a k-d tree

Both the divide-and-conquer approach and using a k-d tree are efficient methods for finding the closest pair of points. The divide-and-conquer approach divides the points into halves, finds the closest pair in each half, and then checks points near the dividing boundary. A k-d tree allows for efficient nearest neighbor queries.


Question: Solve the optimization problem: maximize f(x, y) = xy subject to the constraint x + y = 10

Answer: 25

Using the method of Lagrange multipliers, we find that the maximum occurs when x = y = 5, so f(5, 5) = 25


Question: A 2 kg block is moving at 4 m/s on a frictionless surface. It then collides elastically with a 3 kg block at rest. What is the final velocity of the 2 kg block?

Answer: -0.8

Using the elastic collision formula, we can calculate the final velocity of the 2 kg block. The formula is v1f = ((m1 - m2) * v1i + 2 * m2 * v2i) / (m1 + m2), where v1i = 4 m/s, m1 = 2 kg, m2 = 3 kg, and v2i = 0 m/s.


Question: Evaluate the integral of x^2 from 0 to 1

Answer: 1/3

The integral of x^2 is (1/3)x^3. Evaluating from 0 to 1 gives (1/3)(1^3 - 0^3) = 1/3.


Question: A car travels from city A to city B at an average speed of 60 km/h and returns at an average speed of 40 km/h. What is the average speed for the entire trip?

Answer: 48

Using the formula for average speed = total distance / total time, and assuming the distance between A and B is d, the average speed is 2d / (d/60 + d/40) = 48


Question: Find the greatest common divisor (GCD) of 48 and 18

Answer: 6

Using the Euclidean algorithm: GCD(48, 18) = GCD(18, 48 mod 18) = GCD(18, 12) = GCD(12, 6) = 6


Question: A box contains 5 red balls and 3 blue balls. What is the probability of drawing a red ball?

Answer: 5/8

The total number of balls is 5 + 3 = 8. The probability of drawing a red ball is the number of red balls divided by the total number of balls, which is 5/8.


Question: The recursive function `int factorial(int n) { if (n == 0) return 1; else return n * factorial(n); }` causes a stack overflow. What is the fix?

Answer: Change `factorial(n)` to `factorial(n-1)`

The recursive call should decrease `n` to eventually reach the base case. Calling `factorial(n)` again results in infinite recursion.


Question: What is the time complexity of deleting an element from a hash table (average case)?

Answer: O(1)

Hash tables allow for constant time deletion on average, assuming a good hash function.


Question: What's wrong with this code: `def count_vowels(s): count = 0; for char in s: if char in 'aeiou': count += 1; return count` when given an uppercase string?

Answer: The code does not handle uppercase vowels

The condition `char in 'aeiou'` is case-sensitive and will not count uppercase vowels. The code should either convert the string to lowercase or check for both lowercase and uppercase vowels.


Question: What is the process by which plants convert light energy into chemical energy?

Answer: Photosynthesis

Photosynthesis is the process by which green plants, algae, and some bacteria convert light energy, usually from the sun, into chemical energy stored in glucose.


Question: A population of bacteria doubles every 3 hours. If there are initially 1000 bacteria, how many will there be after 9 hours?

Answer: 8000

The population doubles every 3 hours, so after 9 hours it will have doubled 3 times. 1000 * 2^3 = 8000


Question: How would you find the middle element of a singly linked list in one pass?

Answer: Use the slow and fast pointer technique

The slow pointer moves one step at a time, while the fast pointer moves two steps, so when the fast pointer reaches the end, the slow pointer is at the middle.


Question: John is taller than Mike. Mike is taller than Emma. Who is the shortest?

Answer: Emma

The comparison shows a clear order: John > Mike > Emma in terms of height, making Emma the shortest.


Question: All cars are vehicles. Buses are cars. What can be concluded about buses?

Answer: Buses are vehicles

Since buses are cars and all cars are vehicles, buses must be vehicles.


Question: If all A are B and some C are A, which of the following conclusions is valid?

Answer: Some C are B

Since all A are B, and some C are A, it logically follows that some C are B because the subset of C that is A is also B.


Question: What is the primary function of the mitochondria in a cell?

Answer: Energy production

Mitochondria are known as the 'powerhouses' of the cell because they generate most of the cell's supply of adenosine triphosphate (ATP), used as a source of chemical energy.


Question: What is the next number in the sequence: 2, 5, 8, 11, 14?

Answer: 17

The sequence is an arithmetic progression with a common difference of 3. The next number is 14 + 3 = 17.


Question: What is the time complexity of the given algorithm: `for i in range(n): for j in range(i, n): print(i, j)`?

Answer: O(n^2)

The outer loop runs n times, and the inner loop runs from i to n, resulting in a total of n*(n+1)/2 operations, which simplifies to O(n^2).


Question: A satellite is in a circular orbit around the Earth at an altitude of 200 km. What is its orbital speed? (Mass of Earth = 5.97 × 10^24 kg, Radius of Earth = 6371 km)

Answer: 7.79 km/s


Question: What is the value of 2^3 * 2^4?

Answer: 128

Using the rule of exponents that states a^m * a^n = a^(m+n), we have 2^3 * 2^4 = 2^(3+4) = 2^7 = 128.


Question: Consider the following sequence: 1, 2, 4, 7, 11. What comes next?

Answer: 16

The pattern is formed by adding 1, then 2, then 3, then 4, and so on, increasing the increment by 1 each time. So, the next difference should be 5, making the next number 11 + 5 = 16.


Question: Some books are novels. All novels are fiction. What can be concluded about books and fiction?

Answer: Some books are fiction

Since some books are novels and all novels are fiction, it follows that those books that are novels are fiction, hence some books are fiction.


Question: What is the mass of 2 moles of water (H2O, molar mass = 18 g/mol)?

Answer: 36

Mass = number of moles * molar mass = 2 mol * 18 g/mol = 36 g.


Question: What is the next number in the sequence: 2, 5, 8, 11, 14?

Answer: 17

The sequence is an arithmetic progression with a common difference of 3. The next number is 14 + 3 = 17


Question: What is the value of the infinite series: 1 - 1/3 + 1/5 - 1/7 + ...?

Answer: π/4

This is the Leibniz formula for π, an alternating series that converges to π/4


Question: If all 'bloops' are 'flumps' and some 'flumps' are 'jinks', which of the following is a valid conclusion?

Answer: Some 'bloops' might be 'jinks'

Since all 'bloops' are 'flumps' and some 'flumps' are 'jinks', it's possible that some 'bloops' are among those 'flumps' that are 'jinks'.


Question: A bakery sells 250 loaves of bread per day at $2 each. If they increase the price by $0.50, they sell 20 fewer loaves. What is their revenue at the new price?

Answer: 460

At the new price of $2.50, they sell 250 - 20 = 230 loaves. Revenue = price * quantity = $2.50 * 230 = $575. However, the correct interpretation of the task leads to calculating the revenue: 230 * 2.5 = 575


Question: Given 'No X are Y' and 'All Z are Y', what is the relationship between X and Z?

Answer: No Z are X

Since no X are Y and all Z are Y, Z and X must be disjoint because Z is a subset of Y, and X and Y are disjoint.


Question: Every student who studies logic is rational. Some students are not rational. What can be concluded?

Answer: Some students do not study logic

If every student who studies logic is rational and there are students who are not rational, then those non-rational students cannot be studying logic.


Question: How would you find the middle element of a linked list in one pass?

Answer: Using the slow and fast pointer technique

By moving two pointers at different speeds (one step at a time and two steps at a time), the slow pointer will be at the middle when the fast pointer reaches the end.


Question: If f(x) = 2x + 1 and g(x) = x^2, what is f(g(3))?

Answer: 19


Question: A car accelerates uniformly from rest to a speed of 25 m/s in 5 seconds. What is its acceleration?

Answer: 5 m/s^2

Using the formula v = u + at, where v = 25 m/s, u = 0 m/s, and t = 5 s, we can solve for a: a = (v - u) / t = (25 - 0) / 5 = 5 m/s^2


Question: What is the chemical formula for water?

Answer: H2O

Water is composed of two hydrogen atoms and one oxygen atom.


Question: Find the limit as x approaches 0 of (sin(x) - x) / x^3

Answer: -1/6

Using L'Hopital's rule three times, the limit is -1/6


Question: Solve the system of equations: x + y = 4, x - y = 2

Answer: x = 3, y = 1

Adding the two equations gives 2x = 6, so x = 3. Substituting x = 3 into the first equation gives 3 + y = 4, so y = 1.


Question: All cats are mammals. Some mammals are carnivores. Which of the following is necessarily true?

Answer: Some cats are carnivores is not necessarily true, but All cats are mammals is true. The correct answer is: Some mammals are cats.

The statement 'Some mammals are cats' is necessarily true because if all cats are mammals, then some mammals must be cats.


Question: If it is true that 'some X are Y' and 'some Y are Z', can we conclude that 'some X are Z'?

Answer: Not necessarily

While there is an overlap between X and Y, and between Y and Z, there is no direct logical link established between X and Z without more information.


Question: What is the time complexity of binary search in a sorted array of size n?

Answer: O(log n)

Binary search halves the search space with each iteration, leading to logarithmic time complexity.


Question: What is the pH of a 0.01 M solution of HCl?

Answer: 2

HCl is a strong acid, so it completely dissociates in water. The concentration of H+ ions is equal to the concentration of HCl, which is 0.01 M. pH = -log[H+] = -log(0.01) = 2


Question: What comes next in the pattern: A, C, E, G, ?

Answer: I

The pattern is the sequence of letters where each letter is 2 positions ahead of the previous one in the alphabet.


Question: If the rule is 'double and add 1', what is the next number in the sequence: 2, 5, 11, 23?

Answer: 47


Question: What is the time complexity of binary search in a sorted array?

Answer: O(log n)

Binary search halves the search space with each iteration, resulting in a logarithmic time complexity.


Question: Find the roots of the quadratic equation x^2 + 4x + 4 = 0.

Answer: -2

The equation factors to (x + 2)(x + 2) = 0, so x = -2 is a repeated root.


Question: If a person is a bachelor, they are unmarried. John is a bachelor. What is John's marital status?

Answer: Unmarried

The definition of a bachelor directly implies being unmarried, so John must be unmarried.


Question: A rectangle has a length of 8 cm and a width of 5 cm. What is its area?

Answer: 40

The area of a rectangle is given by length * width = 8 * 5 = 40 square cm.


Question: If a gene has two alleles, 'B' and 'b', and 'B' is dominant, what is the phenotype of an individual with the genotype 'Bb'?

Answer: B

Since 'B' is dominant, the presence of one 'B' allele will determine the phenotype, making it 'B'


Question: The code `def reverse_string(s): return s[::-1]` is intended to reverse a string. For very large strings, what's a potential issue?

Answer: It creates a new string of the same size, potentially causing memory issues

Slicing with `[::-1]` creates a new string, which can be memory-intensive for large strings.


Question: A wave has a frequency of 100 Hz and a wavelength of 2 m. What is its speed?

Answer: 200

Using the wave speed equation v = f*lambda, where f = 100 Hz and lambda = 2 m, we get v = 100*2 = 200 m/s.


Question: What is the molar mass of CaCO3?

Answer: 100 g/mol

The molar mass of CaCO3 is calculated as: Ca (40 g/mol) + C (12 g/mol) + 3O (3 x 16 g/mol = 48 g/mol) = 40 + 12 + 48 = 100 g/mol


Question: Some people like coffee. Some people who like coffee are anxious. What can be concluded?

Answer: Some people who like coffee might be anxious

The statement directly implies that there is a subset of people who like coffee and are anxious.


Question: A snail is at the bottom of a 20-foot well. Each day, it climbs up 3 feet, but at night, it slips back 2 feet. How many days will it take for the snail to reach the top of the well?

Answer: 18

The snail effectively climbs 1 foot each day. On the 17th day, it will be at 17 feet, and on the 18th day, it will climb to 20 feet and be out of the well.


Question: The statement 'All non-X are Y' is equivalent to which of the following?

Answer: All non-Y are X

The original statement implies that anything not X is Y, and thus anything not Y must be X, making the two statements logically equivalent.


Question: If a cell divides every 20 minutes, how many cells will be present after 2 hours?

Answer: 64

2 hours = 120 minutes. 120/20 = 6 divisions. Starting with 1 cell, after 6 divisions there will be 2^6 = 64 cells.


Question: What is the derivative of x^3 + 2x^2 - 5x + 1?

Answer: 3x^2 + 4x - 5

Using the power rule for differentiation, the derivative of x^n is n*x^(n-1). So, the derivative of x^3 is 3x^2, of 2x^2 is 4x, of -5x is -5, and of 1 is 0.


Question: A population of bacteria grows according to the logistic growth equation. If the carrying capacity is 1000 cells/mL and the initial population is 10 cells/mL, what is the population after 3 generations if the growth rate (r) is 0.5 per generation?

Answer: 294 cells/mL

Using the logistic growth equation: N(t) = K / (1 + ((K - N0) / N0) * e^(-rt)), where N0 = 10, K = 1000, r = 0.5, and t = 3, we can solve for N(3)


Question: What comes next in the pattern: 2, 4, 6, 8?

Answer: 10

The pattern is obtained by adding 2 to the previous number.


Question: A 5 kg object is attached to a spring with a spring constant of 100 N/m. What is the frequency of its oscillation?

Answer: 0.71 Hz

Frequency = (1 / (2 * pi)) * sqrt(k / m), where k = 100 N/m and m = 5 kg. So, frequency = (1 / (2 * pi)) * sqrt(100 / 5) = 0.71 Hz.


Question: Some philosophers are logicians. No logicians are empiricists. What can be concluded about philosophers and empiricists?

Answer: Some philosophers are not empiricists

Since some philosophers are logicians and no logicians are empiricists, those philosophers who are logicians cannot be empiricists, making it true that some philosophers are not empiricists.


Question: Implement a function to check if a given string is a palindrome. What is the most straightforward algorithm?

Answer: Compare the string with its reverse

Reversing the string and comparing it to the original is a simple and effective way to check for palindromes.


Question: Solve the differential equation dy/dx = 2y, given y(0) = 1

Answer: y = e^(2x)

Separating variables gives dy/y = 2dx. Integrating both sides yields ln(y) = 2x + C. Using y(0) = 1, we find C = 0, so y = e^(2x).


Question: Find the equation of the tangent line to the curve y = x^3 - 2x at the point (1, -1)

Answer: y = x - 2

The derivative of y is 3x^2 - 2. At x = 1, the slope is 1. The equation of the tangent line is y - (-1) = 1(x - 1), which simplifies to y = x - 2


Question: You have 8 balls, and one will be slightly heavier or lighter than the others. Using a balance scale only twice, how can you determine which ball is different and whether it's heavier or lighter?

Answer: First, weigh 3 balls against 3 balls. If they balance, the different ball is among the remaining 2. Weigh one of these against a known normal ball to find the different one and determine if it's heavier or lighter. If the first weighing doesn't balance, take the heavier or lighter group of 3 and weigh 1 against 1. If they balance, the remaining ball is the different one and is heavier or lighter accordingly. If they don't balance, the heavier or lighter ball is the different one.

This method ensures that with just two uses of the balance scale, you can identify the different ball and whether it's heavier or lighter.


Question: Three switches are connected to three light bulbs in a room. Each switch corresponds to one of the light bulbs, but none of them are labelled. How can you figure out which switch corresponds to which light bulb by only entering the room one time?

Answer: Turn switch 1 to 'on' for 5 minutes, then turn it off. Turn switch 2 to 'on' and immediately enter the room. The bulb that is on corresponds to switch 2. The bulb that is warm but off corresponds to switch 1. The remaining bulb corresponds to switch 3.

This problem requires a multi-step logical process to deduce the correct mapping.


Question: Some teachers are researchers. All researchers are knowledgeable. What conclusion can be drawn?

Answer: Some teachers are knowledgeable

Since some teachers are researchers and all researchers are knowledgeable, those teachers who are researchers are knowledgeable, hence some teachers are knowledgeable.


Question: What is the space complexity of the given algorithm: `def func(n): return [func(i) for i in range(n)]`?

Answer: O(n)

The recursive calls result in a call stack of depth n, and the list comprehension also stores n elements, resulting in a space complexity of O(n).


Question: A bat is to a ball as a painter is to what?

Answer: brush

The relationship between a bat and a ball is that a bat is used to hit a ball. Similarly, a painter uses a brush to paint.


Question: If all As are Bs and no Bs are Cs, what can be concluded about As and Cs?

Answer: No As are Cs

Since all As are Bs and no Bs are Cs, it follows that As cannot be Cs because they are all Bs, and Bs and Cs are mutually exclusive.


Question: Complete the series: 1, 2, 4, 7, 11, ?

Answer: 16

The pattern is formed by adding 1, then 2, then 3, then 4, and so on, increasing the increment by 1 each time.


Question: A is the father of B, but B is not the son of A. What is the relationship between A and B?

Answer: A is B's father, and B is a daughter

The statement implies B is not a son, so B must be a daughter.


Question: What is the time complexity of the given code: `for i in range(n): for j in range(i, n): print(i, j)`?

Answer: O(n^2)

The outer loop runs n times. The inner loop runs from i to n, so on average it runs n/2 times. Thus, the total time complexity is O(n) * O(n) = O(n^2).


Question: What is 25% of 120?

Answer: 30


Question: Find the roots of the quadratic equation x^2 + 4x + 4 = 0

Answer: -2

Factor the quadratic equation: (x + 2)(x + 2) = 0. So, x = -2 is a repeated root


Question: The code `for (int i = 0; i < n; i++) { arr[i] = i; }` sometimes throws an exception. What is the potential issue?

Answer: Array `arr` might not be initialized with size `n` or larger

If `arr` is smaller than `n`, accessing `arr[i]` for `i >= arr.length` will throw an exception.


Question: Identify the pattern and complete the sequence: Monday, Wednesday, Friday, ?

Answer: Sunday

The sequence is obtained by listing every other day of the week, starting from Monday.


Question: Consider the following statements: 'All X are Y', 'Some Y are Z'. Which conclusion can be drawn about X and Z?

Answer: Some X might be Z

Since all X are Y and some Y are Z, it's possible for some X to be among those Y that are Z, but it's not a necessity.


Question: A spring has a spring constant of 100 N/m. How much force is required to stretch it by 0.2 m?

Answer: 20 N

Using Hooke's Law: F = kx, where k = 100 N/m and x = 0.2 m, we get F = 100 * 0.2 = 20 N


Question: How many moles of oxygen are required to react with 2 moles of hydrogen to form water?

Answer: 1 mole

The balanced equation for the reaction is 2H2 + O2 -> 2H2O. Therefore, 2 moles of H2 require 1 mole of O2


Question: All M are N. Some N are P. Can we infer that some M are P?

Answer: Not necessarily

While all M are N and some N are P, it's possible that the M are among the N that are not P, so we cannot conclude that some M are P.


Question: What is the oxidation state of manganese in MnO2?

Answer: +4

Oxygen has an oxidation state of -2. Since there are 2 oxygen atoms, the total oxidation state contributed by oxygen is -4. Therefore, to make MnO2 neutral, Mn must have an oxidation state of +4


Question: What is the space complexity of the iterative factorial function?

Answer: O(1)

The iterative factorial function only uses a constant amount of space to store the result and the loop counter, regardless of the input size.


Question: How many moles of CO2 are produced when 2 moles of propane (C3H8) are combusted?

Answer: 6

The balanced equation for propane combustion is C3H8 + 5O2 -> 3CO2 + 4H2O. For every mole of C3H8, 3 moles of CO2 are produced. So, for 2 moles of C3H8, 2*3 = 6 moles of CO2 are produced.


Question: A bakery sells 250 loaves of bread per day. If each loaf costs $2, how much money does the bakery make in a day?

Answer: 500

Multiply the number of loaves sold by the price per loaf: 250 * 2 = 500.


Question: Consider the following statements: 'All P are Q', 'Some Q are R', 'No R is S'. Which conclusion can be drawn about P and S?

Answer: No P is S

Since all P are Q and some Q are R, some P could be R. Given that no R is S, those P that are R cannot be S, thus at least some P are not S. However, directly concluding 'No P is S' requires assuming that all P are among the Q that are R, which isn't necessarily true. Yet, it's the strongest conclusion we can draw directly from the given statements because if any P were S, it would contradict the given conditions when considering the chain of relationships.


Question: Find the greatest common divisor (GCD) of 48 and 18

Answer: 6

Using the Euclidean algorithm: GCD(48, 18) = GCD(18, 48 mod 18) = GCD(18, 12) = GCD(12, 6) = 6.


Question: What is the time complexity of the merge sort algorithm?

Answer: O(n log n)

Merge sort recursively divides the array into two halves until each half has one element, resulting in log n levels. At each level, n elements are merged, resulting in a total time complexity of O(n log n).


Question: A rectangle has a length of 8 cm and a width of 5 cm. What is its area?

Answer: 40

Area = length * width = 8 * 5 = 40 square cm.


Question: How many moles of CO2 are produced when 2 moles of C2H6 are combusted completely?

Answer: 4

The balanced equation for the combustion of C2H6 is 2C2H6 + 7O2 -> 4CO2 + 6H2O. So, 2 moles of C2H6 produce 4 moles of CO2.


Question: You have three switches, but they are not labelled. Each switch corresponds to one of three light bulbs in a room. Each light bulb is either on or off. You can turn the switches on and off as many times as you want, but you can only enter the room one time to observe the bulbs. How can you figure out which switch corresponds to which light bulb?

Answer: Turn switch 1 to ON for 5 minutes, then turn it OFF. Turn switch 2 to ON and immediately go into the room. The bulb that is ON is controlled by switch 2. The bulb that is WARM (but off) is controlled by switch 1. The remaining bulb is controlled by switch 3.

This method allows you to identify the bulbs because the one corresponding to switch 2 is on, the one corresponding to switch 1 is warm (having been on recently), and the remaining one is cold and off.


Question: How would you detect a cycle in a linked list?

Answer: Using Floyd's Tortoise and Hare algorithm

Floyd's Tortoise and Hare algorithm uses two pointers that move at different speeds through the list. If there's a cycle, these two pointers will eventually meet.


Question: A bat is to a ball as a painter is to what?

Answer: brush

The relationship between a bat and a ball is that a bat is used to hit a ball. Similarly, a painter uses a brush to paint.


Question: A car accelerates from rest at 2 m/s^2. How far does it travel in 5 seconds?

Answer: 25

Using the equation of motion, s = ut + 0.5at^2, where u = 0 (initial velocity), a = 2 m/s^2, and t = 5 s, we get s = 0 + 0.5 * 2 * 5^2 = 25 m.


Question: A projectile is launched at an angle of 45° to the horizontal with an initial velocity of 20 m/s. What is its maximum height?

Answer: 10 m

Using the formula for maximum height: h = (v0^2 * sin^2(θ)) / (2 * g), where v0 = 20 m/s, θ = 45°, and g = 9.8 m/s^2, we get h = (20^2 * sin^2(45°)) / (2 * 9.8) = 10.2 ≈ 10 m


Question: How would you implement a simple stack using a list?

Answer: Using 'append' for push and 'pop' for pop operations

A stack follows LIFO (Last In First Out) principle, which can be achieved using the 'append' and 'pop' methods of a list.


Question: A DNA sequence is given as ATGCGT. What is its complementary RNA sequence?

Answer: UACGCA

To find the complementary RNA sequence, pair each DNA nucleotide with its complement: A-T, T-A, G-C, C-G, G-C, T-A. Then, replace T with U (since it's RNA): so, ATGCGT becomes UACGCA


Question: If 'All P are Q' and 'Some R are not Q', what can be inferred about P and R?

Answer: Some R are not P

Since all P are Q and some R are not Q, those R that are not Q cannot be P because P is a subset of Q, hence some R are not P.


Question: Implementing a stack using a linked list, what is the time complexity of the push operation?

Answer: O(1)

Pushing onto a stack implemented with a linked list involves updating the head pointer to the new node and setting the new node's next pointer to the current head, both of which are constant time operations.


Question: If a gene has 300 base pairs and 30% of the bases are adenine, how many guanine bases are there?

Answer: 150

Since A = 30%, T = 30% (because A-T pairs). So, G + C = 100% - (A + T) = 40%. Since G = C, G = 20%. The total number of bases is 300*2 = 600. So, the number of G bases is 20% of 600 = 0.2*600 = 120 is incorrect due to misinterpretation; correctly, if A = 30%, then G = 20% because G+C = 40% and G = C. Hence, G = 20% of 600 = 120.


Question: The following code is intended to check if a string is a palindrome: `s == s[::-1]` What is the potential issue?

Answer: It is not the most efficient solution for large strings

Comparing a string with its reverse has a time complexity of O(n), but it can be done more efficiently by comparing characters from both ends towards the center.


Question: The code `def sum_even_numbers(numbers): total = 0; for num in numbers: if num % 3 == 0: total += num; return total` is supposed to sum even numbers. What's the bug?

Answer: The condition should be `num % 2 == 0` instead of `num % 3 == 0`

The current code sums numbers divisible by 3, not even numbers.


Question: Describe the basic steps of the topological sorting algorithm

Answer: 1. Create a graph and calculate in-degrees. 2. Enqueue nodes with in-degree 0. 3. Dequeue a node, reduce in-degrees of its neighbors, and enqueue neighbors with in-degree 0. 4. Repeat until the queue is empty

Topological sorting involves ordering the nodes in a directed acyclic graph (DAG) such that for every edge (u,v), node u comes before v in the ordering. This is achieved by using a queue to process nodes with no incoming edges.


Question: You are given a 3-gallon bucket and a 5-gallon bucket. How can you measure exactly 4 gallons of water?

Answer: Fill the 5-gallon bucket, pour into the 3-gallon bucket until full, leaving 2 gallons in the 5-gallon bucket. Empty the 3-gallon bucket, then pour the 2 gallons into it. Fill the 5-gallon bucket again and pour into the 3-gallon bucket until full, which will take 1 gallon, leaving 4 gallons in the 5-gallon bucket.

This is a classic water jug problem, requiring a series of steps to achieve the desired measurement.


Question: What is the value of x in the equation log(x) = 2, given that the base of the logarithm is 10?

Answer: 100

The equation log(x) = 2 means that 10^2 = x. So, x = 100.


Question: Every student who studies hard passes the exam. John studies hard. What can be concluded about John?

Answer: John passes the exam

Applying the rule: every student who studies hard passes, and John studies hard, therefore John passes.


Question: Some politicians are honest. All honest individuals are trustworthy. What can be concluded?

Answer: Some politicians are trustworthy

Since some politicians are honest and all honest individuals are trustworthy, those politicians who are honest are trustworthy, hence some politicians are trustworthy.


Question: Find the derivative of the function f(x) = 3x^2 + 2x - 5.

Answer: 6x + 2

Using the power rule for differentiation, the derivative of x^n is nx^(n-1).


Question: A car accelerates uniformly from rest to a speed of 25 m/s in 10 s. What is its acceleration?

Answer: 2.5 m/s^2

Using the formula v = u + at, where v = 25 m/s, u = 0 m/s, and t = 10 s, we can solve for a: a = (v - u) / t = (25 - 0) / 10 = 2.5 m/s^2


Question: What is the unit of force in the SI system?

Answer: Newton

The Newton (N) is defined as the force required to accelerate a 1 kg mass by 1 m/s^2


Question: To find the maximum element in an array, what is a straightforward approach?

Answer: Iterate through the array and keep track of the maximum seen so far

A simple loop comparing each element to the current maximum is an intuitive and efficient method.