WHATSAPP Welcome to Edugrown – Your Learning Partner
← Back to UG & PG Content
Exam Papers

BSC-1-YEAR-COMPUTER-SCIENCE-PROGRAMMING-METHODOLOGIES-D-328-2025

Barkatullah University (BU) · MP · Science (B.Sc) · 2025 · 0 views

Advertisement
D | BSc 1st Year 2025
B.Sc. First Year (NEP) Examination 2025

Computer Science – Programming Methodologies & Data Structures

B.Sc. First Year | Major/Minor

📄 D-328
⏱ 3 Hours | 🎯 70 Marks
3 Marks Each
Very Short Answer Type Questions – Attempt any TWO
Q1 (3 Marks)
Define a variable in C++.
✦ Answer

A variable in C++ is a named storage location in memory that holds a value of a specific data type. It is declared with: data_type variable_name;
Example: int age = 20; float salary = 35000.5; char grade = 'A';
Variables must be declared before use and their values can change during program execution.

Q2 (3 Marks)
What is a structure in C++?
✦ Answer

A structure in C++ is a user-defined data type that groups variables of different data types under one name.
Syntax:
struct Student {
  int rollNo;
  string name;
  float marks;
};

Structures allow related data to be stored together, e.g., a student's record with roll number, name, and marks.

Q3 (3 Marks)
What is a Linked List?
✦ Answer

A Linked List is a linear data structure where elements (nodes) are stored in non-contiguous memory locations. Each node contains:
1. Data – actual value
2. Pointer/Link – address of next node
Types: Singly linked list, Doubly linked list, Circular linked list.
Advantages: Dynamic size, easy insertion/deletion. Disadvantages: No random access, extra memory for pointers.

Q4 (3 Marks)
Explain the term Recursion.
✦ Answer

Recursion is a programming technique where a function calls itself to solve a problem by breaking it into smaller subproblems. Every recursive function needs:
1. Base case – stopping condition
2. Recursive case – function calling itself
Example: Factorial: int fact(n) { if(n==0) return 1; else return n*fact(n-1); }
Used in: Tree traversal, Tower of Hanoi, Fibonacci series.

9 Marks Each
Short Answer Type Questions (200 words each) – Attempt any FOUR
Q5 (9 Marks)
Explain the syntax of the switch statement in C++.
✦ Answer

The switch statement evaluates an expression and executes code based on matching case labels:

switch(expression) {
  case value1:
    // code
    break;
  case value2:
    // code
    break;
  default:
    // default code
}
  • Expression must be integer or character type.
  • break prevents fall-through to next case.
  • default executes if no case matches.

Example: Menu-driven programs where user selects an option (1–5) and appropriate action is performed.

Q6 (9 Marks)
What is a stack? Explain its operations.
✦ Answer

A Stack is a linear data structure that follows LIFO (Last In, First Out) principle – the last element inserted is the first to be removed.

Operations:

  • Push: Insert element at top of stack.
  • Pop: Remove element from top of stack.
  • Peek/Top: View top element without removing.
  • isEmpty: Check if stack is empty.
  • isFull: Check if stack is full (in array implementation).

Applications:

  • Function call management (call stack).
  • Undo/Redo operations in text editors.
  • Expression evaluation (infix to postfix).
  • Browser back-button history.
Q7 (9 Marks)
Write a program to demonstrate the use of For loop and While loop in C++.
✦ Answer
#include <iostream>
using namespace std;
int main() {
  // For loop: Print 1 to 5
  cout << "For Loop: ";
  for(int i=1; i<=5; i++) {
    cout << i << " ";
  }
  cout << endl;

  // While loop: Print 1 to 5
  cout << "While Loop: ";
  int j = 1;
  while(j <= 5) {
    cout << j << " ";
    j++;
  }
  return 0;
}

Output: For Loop: 1 2 3 4 5 | While Loop: 1 2 3 4 5

Q8 (9 Marks)
Explain file handling in C++ with examples.
✦ Answer

C++ provides fstream library for file handling:

  • ofstream: Write to file
  • ifstream: Read from file
  • fstream: Both read and write
// Writing to file
#include <fstream>
ofstream myfile;
myfile.open("data.txt");
myfile << "Hello World!";
myfile.close();

// Reading from file
ifstream infile("data.txt");
string line;
while(getline(infile, line)) { cout << line; }
infile.close();
Q9 (9 Marks)
What is Hashing? Explain with an example.
✦ Answer

Hashing is a technique to map data (keys) to fixed-size array positions (hash table) using a hash function.

Hash Function: h(key) = key mod table_size

Example: Table size = 7. Keys: 23, 10, 45
h(23)=23%7=2, h(10)=10%7=3, h(45)=45%7=3 (collision!)

Collision Resolution:

  • Chaining: Store colliding keys in linked list at same slot.
  • Open Addressing: Linear probing – find next empty slot.

Applications:

  • Database indexing, password storage (SHA hashing), symbol tables in compilers.
Q10 (9 Marks)
What are open-source programming languages? Give examples.
✦ Answer

Open-source programming languages are those whose source code, tools, and compilers are freely available for use, modification, and distribution without licensing fees.

Examples:

  • Python: Versatile, used in AI/ML, web development, data science.
  • Java: Platform-independent (JVM), enterprise applications.
  • C/C++: Systems programming, embedded systems.
  • JavaScript: Web development (client and server side).
  • PHP: Server-side web scripting.
  • R: Statistical computing and graphics.
  • Ruby: Web applications (Rails framework).
Q11 (9 Marks)
Describe Dr. Sartaj Sahni's contribution to data structures and algorithms.
✦ Answer

Dr. Sartaj Sahni is a renowned computer scientist and professor at University of Florida.

Key Contributions:

  • Co-authored the seminal textbook "Fundamentals of Data Structures in C++" and "Fundamentals of Computer Algorithms" (with Horowitz and Anderson-Freed).
  • Research in algorithm design, combinatorial algorithms, scheduling, and parallel computing.
  • Pioneered work on branch and bound algorithms and approximation algorithms.
  • Contributed to VLSI design and routing algorithms.
  • Fellow of IEEE and ACM, recipient of numerous awards.
14 Marks Each
Long Answer Type Questions (500 words each) – Attempt any TWO
Q12 (14 Marks)
Define Arrays. Discuss the various types of Arrays.
✦ Answer

An Array is a collection of elements of the same data type stored in contiguous memory locations, accessed by an index.

Declaration: int arr[5] = {1,2,3,4,5};

Types of Arrays:

  • 1D Array (Linear Array): Single row of elements. E.g., int a[5]; Used for lists, stacks, queues.
  • 2D Array (Matrix): Rows and columns. E.g., int mat[3][3]; Used for matrices, tables, game boards.
  • 3D Array: Extension to 3 dimensions. E.g., int cube[2][3][4]; Used in image processing.
  • Jagged Array: Array of arrays with different sizes. Each row can have different number of columns.
  • String Array: Array of character strings. E.g., char names[5][20];

Operations on Arrays:

  • Traversal, Insertion, Deletion, Searching (linear/binary), Sorting (bubble, selection, merge sort).
Q13 (14 Marks)
Discuss the various operators used in C++ with examples.
✦ Answer

Operators in C++:

  • Arithmetic: +, -, *, /, % → a+b, a%b
  • Relational: ==, !=, <, >, <=, >= → a>b
  • Logical: && (AND), || (OR), ! (NOT) → a>0 && b>0
  • Assignment: =, +=, -=, *=, /= → a += 5
  • Increment/Decrement: ++, -- → i++, --j
  • Bitwise: &, |, ^, ~, <<, >> → a & b
  • Conditional (Ternary): ? : → max = (a>b) ? a : b
  • sizeof: Returns size in bytes → sizeof(int)
  • Scope resolution: :: → access global variable or class member
Q14 (14 Marks)
Discuss the various types of graphs and graph traversal algorithms (BFS and DFS).
✦ Answer

Graph is a non-linear data structure consisting of vertices (nodes) and edges (connections).

Types of Graphs:

  • Directed (Digraph): Edges have direction. E.g., social network following.
  • Undirected: Edges have no direction. E.g., friendship network.
  • Weighted: Edges have weights (costs). E.g., road distances.
  • Connected: Path exists between every pair of vertices.
  • Cyclic/Acyclic: Contains/does not contain cycles.

BFS (Breadth First Search):

  • Visits all neighbors of a node before going deeper.
  • Uses a Queue. Time complexity: O(V+E).
  • Applications: Shortest path (unweighted), social network levels.

DFS (Depth First Search):

  • Explores as far as possible along each branch before backtracking.
  • Uses Stack (or recursion). Time complexity: O(V+E).
  • Applications: Topological sort, cycle detection, maze solving.
Q15 (14 Marks)
Discuss the various sorting methods used in Data Structures.
✦ Answer

Sorting Algorithms:

  • Bubble Sort: Compare adjacent elements; swap if out of order. O(n²). Simple but slow.
  • Selection Sort: Find minimum and place in sorted position. O(n²). Simple, fewer swaps.
  • Insertion Sort: Insert elements one by one into correct position. O(n²) worst, O(n) best (nearly sorted). Used for small datasets.
  • Merge Sort: Divide-and-conquer. Split, sort halves, merge. O(n log n). Stable sort, used in external sorting.
  • Quick Sort: Pick pivot, partition around it, recursively sort. O(n log n) average, O(n²) worst. Fastest in practice.
  • Heap Sort: Uses max-heap data structure. O(n log n). In-place, not stable.
  • Counting Sort: Non-comparison sort. O(n+k). Used when range of values is known.
BSc 1st Year 2025 | Question Paper Solutions | All Sections Covered
Advertisement

💬 Comments & Doubts

💭

Abhi tak koi comment nahi

Sabse pehle comment karne wale bano!

Apna comment likhein

Doubt ho ya suggestion — kuch bhi poochh sakte hain. Login zaroori nahi hai.

11 − 4 =

Ye sirf ye confirm karne ke liye hai ki aap robot nahi hain.

Comment publish hone se pehle admin check karta hai.

🔔 Email Updates Lein

Naya content aate hi email par pata chal jayega. Sirf wahi sections chunein jo chahiye.

🔒 Content copy nahi kar sakte