T4Tutorials .PK

VU Past Papers CS301 – Midterm Most important MCQs and question with answers

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

  1. Insert (Add) – Add a new node into the list.
  2. Delete (Remove) – Remove a node from the list.
  3. Retrieve (Get) – Access an element from the list.
  4. Search (Find) – Check whether a specific element exists in the list.
  5. Count Elements – Find the number of elements in the list.
  6. Check Empty – Determine whether the list is empty.

2. Limitations of Arrays

Arrays have some disadvantages:

  1. Fixed size – Once created, array size cannot be changed.
  2. 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.

  1. Dynamic size – Size can grow or shrink during runtime.
  2. Easy insertion and deletion – Only pointers need to be updated.
  3. 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:

5. What is a Constructor?

A constructor is a special function of a class that is automatically called when an object is created.

Properties

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:

Example idea:

Program execution command:

program.exe abc def

7. Josephus Problem

Josephus problem is a theoretical counting problem.

Idea

Data Structure Used

Circular Linked List is commonly used to solve this problem.

8. Difference Between Singly and Doubly Linked List

Singly Linked List

Doubly Linked List

9. What is a Node?

A node is the basic element of a linked list.

Each node has two parts:

  1. Data – stores the actual value
  2. Pointer (Next) – stores address of next node

The last node points to NULL.

10. Difference Between Head Node and Current Node

Head Node

11. What is Abstract Data Type (ADT)?

An ADT is a data type where:

Example ADTs:

12. Stack Definition

A stack is a linear data structure that follows:

LIFO (Last In First Out)

Example:

Stack of books.

Main Operations

13. Difference Between Stack and Linked List

Stack

Linked List

14. Types of Linked Lists

  1. Singly Linked List
  2. Doubly Linked List
  3. Circular Linked List
  4. Circular Doubly Linked List

15. Circular Linked List

In a circular linked list:

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:


17. Traversing

Traversing means:

Visiting every element of a data structure at least once.

Used for:

18. Infix, Prefix, and Postfix Expressions

Infix

Operator is between operands

Example
A + B

Prefix

Operator is before operands

Example

Operator is after operands

Example
A B +

19. Operator Precedence

Operator precedence defines the order in which operations are performed.

Order:

  1. Parentheses ()
  2. Multiplication / Division
  3. 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

21. Stack vs Heap Memory

Stack Memory

Heap Memory

22. Fatal Error

A fatal error is an error that stops program execution immediately.

Examples:

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.

Exit mobile version