Unit 1: Basic Data Structures - Subjective Questions

CSE329 — Prelude To Competitive Coding • Practice Questions with Detailed Answers

20 questions

1

Define an array. Explain how 1D and 2D arrays are declared and processed in memory, with suitable examples.

2

Explain the algorithms for insertion and deletion of an element in a 1D array at a given position. Analyze their time complexity.

3

Describe the different approaches to perform array rotation by positions. Explain the Reversal Algorithm and the Juggling Algorithm in detail.

4

Write an algorithm to perform matrix multiplication of two matrices and . State the condition for multiplication and derive its time complexity.

5

Distinguish between lower triangular and upper triangular matrices. Write conditions and code snippets to check both.

6

Explain the algorithm to print a matrix in spiral form with a suitable example. Analyze its time and space complexity.

7

Describe an algorithm to find distinct elements common to all rows of a matrix. Explain how hashing improves efficiency.

8

Explain string declaration and manipulation in C. Discuss common string functions with examples.

9

Given a string, explain how to find the minimum number of characters needed to make it a Pangram. Provide the algorithm and an example.

10

Explain the problem of rearranging characters so that no two adjacent characters are the same. Describe an algorithm using a greedy/heap approach.

11

Explain how to find the minimum number of characters to remove from two strings to make them anagrams. Give the algorithm with an example.

12

Describe the implementation of a stack using an array. Explain PUSH, POP, and PEEK operations along with overflow and underflow conditions.

13

Explain how to implement two stacks in a single array efficiently. Discuss the space-efficient approach.

14

Explain how to implement a Stack using Queues. Describe both the push-costly and pop-costly approaches.

15

Explain the implementation of a Circular Queue using an array. Why is a circular queue preferred over a linear queue?

16

Explain the implementation of a Deque (Double Ended Queue) using a circular array. List its operations and applications.

17

Explain the Two Pointer Technique. Using it, write an algorithm to determine whether there exists a pair in an unsorted array whose sum equals a given value .

18

Explain the concept of a Peak Element in an array. Write an efficient algorithm to find a peak element and analyze its complexity.

19

Explain how to rearrange positive and negative numbers in an array alternately. Also explain how to find the majority element using the Moore's Voting Algorithm.

20

Explain the following array problems with their approaches: (a) Move all zeros to the end of the array, and (b) Find the first non-repeating element in an array of integers.