Sample Computer Science Questions
Q1: What is the time complexity of binary search on a sorted array of n elements?
A. O(n)
B. O(n²)
C. O(log n) ā
D. O(1)
Q2: Which data structure uses LIFO (Last In, First Out) ordering?
A. Queue
B. Stack ā
C. Linked List
D. Heap
Q3: In object-oriented programming, what is inheritance?
A. A function calling itself
B. A child class acquiring properties from a parent class ā
C. Hiding internal data from outside code
D. Converting one data type to another
š Study Tips for Computer Science
1
Learn Big O notation thoroughly ā knowing the time and space complexity of algorithms is essential for technical interviews and optimization.
2
Practice implementing core data structures (linked list, stack, queue, hash map, binary tree) from scratch at least once.
3
For algorithm problems, always think about edge cases first: empty input, single element, maximum size, and negative numbers.
4
Understand recursion deeply ā practice writing the base case and recursive case for tree traversals, factorial, Fibonacci, and pathfinding.
ā Computer Science FAQ
What is the difference between a stack and a queue?
ā¾
A stack is LIFO (Last In, First Out) ā the last element added is the first removed, like a stack of plates. A queue is FIFO (First In, First Out) ā the first element added is the first removed, like a line at a store. Both are abstract data types with many implementations.
What is the difference between an array and a linked list?
ā¾
Arrays store elements in contiguous memory, allowing O(1) random access by index but O(n) insertions/deletions in the middle. Linked lists store elements in nodes with pointers to the next node, allowing O(1) insertions/deletions at known positions but O(n) access by index.
What is recursion?
ā¾
Recursion is a technique where a function calls itself to solve a smaller version of the same problem. Every recursive solution needs a base case (termination condition) and a recursive case (calls itself with a simpler input). Recursion is natural for tree traversal, divide-and-conquer algorithms, and backtracking.
Browse All Quiz Topics