In collaboration with Nadine Ferguson, the following questions were compiled to initiate a book on learning programming and problem-solving via computers, by asking questions:
By asking questions, real-world examples, and multiple solutions to the same problem.
Questions
What is the problem?
What is a solution?
What is an efficient solution?
What is a computer?
How can a solution be communicated to computers?
What is an algorithm and how does it help in programming computers?
What is abstraction? Could you explain with examples?
What are the Turing primitives?
What is a flowchart?
What are ANSI Standard symbols for drawing a flowchart?
Draw parallels between the flowchart symbols and Turing primitives.
What is a program, and how can we translate a flowchart or algorithm into a computer program?
What is a computer language? Why do we need a language or multiple languages?
What is Python, what paradigms is it developed in, and what does it support?
What is the Object-Oriented Programming paradigm? Compare the same with alternative paradigms.
What are some examples of Python objects?
What is an error? How many types of errors do you think can occur?
Can you relate computer program errors to people's mistakes in learning natural languages such as English?
Which error poses the least difficulty and removal?
Which error poses the most difficulty and removal?
How can you tell if a program is correct, i.e., will correctly solve the problem it is intended to?
How do we ensure a mathematical predicate/statement/solution is correct?
What is proof? How can we prove that a program will always work?
What are testing (automated testing using doctest) and debugging?
What are the major types of testing-- Unit and integration testing?
What are the basic building blocks of a computer?
How many ways can a program receive input?
How many ways a program can output?
What is memory?
What number system(s) do computers understand?
What is the binary number system?
What happens when you press a key on the keyboard?
What is an ASCII table? What it is used for?
Write down ASCII values for letters a-z, A-Z, and digits 0-9
What are variables/names? What are values?
How many types of values a variable can hold?
What are the common built-in data types in Python?
What is static and dynamic typing? Which one would be slower?
What is Scope in Python?
What is Scope Resolution in Python?
What types of operators are allowed in Python? Explain operators for each data type.
Can you explain the ternary operator in Python?
What is an assignment?
Mutability (in-place change) and Rebinding (associated with another value)
What is a function (mathematical definition)?
What is a function in computer programming?
What are the arguments and parameters?
Explain arguments, default arguments, and keyword arguments.
What is a return value and what gets returned without a return statement?
What are the built-in functions in Python (e.g., print, range)
Draw an equivalence between Turing primitives, flowchart boxes, and programming constructs.
What are the minimum things we need to communicate to the computer? What are the advantages?
What is the control flow?
What are conditionals?
Can we chain conditionals?
Can we nest conditionals?
What are loops?
Nested loops? Why do we need it?
How to break a loop?
How do you replace a break statement in a loop with a Boolean flag?
What is break, continue, and pass in Python?
What is an infinite loop? Could you explain a scenario in which it is inevitable?
What are collections? What types are available in Python to hold a collection of values?
What are lists?
What are negative indexes, and why are they used? Explain at least 4 situations in which negative indices are handy.
What types of operations can be performed on a collection, such as lists?
Traversing a list, modifying a list, creating a list from another list
How do you copy an object in Python? How to copy a list into another list?
What are deep copy and shallow copy in Python? Provide an example for data types where deep and shallow copy applies.
What is the difference between Python Arrays and lists?
Multi-dimensional lists. Matrix operations (addition, subtraction, multiplication, transpose)
How do you traverse a 2D matrix?
How do you transpose a 2D matrix?
How do you find the sum of the principal diagonal elements in a 2D matrix?
What are strings? How is it different from the list?
What operations can be performed on strings?
How will you search for a string in a big string?
Implement the Caesar Cipher encryption algorithm using string methods
What are the string-matching algorithms?
Can you print the sum of the squares of digits of a number?
What are mutation and rebinding, and how does it apply to lists and strings?
What are tuples? What are the usages of tuples in programming situations?
What are dictionaries? What are they useful for?
How to work with a collection of elements?
Loops and collections (list, tuple, dictionaries)
Collection of collections? (list of lists, tuples, dictionaries; tuple of lists, tuples, dictionaries, etc.)
Provide some examples that use both lists and dictionaries.
Provide some examples that use lists and tuples
Provide some examples that use tuples and dictionaries
What are Dict and List comprehensions?
What data structure/type can be used in Python to store unique data and eliminate duplicate items?
How do you find the intersection of two sets?
How do you find the union of two sets?
How do you find the difference between the two sets?
How do you find the symmetric difference between the two sets?
How do you find subsets and supersets?
What is the lambda function in Python? Why is it used?
What is a flag variable, and what scenarios do we need it?
What are modules and packages in Python?
Differentiate between a package and a module in Python.
What are some of the most commonly used built-in modules in Python?
How do you generate random numbers in Python?
Write a Python program to simulate virtual dice.
How do you create 100 random integers in a specified range in Python?
How to generate a floating-point number in a range specified by the user?
How do you select a random element from a list?
What is persistence?
How to read from a file?
How do you write to a file stored on a hard disk?
How do you append data to an existing text file?
What is a read position/file pointer, and how can you reset it for multiple file reads?
How to read a file one line at a time?
How do you read a text file into a list?
Can a file object be iterated over to process a text file line by line?
How to read and write numeric data from/write to a file?
How to process data written to a file as records and fields?
What is exception handling? And how do you catch exceptions in Python?
How can you use exception handling in file I/O to check for file existence?
What is the difference between run-time errors and semantic errors?
What are files? What is a directory? How to get the current working directory in Python?
How do I get a list of all the files in a directory?
What are the resources a program consumes?
How do we measure the amount of space a program takes? What is unit do we use?
How do we measure the amount of time a program takes? What is the unit that we use?
What are the factors that impact a program's running time? Is it possible to keep track of all these factors? Do you think these factors are stable, and can we rely on their time?
Does the number or amount of resources a program takes depend on the programming language that we use?
Is there a way to measure the resources a program consumes independent of programming language?
What are algorithms?
Does an algorithm always take the same steps to solve a problem?
Does input affect the time taken by an algorithm?
What is the best case, worst case, and average case in the complexity analysis of an algorithm?
What are the notations used to indicate the best, worst, and average-case complexities?
Why do we always do the worst-case complexity analysis of algorithms?
What do you understand about algorithmic complexity?
What is the order of growth?
What is the major family of functions that we use to indicate the order of growth of an algorithm?
Can you put those functions listed in Q. 110 in order of their growth?
How do we measure algorithmic complexity?
How do we measure the complexity of algorithms that exclusively use loops? Could you explain with examples?
Is there an alternative for loops?
Could you explain the divide and conquer strategy to solve a problem?
What is recursion?
How do you define the base case?
What are the characteristics of the general case for recursion?
How do you avoid infinite recursion?
How is recursion different from iteration?
Define a recursive function to calculate the factorial of a number.
Define a function that recursively counts down from a user-inputted integer.
Describe the flow of execution of a recursive function.
What is one-way vs. two-way recursion?
Could you draw the call stack diagram for a two-way recursive function?
What does it mean when a Python program generates a “maximum recursion depth exceeded” error?
Define a linear search function in Python.
Write the algorithm for binary search and implement it in Python.
Write the algorithm for bubble sort and implement it in Python
How do you implement a quicksort algorithm in Python?
How to implement a linear search using recursion?
What is the best, worst, and the average case for linear search?
How to implement a binary search in recursion?
What is the best, worst, and the average case for binary search?
How to check if a string is a palindrome?
How to compute factorial using a loop?
How to compute factorial using recursion?
How to find the sum of a given list of numbers using a loop?
How would you compute the sum of a list of numbers using recursion?
How to compute nth Fibonacci using a loop?
How to compute nth Fibonacci using recursion?
How to measure the complexity of algorithms that exclusively use recursion (or divide and conquer strategy) to solve a problem?
What is a recurrence relation?
What is the master’s theorem?
What kind of algorithms can be analyzed using the master’s theorem?
What is the runtime complexity of searching an element in an unsorted list of elements?
What is the runtime complexity of searching an element in a sorted list of elements?
What is the cost of maintaining a sorted list?
Is maintaining a sorted list and searching in O(log n) possible? How?
What are ADTs?
Describe a stack ADT and how objects are accessible in a stack
Implement a stack/LIFO using list push and pop operations. How would you determine the number of objects in a stack? Add an element to the top of the stack. Remove the top item on the stack.
Describe the performance characteristics of a well-designed stack in terms of algorithm complexity (big O notation). What is the cost of a pop and push stack operation?
What other Python data structure can be used to implement a stack?
How would you implement a queue/FIFO structure in Python?
What ADT is used if the object needs to be inserted in the middle of the sequence (instead of the start or end)?
What is a linked list?
Write a program to traverse a linked list and delete the first and last nodes.
What is the difference between a singly linked list and a double linked list? Could you give an example? When would you use each?
What is a non-linear data structure? What are the heavily studied non-linear data structures?
What is a tree?
What is a rooted tree?
What is an ordered tree?
What is a search tree?
What is a binary search tree (BST)?
What are the ways to represent a binary search tree in a computer?
What are the problems with an array-based representation of a BST?
Why is a linked-list-based structure an efficient way of representing a BST?
How to insert an element in a BST?
What is the complexity of the insertion process in the best and worst cases?
How to search for an element in a BST?
What is the complexity of the search process in the best and worst cases?
How to delete an element from a BST?
What is the complexity of the deletion process in the best and worst cases?
What is a balanced BST?
What would be the complexity of keeping a BST balanced?
What is hashing?
What is a collision in hashing?
What is chaining?
What is the complexity of searching an element in a hash table?
How would you search for the occurrence of a string in a text?
What would be the computational complexity of finding a fixed string in a text?
Is there a way to improve the computational complexity of the string-matching process?