Q#1: What does a constraint mean in computer systems?
(A) A programming language
(B) A limitation on system resources
(C) A type of algorithm
(D) A storage device
Answer: (B) A limitation on system resources
Q#2: In an assignment statement, what does an lvalue represent?
(A) A constant value
(B) A memory location where a value can be stored
(C) A function call
(D) A pointer only
Answer: (B) A memory location where a value can be stored
Q#3: In a list or array, what does the “current” pointer indicate?
(A) The total number of elements
(B) The first element of the array
(C) The currently focused element position
(D) The memory address of array
Answer: (C) The currently focused element position
Q#4: What is an algorithm?
(A) A programming language
(B) A finite sequence of steps to solve a problem
(C) A data structure
(D) A type of memory
Answer: (B) A finite sequence of steps to solve a problem
Q#5: What is the main purpose of a data structure?
(A) To increase computer size
(B) To organize and store data efficiently
(C) To remove algorithms
(D) To replace programming languages
Answer: (B) To organize and store data efficiently
Q#6: Which data structure is most commonly used to store similar data items?
(A) Tree
(B) Graph
(C) Array
(D) Stack
Answer: (C) Array
Q#7: What is the time complexity of accessing an element in an array?
(A) O(n)
(B) O(log n)
(C) O(1)
(D) O(n²)
Answer: (C) O(1)
Q#8: How can data be organized in general?
(A) Static and Dynamic
(B) Linear and Non-linear
(C) Input and Output
(D) Internal and External
Answer: (B) Linear and Non-linear
Q#9: What does the term “chunk” mean in computer memory?
(A) A complete memory block
(B) A piece of reasonable size of memory
(C) A program file
(D) A variable name
Answer: (B) A piece of reasonable size of memory
Q#10: What are argc and argv in C/C++?
(A) Loop variables
(B) Command line arguments
(C) Memory addresses
(D) Data types
Answer: (B) Command line arguments
Q#11: What is the difference between a data structure and an algorithm?
(A) Data structure stores data while algorithm solves problems
(B) Both are same
(C) Algorithm stores data
(D) Data structure executes programs
Answer: (A) Data structure stores data while algorithm solves problems
Q#12: What is meant by efficiency of a solution?
(A) Using maximum memory
(B) Solving problem within resource constraints
(C) Writing long code
(D) Using only arrays
Answer: (B) Solving problem within resource constraints
Q#13: What does an array index represent?
(A) Value of element
(B) Memory location number of element
(C) Size of array
(D) Type of data
Answer: (B) Memory location number of element
Q#14: What is a list in computer science?
(A) A collection of items of the same type
(B) A programming language
(C) A memory unit
(D) A hardware device
Answer: (A) A collection of items of the same type
Q#15: What is a dynamic array?
(A) Array with fixed size
(B) Array that can be resized during runtime
(C) Array without elements
(D) Array stored in ROM
Answer: (B) Array that can be resized during runtime
Q#16: Where is a static array usually stored in memory?
(A) Heap
(B) Stack
(C) Register
(D) Cache
Answer: (B) Stack
Q#17: Where is dynamically allocated memory stored?
(A) Stack
(B) Heap
(C) ROM
(D) Cache
Answer: (B) Heap
Q#18: What is a linked list?
(A) A group of nodes connected by pointers
(B) A type of array
(C) A programming language
(D) A sorting technique
Answer: (A) A group of nodes connected by pointers
Q#19: What are the two main parts of a node in a linked list?
(A) Data and index
(B) Data and pointer to next node
(C) Value and array
(D) Address and index
Answer: (B) Data and pointer to next node
Q#20: What does the getNext() function return in a linked list?
(A) Data of node
(B) Pointer to next node
(C) Array index
(D) Size of list
Answer: (B) Pointer to next node
Q#21: What does the setNext() function do in a linked list?
(A) Deletes a node
(B) Assigns address of next node
(C) Prints node data
(D) Counts nodes
Answer: (B) Assigns address of next node
Q#22: What is the main purpose of a node in a linked list?
(A) To store only addresses
(B) To store data and link to the next node
(C) To calculate algorithms
(D) To sort elements
Answer: (B) To store data and link to the next node
What is the importance of link list in memory?
1. Operations of Linked List
A linked list provides several operations to manage nodes in the list.
Main Operations
- Insert (Add) – Add a new node into the list.
- Delete (Remove) – Remove a node from the list.
- Retrieve (Get) – Access an element from the list.
- Search (Find) – Check whether a specific element exists in the list.
- Count Elements – Find the number of elements in the list.
- Check Empty – Determine whether the list is empty.
2. Limitations of Arrays
Arrays have some disadvantages:
- Fixed size – Once created, array size cannot be changed.
- Insertion and deletion are expensive – Elements must be shifted when inserting or deleting in the middle.
3. Advantages of Linked Lists
Linked lists overcome array limitations.
- Dynamic size – Size can grow or shrink during runtime.
- Easy insertion and deletion – Only pointers need to be updated.
- Efficient memory usage – Memory is allocated when needed.
4. What is a Constant Pointer?
A constant pointer is a pointer whose address cannot be changed after initialization.
Example idea:
A pointer always points to the same memory location during program execution.
Meaning:
- The pointer address cannot change
- But the value stored at that address can change
5. What is a Constructor?
A constructor is a special function of a class that is automatically called when an object is created.
Properties
- Same name as the class
- No return type
- Used to initialize objects
Example purpose:
Initialize data members when an object is created.
6. What are Command Line Arguments?
Command line arguments are values passed to a program when it starts execution.
In C++ main function:
- argc → Number of arguments
- argv → List of arguments
Example idea:
Program execution command:
program.exe abc def
- argc = 3
- argv contains: program.exe, abc, def
7. Josephus Problem
Josephus problem is a theoretical counting problem.
Idea
- People stand in a circle.
- Every k-th person is eliminated.
- Process continues until one person remains.
Data Structure Used
Circular Linked List is commonly used to solve this problem.
8. Difference Between Singly and Doubly Linked List
Singly Linked List
- Each node has one pointer
- Pointer points to next node
- Traversal only forward
Doubly Linked List
- Each node has two pointers
- One pointer to previous node
- One pointer to next node
- Traversal forward and backward
9. What is a Node?
A node is the basic element of a linked list.
Each node has two parts:
- Data – stores the actual value
- Pointer (Next) – stores address of next node
The last node points to NULL.
10. Difference Between Head Node and Current Node
Head Node
- Points to the first node of the list.
- Pointer that refers to the node currently being processed.
11. What is Abstract Data Type (ADT)?
An ADT is a data type where:
- Only operations are defined
- Implementation details are hidden
Example ADTs:
- Stack
- Queue
- List
12. Stack Definition
A stack is a linear data structure that follows:
LIFO (Last In First Out)
Example:
Stack of books.
Main Operations
- Push → Insert element
- Pop → Remove element
- Top → Access top element
13. Difference Between Stack and Linked List
Stack
- Abstract data type
- Uses push and pop
- Follows LIFO
Linked List
- Data structure made of nodes
- Can be used to implement stack
14. Types of Linked Lists
- Singly Linked List
- Doubly Linked List
- Circular Linked List
- Circular Doubly Linked List
15. Circular Linked List
In a circular linked list:
- Last node does not point to NULL
- Instead it points back to the first node
This creates a loop structure.
16. Constant Time
Constant time means the operation takes the same amount of time regardless of input size.
Notation:
O(1)
Example:
- Accessing an element in an array.
17. Traversing
Traversing means:
Visiting every element of a data structure at least once.
Used for:
- Printing elements
- Searching elements
18. Infix, Prefix, and Postfix Expressions
Infix
Operator is between operands
Example
A + B
Prefix
Operator is before operands
Example
- A B
Operator is after operands
Example
A B +
19. Operator Precedence
Operator precedence defines the order in which operations are performed.
Order:
- Parentheses ()
- Multiplication / Division
- Addition / Subtraction
20. Queue
A queue is a linear data structure that follows:
FIFO (First In First Out)
Example:
People standing in a line.
Operations
- Enqueue → Insert element
- Dequeue → Remove element
21. Stack vs Heap Memory
Stack Memory
- Stores local variables
- Automatically managed
- Faster access
Heap Memory
- Stores objects and dynamic data
- Manually allocated
- Larger memory space
22. Fatal Error
A fatal error is an error that stops program execution immediately.
Examples:
- Dividing by zero
- Accessing illegal memory
- Invalid program code
23. Templates in C++
Templates allow generic programming.
They allow a function or class to work with multiple data types.
Example idea:
One function can work for int, float, double etc.