Introduction to Programming
- 78Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is programming, according to the lecture?
What is programming, according to the lecture?
78 questions
- 1
What is programming, according to the lecture?
- A
Teaching a computer to think like a human
- B
Translating English into binary code for computers
- C
Writing instructions in a programming language to create software
- D
The process of preparing an instructional program for a device
Correct answer
DThe process of preparing an instructional program for a device
Explanation
The lecture defines programming as 'the process of preparing an instructional program for a device' (the dictionary definition), and then explains it in layman's terms as attempting to get a computer to complete a specific task without mistakes.
- A
- 2
Why is a computer considered 'very dumb' in the context of programming?
- A
Because it has limited memory and processing speed
- B
Because it requires very specific instructions and cannot infer intent
- C
Because it cannot perform arithmetic operations without explicit instructions
- D
Because it only understands binary and cannot process high-level languages
Correct answer
BBecause it requires very specific instructions and cannot infer intent
Explanation
The lecture emphasizes that computers are 'actually very dumb' and need extremely specific instructions; if one detail is missing, the program fails. This is illustrated with the Lego analogy.
- A
- 3
What does a computer understand natively?
- A
Natural English language
- B
Assembly language
- C
High-level programming languages
- D
Machine code in binary (0s and 1s)
Correct answer
DMachine code in binary (0s and 1s)
Explanation
The lecture states that computers only understand machine code, which is a numerical language (binary) consisting of 1's and 0's. Every instruction must be converted into this form.
- A
- 4
What is the role of a programming language?
- A
To provide a graphical interface for writing code
- B
To act as an intermediary translating human-readable code into machine code
- C
To debug programs automatically
- D
To replace machine code entirely
Correct answer
BTo act as an intermediary translating human-readable code into machine code
Explanation
The lecture describes programming languages as a 'middle man' that translates instructions from human-readable form into machine code, analogous to an interpreter for a non-English speaking friend.
- A
- 5
Which of the following is an example of a low-level programming language?
- A
Assembly
- B
Java
- C
JavaScript
- D
Python
Correct answer
AAssembly
Explanation
The lecture mentions that low-level programming languages like assembly or C are closer to binary than high-level languages such as Java or Python.
- A
- 6
What does IDE stand for?
- A
Integrated Debugging Environment
- B
Initial Development Environment
- C
Integrated Development Environment
- D
Interactive Design Editor
Correct answer
CIntegrated Development Environment
Explanation
The lecture explicitly states that IDE stands for Integrated Development Environment, providing a graphic interface to write, run, and debug code.
- A
- 7
What is a major advantage of using an IDE?
- A
It eliminates all programming errors
- B
It provides tools like error checking, auto-fill, and project hierarchy
- C
It converts high-level code directly into binary
- D
It automatically writes code for the programmer
Correct answer
BIt provides tools like error checking, auto-fill, and project hierarchy
Explanation
The lecture lists built-in error checking, auto-fill for frequently used words/phrases, and project hierarchy as useful tools provided by IDEs.
- A
- 8
What is syntax in programming?
- A
The process of debugging code
- B
The set of rules that define the structure of a programming language
- C
The speed at which code executes
- D
The graphical layout of an IDE
Correct answer
BThe set of rules that define the structure of a programming language
Explanation
The lecture defines syntax as the grammar of a programming language, a set of rules that must be followed for the code to run correctly.
- A
- 9
What happens if you break a syntax rule in a program?
- A
The program will not run and returns a syntax error
- B
The program may still run but with unexpected results
- C
The program runs slower
- D
The program automatically fixes the error
Correct answer
AThe program will not run and returns a syntax error
Explanation
The lecture explains that breaking syntax rules results in an error (syntax error), and the IDE will not let you run the program until the error is fixed.
- A
- 10
What is the main purpose of the console in programming?
- A
To store variables during execution
- B
To output text from the program for the developer
- C
To display graphics to the end user
- D
To compile the code into machine language
Correct answer
BTo output text from the program for the developer
Explanation
The lecture states that the console is a text interface used by programmers to output information (e.g., via print statements) and is a developer tool, not intended for end users.
- A
- 11
In Python, what does the code
print("Hello World")do?- A
Displays a message box with 'Hello World'
- B
Prints 'Hello World' to the console
- C
Prints 'Hello World' on paper
- D
Writes 'Hello World' to a file
Correct answer
BPrints 'Hello World' to the console
Explanation
The lecture gives this exact example: in Python,
print("Hello World")causes the message 'hello world' to appear on the console. - A
- 12
Why should the console not be used in the final product for end users?
- A
Because it requires additional libraries
- B
Because it is hidden behind the scenes and not meant for user-facing output
- C
Because it only works in debug mode
- D
Because it is too slow for real-time applications
Correct answer
BBecause it is hidden behind the scenes and not meant for user-facing output
Explanation
The lecture clearly states that the console is a developer tool and is not meant to be viewed by the end user; other methods like graphics are used for user-facing output.
- A
- 13
Which arithmetic operators are natively understood by a computer?
- A
Addition, subtraction, multiplication, and division only
- B
Addition, subtraction, multiplication, division, and modulus
- C
All mathematical functions including trigonometry
- D
Only addition and subtraction
Correct answer
BAddition, subtraction, multiplication, division, and modulus
Explanation
The lecture covers the four basic operations (+, -, *, /) and also introduces modulus (%), stating that computers know how to do simple arithmetic including these.
- A
- 14
What does the modulus operator (%) do?
- A
Raises a number to a power
- B
Returns the remainder of a division
- C
Multiplies two numbers
- D
Returns the quotient of a division
Correct answer
BReturns the remainder of a division
Explanation
The lecture defines modulus as getting the remainder of a divisional operation, e.g., 10 modulus 3 returns 1.
- A
- 15
How can you determine if an integer is even using modulus?
- A
If the number modulus 1 equals 0, it is even
- B
If the number modulus 2 is greater than 0, it is even
- C
If the number modulus 2 equals 0, it is even
- D
If the number modulus 2 equals 1, it is even
Correct answer
CIf the number modulus 2 equals 0, it is even
Explanation
The lecture explains that if
number % 2returns 0, the number is even; if it returns 1, it is odd. - A
- 16
What is a string in programming?
- A
A variable that stores true or false
- B
A numeric data type for integers
- C
A function that prints text
- D
A sequence of characters enclosed in quotation marks
Correct answer
DA sequence of characters enclosed in quotation marks
Explanation
The lecture defines strings as 'another way to just say text' and notes that anything enclosed by quotation marks is denoted as a string.
- A
- 17
What is concatenation?
- A
Converting a string to uppercase
- B
Joining two or more strings together using the + operator
- C
Comparing two strings for equality
- D
Dividing a string into parts
Correct answer
BJoining two or more strings together using the + operator
Explanation
The lecture introduces concatenation as 'adding' strings together (e.g.,
"Game over, " + 4 + " was your final score") to produce a combined string. - A
- 18
What is the difference between
"4"and4in programming?- A
4is a string, while"4"is an integer - B
There is no difference; both represent the number 4
- C
Both are strings, but
4can be used in arithmetic - D
"4"is a string, while4is a numeric integer
Correct answer
D"4"is a string, while4is a numeric integerExplanation
The lecture emphasizes that
"4"in quotation marks is treated as a string, whereas4without quotation marks is treated as a number. Trying to do math with a string will cause an error. - A
- 19
What is a variable?
- A
A storage location in memory that holds a value and can be referenced and manipulated
- B
A fixed value that cannot change
- C
A function that returns a value
- D
A type of loop structure
Correct answer
AA storage location in memory that holds a value and can be referenced and manipulated
Explanation
The lecture defines a variable as 'something that can store information and can be referenced and manipulated,' comparing it to a cardboard box that holds items.
- A
- 20
Which of the following is NOT a primitive variable type covered in the lecture?
- A
Integer
- B
Array
- C
Boolean
- D
Char
Correct answer
BArray
Explanation
The lecture lists integers, booleans, floats, doubles, strings, and chars as primitive variables. Array is a data structure, not a primitive variable type.
- A
- 21
What range of values can an integer (int) variable hold in standard Java?
- A
0 to 2,147,483,647
- B
-32,768 to 32,767
- C
-2,147,483,648 to 2,147,483,647
- D
All real numbers including decimals
Correct answer
C-2,147,483,648 to 2,147,483,647
Explanation
The lecture explicitly states that an integer can store whole numbers from -2,147,483,648 to 2,147,483,648.
- A
- 22
What values can a boolean variable hold?
- A
Any number
- B
True or false only
- C
Any text string
- D
0 or 1
Correct answer
BTrue or false only
Explanation
The lecture says boolean variables can only hold the value of either true or false, and are useful for conditional statements.
- A
- 23
What is the main difference between a float and a double?
- A
A double cannot store negative numbers
- B
A float can only store whole numbers, while a double can store decimals
- C
A float is faster than a double
- D
A float can store numbers up to 32-bit precision, while a double can store up to 64-bit precision
Correct answer
DA float can store numbers up to 32-bit precision, while a double can store up to 64-bit precision
Explanation
The lecture explains that float stores numbers with up to 32-bit precision and double up to 64-bit precision, meaning double can store more decimal places.
- A
- 24
What does a char variable hold?
- A
A decimal number
- B
A string of characters
- C
A true/false value
- D
A single character
Correct answer
DA single character
Explanation
A char stands for character and can hold one character. The lecture notes that strings can also hold one character, but chars cannot hold more than one.
- A
- 25
What happens if you try to reference a variable that has not been assigned a value?
- A
The program automatically assigns a default value
- B
The variable gets assigned a random value
- C
A NullPointerException error occurs
- D
The program returns zero
Correct answer
CA NullPointerException error occurs
Explanation
The lecture warns that if you try to reference a variable without any information, you'll get a NullPointerException, which should be avoided.
- A
- 26
In the analogy, what does it mean when a variable 'points' to the same memory location as another variable?
- A
Both variables have their own separate copies of the data
- B
It is not possible in programming
- C
One variable is deleted when the other is written to
- D
Both variables reference the same data in memory
Correct answer
DBoth variables reference the same data in memory
Explanation
The lecture explains that if you set a new variable equal to an existing variable, it simply points to the same memory location, like adding another label to the same box.
- A
- 27
What is camelCase naming convention for variables?
- A
Not capitalizing the first word, but capitalizing every word after that
- B
Using underscores between words
- C
Capitalizing the first letter of the first word only
- D
Capitalizing the first letter of every word including the first
Correct answer
ANot capitalizing the first word, but capitalizing every word after that
Explanation
The lecture defines camelCase as not capitalizing the first word, but capitalizing every word that follows it, e.g., playerScore.
- A
- 28
What does an if statement do in programming?
- A
It executes a block of code only if a specified condition is true
- B
It defines a new variable
- C
It prints output to the console
- D
It repeats a block of code multiple times
Correct answer
AIt executes a block of code only if a specified condition is true
Explanation
The lecture states that an if statement checks if a condition (in parentheses) is true; if so, it runs the code inside its curly braces.
- A
- 29
In an if-else if-else chain, when is the else if condition evaluated?
- A
Before the if condition
- B
Only if the preceding if condition is false
- C
Only after the else clause
- D
Always, regardless of the if condition
Correct answer
BOnly if the preceding if condition is false
Explanation
The lecture explains that an else if statement is evaluated only if the preceding if (or else if) condition is false.
- A
- 30
Why is it good practice to include an else clause at the end of an if-else if chain?
- A
To catch any cases not handled by the preceding conditions
- B
To make the code run faster
- C
To repeat the check for the first condition
- D
It is required by the compiler
Correct answer
ATo catch any cases not handled by the preceding conditions
Explanation
The lecture suggests always having an else statement to catch any weird cases that don't fit the specified parameters.
- A
- 31
What is a switch statement used for?
- A
To handle multiple conditional branches more cleanly than many if-else statements
- B
To declare new variables
- C
To repeat code multiple times
- D
To print output to the console
Correct answer
ATo handle multiple conditional branches more cleanly than many if-else statements
Explanation
The lecture describes a switch statement as functionally similar to many if and else if statements but with less clutter, using cases and a default case.
- A
- 32
In a switch statement, what does the
breakstatement do?- A
It exits the entire program
- B
It breaks the loop containing the switch
- C
It is optional and has no effect
- D
It stops the current case and prevents fall-through to the next case
Correct answer
DIt stops the current case and prevents fall-through to the next case
Explanation
The lecture mentions that a break statement is used to end a case; without it, execution would continue into the next case (fall-through).
- A
- 33
What is the purpose of a for loop?
- A
To store multiple values in a variable
- B
To iterate through all elements in an array
- C
To repeatedly execute a block of code a specified number of times
- D
To execute a block of code only if a condition is true
Correct answer
CTo repeatedly execute a block of code a specified number of times
Explanation
The lecture explains that a for loop is used to run certain instructions numerous times, with three parts: an integer initializer, a condition, and an operation.
- A
- 34
In a for loop, what condition causes the loop to terminate?
- A
When the loop has executed once
- B
When the integer value no longer meets the condition
- C
When a break statement is encountered
- D
When the integer value meets the condition
Correct answer
BWhen the integer value no longer meets the condition
Explanation
The loop continues as long as the condition is true; when the integer is modified to the point where the condition becomes false, the loop terminates.
- A
- 35
What is an infinite loop?
- A
A loop that runs exactly 100 times
- B
A loop that terminates after a fixed number of iterations
- C
A loop that never terminates because its condition is always true
- D
A loop that contains a syntax error
Correct answer
CA loop that never terminates because its condition is always true
Explanation
The lecture defines an infinite loop as occurring when the condition will always be true given the parameters, causing the program to crash (e.g., starting at 10 and checking if i < 0 while incrementing).
- A
- 36
What is a for-each loop primarily used for?
- A
Iterating through each element in an array or list
- B
Creating an infinite loop
- C
Repeating a block of code a set number of times
- D
Incrementing a variable until a condition is met
Correct answer
AIterating through each element in an array or list
Explanation
The lecture states that a for-each loop (or for-in-list) is used for iterating through arrays or lists, performing a set of instructions for each value.
- A
- 37
How does a while loop differ from a for loop?
- A
A while loop is used only for arrays
- B
A while loop continues as long as its condition is true, but the condition is not part of the loop syntax in the same compact way
- C
A while loop cannot become infinite
- D
A while loop always runs at least once
Correct answer
BA while loop continues as long as its condition is true, but the condition is not part of the loop syntax in the same compact way
Explanation
The lecture notes that while loops are different in that the loop is not contained within one statement; it stretches out and continues as long as the condition is true.
- A
- 38
What is unique about a do-while loop?
- A
It never executes the body more than once
- B
It checks the condition before executing the body
- C
It can only be used with integers
- D
It executes the body at least once before checking the condition
Correct answer
DIt executes the body at least once before checking the condition
Explanation
The lecture explains that do-while loops carry out their instructions at least once, even if the condition is false, then function like a basic while loop.
- A
- 39
What are the three types of errors discussed in the lecture?
- A
Compilation, execution, and termination errors
- B
Memory, loop, and variable errors
- C
Input, output, and processing errors
- D
Syntax, runtime, and logic errors
Correct answer
DSyntax, runtime, and logic errors
Explanation
The lecture explicitly categorizes errors into three types: syntax errors, runtime errors, and logic errors.
- A
- 40
Which type of error is usually the easiest to fix?
- A
All errors are equally easy to fix
- B
Syntax error
- C
Logic error
- D
Runtime error
Correct answer
BSyntax error
Explanation
The lecture states that syntax errors are usually the easiest to solve since they are often small mistakes like a missing semicolon, and IDEs highlight them.
- A
- 41
What causes a runtime error?
- A
Breaking syntax rules
- B
Misspelling a variable name
- C
Using the wrong operator in a calculation
- D
A statement that seems logically sound but cannot be computed in a reasonable time, e.g., an infinite loop
Correct answer
DA statement that seems logically sound but cannot be computed in a reasonable time, e.g., an infinite loop
Explanation
The lecture defines runtime errors as those that appear when running the code, often due to infinite loops or conditions that cannot be met to terminate.
- A
- 42
What is a logic error?
- A
An error that crashes the program immediately
- B
An error where the code runs but produces incorrect results
- C
An error due to incorrect syntax
- D
An error that stops the program from running
Correct answer
BAn error where the code runs but produces incorrect results
Explanation
The lecture describes logic errors as those where the code runs without syntax or runtime errors but the result is not what was intended (e.g., multiplying instead of adding).
- A
- 43
What is one recommended strategy for debugging logic errors?
- A
Use print statements to output variable values at key points
- B
Change the programming language
- C
Rewrite the entire program
- D
Ignore the error and hope it goes away
Correct answer
AUse print statements to output variable values at key points
Explanation
The lecture suggests using print statements to check the value of variables before conditionals to understand what the computer is doing.
- A
- 44
What is a breakpoint?
- A
A marker that pauses program execution when the line is reached
- B
A point where the program stops running permanently
- C
A feature that automatically fixes errors
- D
A command that ends the program
Correct answer
AA marker that pauses program execution when the line is reached
Explanation
The lecture defines a breakpoint as a marker that pauses the program when the line is reached, allowing the programmer to check state and continue step by step.
- A
- 45
How can commenting out code help with debugging?
- A
It increases the program's speed
- B
It adds notes to the console
- C
It deletes the code permanently
- D
It temporarily removes code from execution without deleting it, helping isolate the error
Correct answer
DIt temporarily removes code from execution without deleting it, helping isolate the error
Explanation
The lecture explains that commenting code essentially 'deletes' it in the computer's eyes without actually deleting it, allowing you to test if that section is causing the problem.
- A
- 46
What is a function in programming?
- A
A type of loop
- B
A conditional structure
- C
A variable that stores multiple values
- D
A segment of code that can be called by name to perform a specific task
Correct answer
DA segment of code that can be called by name to perform a specific task
Explanation
The lecture defines a function as a segment of code that can be easily run by 'calling' the function name, and it may do something in return.
- A
- 47
What are arguments in a function?
- A
The code inside the function
- B
The name of the function
- C
The values returned by a function
- D
Variables passed into a function to be manipulated or used
Correct answer
DVariables passed into a function to be manipulated or used
Explanation
The lecture defines arguments as variables that we pass into the function to be manipulated, analogized to ordering food at a restaurant.
- A
- 48
What does it mean for a function to 'return' a value?
- A
The function gives back a value that can be used in the calling code
- B
The function repeats itself
- C
The function prints the value to the console
- D
The function ends without any output
Correct answer
AThe function gives back a value that can be used in the calling code
Explanation
The lecture explains that functions can return values back to the user, which can be assigned to a variable or printed. For example, the max function returns an integer.
- A
- 49
What is a void function?
- A
A function that is empty
- B
A function that returns an integer
- C
A function that does not return any value
- D
A function that takes no arguments
Correct answer
CA function that does not return any value
Explanation
The lecture defines void functions as those that do not return anything, like the printStats function, which simply runs code but does not give back a value.
- A
- 50
What is the purpose of an import statement?
- A
To gain access to libraries of functions written by others
- B
To define a new function
- C
To create a new variable
- D
To print output to the console
Correct answer
ATo gain access to libraries of functions written by others
Explanation
The lecture explains that importing functions allows you to use libraries of functions that other people have made, analogous to buying materials from a store instead of making them yourself.
- A
- 51
In Java, what is the correct way to create a function named
addNumbersthat takes two integers and returns an integer?- A
public void addNumbers(int a, int b) { return a + b; }
- B
public int addNumbers() { return a + b; }
- C
public int addNumbers(int a, int b) { return a + b; }
- D
int addNumbers(a, b) { return a + b; }
Correct answer
Cpublic int addNumbers(int a, int b) { return a + b; }
Explanation
Based on the lecture's explanation: public (scope), int (return type), function name, parentheses with parameters, and a return statement. Void would not return a value, and parameters must be declared with types.
- A
- 52
When creating a function that returns a value, why must you ensure all code paths return a value?
- A
To ensure the function always provides a return value no matter what path is taken
- B
To make the function void
- C
To avoid a syntax error
- D
To prevent the function from running infinitely
Correct answer
ATo ensure the function always provides a return value no matter what path is taken
Explanation
The lecture emphasizes that no matter what path the code takes, it must return a variable, otherwise the function will throw an error. For example, in an if-else, you must have returns for both branches.
- A
- 53
What is recursion in programming?
- A
A loop that repeats indefinitely
- B
A function that calls itself
- C
A way to store multiple values
- D
A method of sorting data
Correct answer
BA function that calls itself
Explanation
The lecture defines recursion as functions that repeatedly call themselves, with one of the instructions being a call to the same function.
- A
- 54
What is a base case in recursion?
- A
A condition that stops the recursion by returning a definite value
- B
The first call to the recursive function
- C
The data structure used in recursion
- D
The number of times the function should repeat
Correct answer
AA condition that stops the recursion by returning a definite value
Explanation
The lecture explains that a base case is a definite value or condition that all recursive calls try to reach; when satisfied, the recursion stops and returns a value.
- A
- 55
What happens if a recursive function does not have a base case?
- A
The function stops automatically after a few iterations
- B
The function runs indefinitely and may cause a stack overflow
- C
The function only runs once
- D
The function returns a default value
Correct answer
BThe function runs indefinitely and may cause a stack overflow
Explanation
The lecture warns that without a base case, the recursive function will call itself infinitely, leading to a stack overflow error and program crash.
- A
- 56
What data structure does recursion rely on to manage function calls?
- A
Array
- B
Queue
- C
Dictionary
- D
Stack
Correct answer
DStack
Explanation
The lecture explains that recursion uses a stack data structure, which follows LIFO (Last In, First Out). Each recursive call is stacked on top of the previous one.
- A
- 57
What is an array?
- A
A loop structure
- B
A key-value pair data structure
- C
A list of values that can be of different types
- D
A variable that can hold multiple values of the same type
Correct answer
DA variable that can hold multiple values of the same type
Explanation
The lecture defines an array as a list, but specifies that you must determine the type of array (e.g., array of strings) and cannot mix types. It holds multiple values of the same type.
- A
- 58
In arrays, what index does the first element have?
- A
0
- B
-1
- C
Depends on the language
- D
1
Correct answer
A0
Explanation
The lecture emphasizes that in computer science, arrays start at index 0. The first element is at index 0, the second at index 1, etc.
- A
- 59
What happens if you try to access an index that is out of bounds in an array?
- A
The array automatically resizes
- B
The program prints a warning
- C
The program continues but returns null
- D
An 'out of bounds' error occurs
Correct answer
DAn 'out of bounds' error occurs
Explanation
The lecture states that referencing an index beyond the array size results in an 'out of bounds' error.
- A
- 60
Can the size of an array be changed after it is initialized?
- A
Yes, you can add elements as needed
- B
No, the size of an array is fixed once defined
- C
No, but you can use a special function to increase it
- D
Yes, but only by reinitializing the array
Correct answer
BNo, the size of an array is fixed once defined
Explanation
The lecture explicitly states that once an array has been defined, there is no way to change its size; array sizes are final.
- A
- 61
What is a two-dimensional (2D) array?
- A
An array of arrays, forming a grid-like structure
- B
An array with two elements
- C
An array that can hold two different types
- D
An array that can be accessed in two dimensions
Correct answer
AAn array of arrays, forming a grid-like structure
Explanation
The lecture describes 2D arrays as arrays containing arrays, like a matrix with rows and columns. Indexing uses two numbers (row, column).
- A
- 62
How does an ArrayList differ from a regular array?
- A
An ArrayList is faster than an array
- B
An ArrayList automatically grows when elements are added beyond its initial capacity
- C
An ArrayList cannot hold numbers
- D
An ArrayList uses 1-based indexing
Correct answer
BAn ArrayList automatically grows when elements are added beyond its initial capacity
Explanation
The lecture contrasts ArrayLists as 'growing arrays' that start with a size of 10 and automatically allocate more memory when needed, unlike arrays whose size is fixed.
- A
- 63
In a dictionary (or map), how are values stored?
- A
Values are stored in a linear order and accessed by index
- B
Values are stored in a sorted order automatically
- C
Values are stored as key-value pairs, accessed by a unique key
- D
Values are stored in multiple arrays
Correct answer
CValues are stored as key-value pairs, accessed by a unique key
Explanation
The lecture explains that dictionaries store key/value pairs, and you use the key to retrieve the value. Keys must be unique.
- A
- 64
What is the main advantage of a dictionary over an array for storing related data?
- A
Dictionaries allow logical key-based lookups rather than numeric indices
- B
Dictionaries automatically sort data
- C
Dictionaries can hold more data
- D
Dictionaries are faster for sequential access
Correct answer
ADictionaries allow logical key-based lookups rather than numeric indices
Explanation
The lecture mentions that dictionaries are more fluid and easier to organize because you can use meaningful keys (e.g., product name) instead of positions.
- A
- 65
What is the goal of a searching algorithm?
- A
To remove duplicates from a list
- B
To find a particular data point in a list as quickly as possible
- C
To count the number of elements in a list
- D
To sort a list of values
Correct answer
BTo find a particular data point in a list as quickly as possible
Explanation
The lecture states that searching algorithms aim to give the algorithm a string or object to find and return its index as fast as possible.
- A
- 66
What is a key difference between linear search and binary search?
- A
Binary search checks every element, linear search halves the list
- B
Binary search works only on sorted lists, linear search works on any list
- C
Linear search works only on sorted lists, binary search works on any list
- D
Linear search is always faster than binary search
Correct answer
BBinary search works only on sorted lists, linear search works on any list
Explanation
The lecture explains that linear search works for both sorted and unsorted lists, while binary search requires a sorted list but is more efficient.
- A
- 67
In the worst case, how many elements does a linear search need to check?
- A
Logarithmic number of elements
- B
The first element only
- C
All n elements
- D
Half the elements on average
Correct answer
CAll n elements
Explanation
The lecture states that in the worst case (item is last), linear search checks the entire list of n elements, giving O(n) complexity.
- A
- 68
What is the time complexity of binary search in the worst case?
- A
O(1)
- B
O(n^2)
- C
O(n)
- D
O(log n)
Correct answer
DO(log n)
Explanation
The lecture mentions that binary search has O(log n) efficiency in the worst case, which is much more efficient than linear search's O(n).
- A
- 69
What is pseudocode?
- A
A non-real code used to plan out a program without worrying about syntax
- B
A debugging tool
- C
A type of low-level programming language
- D
Code written in a specific programming language
Correct answer
AA non-real code used to plan out a program without worrying about syntax
Explanation
The lecture defines pseudocode as pseudo (not real) and code, a means to plan programs before writing them, ignoring syntax and focusing on goals.
- A
- 70
Which pseudocode strategy involves a graphical representation of a function's flow?
- A
Flowchart
- B
Feature planning
- C
CamelCase
- D
Write-up method
Correct answer
AFlowchart
Explanation
The lecture describes flowcharts as graphical representations of a function's flow, using blocks and arrows to map out paths.
- A
- 71
What is the 'write-up' method of pseudocode?
- A
Drawing a diagram of the program
- B
Listing all functions needed
- C
Writing out step-by-step what the program should do in plain English
- D
Writing the actual code in a simplified language
Correct answer
CWriting out step-by-step what the program should do in plain English
Explanation
The lecture describes the write-up method as jotting down from start to finish what the program is going to do, without worrying about programming statements.
- A
- 72
What does a feature planning pseudocode involve?
- A
Drawing a flowchart
- B
Writing detailed code for each feature
- C
Creating a timeline for development
- D
Listing the main features of the program and the functions needed to implement them
Correct answer
DListing the main features of the program and the functions needed to implement them
Explanation
The lecture explains that feature planning means writing out the main features you want the user to have and what functions are needed to complete them.
- A
- 73
Which of the following is a high-level programming language?
- A
Assembly
- B
Python
- C
Binary
- D
Machine code
Correct answer
BPython
Explanation
The lecture contrasts high-level languages (like Python, Java) with low-level languages (like assembly). High-level languages have higher abstraction from machine code.
- A
- 74
What is a scripting language?
- A
A language that requires compilation before execution
- B
A low-level programming language
- C
A language used only for web design
- D
A language that has many commands and can be run without being compiled
Correct answer
DA language that has many commands and can be run without being compiled
Explanation
The lecture defines scripting languages as having many commands and being run without needing to be compiled, making them faster to write and easier to port.
- A
- 75
Which language is recommended for designing the content and style of a website?
- A
HTML and CSS
- B
Python
- C
Java
- D
C++
Correct answer
AHTML and CSS
Explanation
The lecture mentions HTML for content and CSS for style when designing websites.
- A
- 76
According to the lecture, what is the best next step after learning programming basics?
- A
Choose a specific programming language and learn its syntax through tutorials
- B
Avoid writing code and only study theory
- C
Purchase expensive online courses
- D
Immediately start a large project
Correct answer
AChoose a specific programming language and learn its syntax through tutorials
Explanation
The lecture suggests researching a language, then learning it through tutorial series (like on YouTube) to pick up on syntax and rules.
- A
- 77
Which website does the lecture recommend for practicing coding challenges in Java and Python?
- A
GitHub
- B
CodingBat
- C
HackerRank
- D
CoderByte
Correct answer
BCodingBat
Explanation
The lecture specifically mentions CodingBat as a free website with hundreds of coding challenges in Java and Python.
- A
- 78
What is the LIFO structure mentioned in the context of recursion?
- A
First In, First Out
- B
Linear Input, Fixed Output
- C
Last In, First On
- D
Last In, First Out
Correct answer
DLast In, First Out
Explanation
The lecture explains that programs follow a LIFO structure (stack), where the last item added to the stack is the first one removed.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.