Computer Programming Flashcards
6 cards from real AMCAT practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Computer Programming flashcards as text
Which sorting algorithm has the best average-case time complexity?
Answer: Merge Sort
Merge Sort has an average and worst-case time complexity of O(n log n), better than O(n²) sorts.
What is a pointer in C?
Answer: A variable that stores the memory address of another variable
A pointer in C is a variable that holds the memory address of another variable.
Which of the following is an example of a recursive function?
Answer: A function that calls itself
A recursive function is one that calls itself during its execution to solve a sub-problem.
In Python, what does the 'len()' function return when applied to a list?
Answer: The number of elements
The 'len()' function returns the number of items (length) in a list or other iterable.
What is the primary purpose of a constructor in OOP?
Answer: To initialize an object's attributes when it is created
A constructor is a special method called automatically when an object is instantiated, used to set initial values.
Which operator is used to allocate dynamic memory in C++?
Answer: new
The 'new' operator in C++ allocates memory on the heap at runtime.