Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

VU Past Papers CS302 – Introduction to Data Structures and Arrays Questions & Answers (Lectures 1–22)

Lecture-Wise Questions & Answers (Lectures 1–22)


Lecture 1: Introduction to Data Structures and Arrays

Q1: What are constraints?
A: Constraints define limitations or restrictions on resources of a system (like memory, disk space, or time). Efficient solutions solve problems within resource constraints.

Q2: What is lvalue?
A: Lvalue is a memory location where a value can be stored. Appears on the left-hand side of assignment. Example: int var = 7; β†’ var is lvalue.

Q3: What is the β€œcurrent” pointer?
A: A variable showing the currently focused element in an array or list. Example: current = 5 means focus is on element 5.

Q4: What is an algorithm?
A: A finite sequence of steps to solve a problem.

Q5: Role of arrays in data structures:

  • Store similar data efficiently.
  • Enable constant-time read/write (O(1)), but lookup operations like find_min may take linear time (O(n)).
  • Can be multidimensional (matrix, tensor).

Q6: How many types can data be organized?

  1. Linear (arrays, lists)
  2. Non-linear/Hierarchical (trees)

Q7: Importance of data structures:

  • Queue in banks, undo in editors, online shopping lists, telephone networks, image bitmaps, printer spooler, browser history.

Q8: What is a chunk?
A: A piece of memory of reasonable size.

Q9: Basic purpose of data structure:

  • Organize and store data efficiently for operations like searching, deletion, insertion.

Q10: What are argc and argv?

  • Command-line arguments in main(int argc, char** argv).

Q11: Difference between data structure and algorithm:

  • Data Structure: Organization of data efficiently.
  • Algorithm: Steps to solve a problem.

Q12: What is efficiency?

  • Solving problem within resource constraints (time, space).

Q13: What is Array Name and x?

  • x is array name; x[0], x[1], … access elements.

Q14: List Data Structure & Operations:

OperationDescription
createList()Create a new list
copy()Copy one list to another
clear()Remove all elements
insert(X, ?)Insert element X at a position
remove(?)Remove element at a position
get(?)Get element at position
update(X, ?)Replace element at position with X
find(X)Check if X exists
length()Return list length

Q15: Dynamic arrays:

  • Resizable array allowing addition/removal of elements. Dynamic arrays differ from statically allocated arrays.

Q16: Difference between Array and List:

FeatureArrayList
MemoryContiguous/staticDynamic/random
SizeFixedCan grow
ModificationEasyComplex
Addition/DeletionNot possible after declarationCan add/delete nodes

Lecture 2: Linked Lists and Dynamic Memory

Q1: What are linked lists?

  • Sequence of nodes where each node points to the next. Allows dynamic memory allocation.

Q2: Why use arrays for implementing lists?

  • Array implementation stores elements contiguously. Limitations: fixed size β†’ use linked memory method.

Q3: Difference between static and dynamic arrays:

FeatureStatic ArrayDynamic Array
MemoryStackHeap
SizeFixedCan be input by user
Exampleint arr[6];int* arr = new int[size];

Q4: Difference between array and list:

FeatureArrayList
ElementsHomogeneousHeterogeneous
MemoryContinuousRandom
SizeFixedCan be dynamic

Q5: How to set current position?

  • Assign an index to the current variable, e.g., current = 3;.

Q6: How to shift elements left/right in array?

  • Use a loop to move elements; store first/last element temporarily.

Q7: Main operations on lists: (same as Lecture 1)

Q8: Main difference between array and list:

  • Array: indexed, contiguous memory, static size.
  • List: abstract, nodes, dynamic size, elements linked via pointers.
Contents Copyrights Reserved By T4Tutorials