Programming and Data Structures Short Notes for GATE CS
GATE CS Programming and Data Structures: 1 units and 7 chapters, weightage from 66 previous year questions across 10 papers, a study order by exam weight and
A question from this chapter
Question 1
Level 1: Warm-up
Consider the C expression (x > 0) && (y++). If x is -1 and y is 5 before the expression is evaluated, what is the value of y immediately after?
Question 2
Level 1: Warm-up
Consider the following C declaration:
```c
char msg[] = "OK";
```
What is the numerical value of sizeof(msg)?
Question 3
Level 1: Warm-up
An empty stack and an empty queue undergo the following operations:
Let S be the sum of elements currently in the stack, and Q be the sum of elements currently in the queue. Which of the following correctly describes the relationship between S and Q?
Question 4
Level 1: Warm-up
In a binary search tree, let X be an internal node, Y be its immediate left child, and Z be its immediate right child. Assuming all keys are distinct, which of the following represents the correct ascending order of their values?
Question 5
Level 1: Warm-up
A binary min-heap contains 20 distinct elements. The maximum element can be stored at most in _____________ different positions in the underlying array.
Free preview ends here
Login to view the complete short notes
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Built around you, not around a syllabus PDF
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
Revision that hits your weak spots
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Questions calibrated to the real exam
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Notes written for recall, not for volume
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
One place for everything
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
Honest progress
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Unlock the whole course
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
Programming and Data Structures Short Notes for GATE CS
GATE CS Programming and Data Structures: 1 units and 7 chapters, weightage from 66 previous year questions across 10 papers, a study order by exam weight and 563 practice questions.
About Programming and Data Structures Short Notes
Quick revision sheets for Programming and Data Structures in GATE CS. Every chapter is condensed into key formulas, shortcuts and common traps so you can revise 7 chapters fast before the exam.
GATE CS Programming and Data Structures Unit-wise Weightage from Past Papers
We counted every GATE CS Programming and Data Structures previous year question in our bank (66 questions from 10 papers) and grouped them by unit.
Let S be the sum of elements currently in the stack, and Q be the sum of elements currently in the queue. Which of the following correctly describes the relationship between S and Q?
A.
S=Q
B.
S>Q
C.
S<Q
D.
S=2Q
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a bounding question testing the fundamental difference between LIFO (stack) and FIFO (queue) removal constraints.
Step 1: Trace the Stack (LIFO).
push(10) → [10]
push(20) → [10, 20]
pop() → removes 20 (top). Stack is [10]
push(30) → [10, 30]
Sum S=10+30=40.
Step 2: Trace the Queue (FIFO).
enqueue(10) → [10]
enqueue(20) → [10, 20]
dequeue() → removes 10 (front). Queue is [20]
enqueue(30) → [20, 30]
Sum Q=20+30=50.
Step 3: Compare S and Q. 40<50, so S<Q.
Answer: S<Q
Question 4 · Binary Trees, Binary Search Trees and TraversalsMCQ
In a binary search tree, let X be an internal node, Y be its immediate left child, and Z be its immediate right child. Assuming all keys are distinct, which of the following represents the correct ascending order of their values?
A.
Z<X<Y
B.
Y<X<Z
C.
X<Y<Z
D.
Y<Z<X
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a language-to-math translation question testing the strict definition of the BST invariant.
Step 1: Translate the BST property into mathematical inequalities. For any node X, all values in its left subtree must be strictly less than X. Therefore, Y<X.
Step 2: Similarly, all values in the right subtree must be strictly greater than X. Therefore, X<Z.
Step 3: Combine the inequalities: Y<X and X<Z gives Y<X<Z.
Step 4: Match this with the options. Option B matches exactly.
Answer: B
Question 5 · Heaps, Priority Queues and Data Structure OperationsNAT
A binary min-heap contains 20 distinct elements. The maximum element can be stored at most in _____________ different positions in the underlying array.
Correct Answer:
10
Step-by-Step Solution
Key idea: In a min-heap, the maximum element must be at a leaf node. The number of leaves in a complete binary tree with n nodes is ⌈n/2⌉.
Step 1: Identify that in a min-heap, the maximum cannot be at an internal node (it would violate the heap property since children must be ≥ parent).
Step 2: Therefore, the maximum must be at a leaf.
Step 3: Count the leaves: ⌈n/2⌉=⌈20/2⌉=10.
Answer: 10
Common trap: Using ⌊n/2⌋=10 gives the same answer for even n, but for odd n it would be wrong. Always use ⌈n/2⌉ for leaf count.