First of all, Happy Diwali to everyone reading this! 🪔✨
I also owe this blog a small apology.
There are no Day 55 and Day 56 entries.
The reason is wonderfully simple: I didn't study on Saturday and Sunday because of Diwali.
So instead of pretending that I woke up at 5 AM during the festival to solve GATE PYQs between crackers and sweets, I'm just going to document what actually happened. I took two days off.
And on Monday, I was back.
Day 57 became a combination of Discrete Mathematics, C Programming question analysis, and Compiler Design practice. It was one of those days where I spent less time collecting completed chapters and more time stopping at confusing concepts until they actually started making sense.
Honestly, those days can be more useful than they initially look.
Back to Discrete Mathematics: Completing Propositional Logic
The first thing I worked on was Propositional Logic from Discrete Mathematics.
I completed the portion and also made notes for it.
The topics I covered included:
- Basics of Logic
- Propositional Logic
- Types of Propositions
- Logical Connectives
- Truth Tables
- Operator Precedence
- Tautology
- Contradiction
- Contingency
For operator precedence, I revised:
NOT → AND → OR → Implication → Bi-implication
Making the notes alongside the revision was important because I don't want this to become another chapter that I technically completed once and then have to rediscover later as if someone secretly changed the syllabus.
So the Propositional Logic portion is now revised and documented in my notes. ✅
C Programming: When One Pointer Question Turns Into a Full Investigation
The biggest part of today's study session was analysing C Programming questions.
And some of these questions became much more interesting than simply checking whether my answer was correct.
There were questions involving:
- Dynamic memory allocation
malloc()free()- Dangling pointers
- Pointer arithmetic
- Pointer subtraction
- Structure alignment
- Internal and external padding
Instead of quickly looking at the correct options and moving on, I wanted to understand why things were happening.
That led to some genuinely useful discussions. For more subject-wise question practice, see the site's PYQ notes.
| Metric | Result |
|---|---|
| Score | 9.67/25 |
| Percentage | 38.7% |
| Total questions | 15 |
| Attempted | 12 |
| Correct | 6 |
| Wrong | 6 |
| Skipped | 3 |
| Time taken | 44 minutes |
What Happens to Other Pointers After free()?
One of the most important concepts I clarified today involved multiple pointers pointing inside the same dynamically allocated memory block.
Suppose we have:
int *p1 = malloc(2 * sizeof(int));
int *p2 = p1 + 1;
Initially, the memory looks something like this:
[ int ][ int ]
↑ ↑
p1 p2
Now if we do:
free(p1);
The important thing is that free() releases the entire allocated block, not just the first integer.
That means both pointers are now related to memory that has already been freed.
So:
p1becomes dangling.p2also becomes dangling.
This was an important clarification for me because p2 still physically contains an address value.
But that address no longer gives me valid access to an allocated memory block.
The simplest rule I took from this was:
When an allocated memory block is freed, every pointer pointing anywhere inside that particular block becomes invalid for accessing that allocation.
That distinction helped clear up several parts of the question.
Pointer Arithmetic Does Not Bring Freed Memory Back From the Dead
Another interesting point came up while thinking about pointer arithmetic.
Suppose p2 originally points to the second element:
[ int ][ int ]
↑ ↑
p1 p2
After:
free(p1);
doing:
p2 -= 1;
can change the address value stored in p2.
But it does not magically recreate the allocated memory.
The memory block has already been freed.
Apparently pointer arithmetic is powerful, but not powerful enough to resurrect heap memory. A disappointing limitation of modern technology. 😭
Questioning the Memory Leak Explanation
One part of the discussion became particularly interesting.
There was a situation where the original pointer to allocated memory was overwritten, but another pointer was still pointing somewhere inside the allocated block.
Instead of accepting the label "memory leak" immediately, I stopped and questioned it:
If another pointer still points inside the allocated memory, is the memory really completely unreachable?
That question led to a deeper discussion about:
- The original pointer returned by
malloc() - Pointers pointing inside an allocated block
- Whether pointer arithmetic could reconstruct the starting address
- The requirement that
free()must receive the appropriate pointer value
This was probably one of the best moments of today's analysis.
Not because the question itself was easy, but because I didn't just memorise a label.
I actually tried to understand what every pointer was doing.
That's something I want to continue during my GATE CSE preparation.
Structure Padding: Why Is the Compiler Wasting My Memory?
Another question involved structure alignment and padding.
The question introduced two terms:
K
K represents the size and alignment requirement of an individual primitive data type.
For example:
char→ 1short→ 2int→ 4- pointer → 8
Kmax
Kmax is the largest primitive element size present in the structure.
The useful distinction I learned was:
K applies to an individual member.
Kmax applies to the structure-level alignment requirement.
The compiler may insert padding between members so that the next member starts at an appropriate address.
For example, if an 8-byte aligned member needs to start at an address divisible by 8 but the current position is 4, padding may be inserted before it.
The question also distinguished between:
- Internal padding: padding between structure members.
- External padding: padding added at the end of the structure.
Initially, I asked where the alignment rule was actually written in the question.
That turned out to be a useful question because the exact wording mattered.
Another reminder that before applying some rule from memory, I should first check what the question is actually giving me.
A Silly Pointer Subtraction Mistake
Not every mistake today was deeply philosophical.
One pointer subtraction question was actually something I understood, but I made a silly calculation mistake.
The pointers were pointing to arrays.
So the important size was:
Size of pointed-to array
=
Number of elements × sizeof(int)
For example:
int (*p)[2];
points to an array of two integers.
So the pointed-to size is:
2 × 4 = 8 bytes
Therefore, pointer subtraction works according to the size of that entire pointed-to type.
I had the right overall approach but made a mistake while calculating the size.
So I marked that one mentally as:
Concept understood. Calculation briefly betrayed me.
A very common partnership during competitive exams.
Compiler Design: Practising LL(1) Parsers in Two Different Ways
Later, I moved to Compiler Design.
I practised:
- Lexical Analysis
- Parsing Basics
- LL(1) Parser questions
The LL(1) practice was particularly useful because I solved questions using two different methods.
Method 1: The Tabular Method
This was the method taught by my professor.
The general approach I practised was:
- Check the grammar.
- Look for ambiguity.
- Check for left recursion.
- Check for common prefixes and left factoring requirements.
- Find FIRST sets.
- Use FOLLOW sets appropriately when epsilon is involved.
- Construct the LL(1) parsing table.
- Check for conflicts.
The final test is simple:
If a parsing table cell receives more than one production, there is a conflict.
And therefore:
The grammar is not LL(1).
Method 2: The Conflict-Based Shortcut
The second approach was faster.
Instead of always constructing the complete table, I checked for conflicts directly.
The main things involved were:
FIRST-FIRST conflicts
Different alternatives should not compete for the same lookahead symbol.
FIRST-FOLLOW conflicts
When epsilon is involved, FIRST and FOLLOW relationships must also be checked carefully.
So instead of building the entire table every time, this method helps identify whether a conflict exists.
If there is a conflict:
Not LL(1). ❌
If the required conflicts are absent:
LL(1). ✅
Why Practising Both Methods Helped
The best part was that I didn't just learn a second random method.
I solved the questions using both approaches.
The tabular method gave me a structured and familiar way of checking the grammar.
The shortcut method gave me a faster way to understand why conflicts occur.
That made the concept feel less like:
"Follow these steps and fill some boxes."
And more like:
"Check whether the parser can uniquely decide which production to use."
That connection is something I wanted.
A Small Diwali Break, Then Back to Work
Day 55 and Day 56 don't have blog entries because I didn't study on those days.
It was Diwali, and I took the break.
Now I'm back on Day 57 and continuing the GATE CSE 2027 preparation.
I don't think every missing study day needs an excuse disguised as productivity.
Sometimes you study.
Sometimes you celebrate a festival.
Then Monday arrives and suddenly you're discussing dangling pointers and LL(1) conflicts again.
Human civilisation continues somehow. 😭📚
What I Realized Today
Today's biggest lesson was about not accepting an answer without understanding the reasoning behind it.
The C Programming questions became much more useful because I kept asking:
- What exactly is this pointer pointing to?
- What happens after the memory is freed?
- Does another pointer still provide access?
- What does the question's wording actually specify?
Similarly, practising LL(1) using two different methods helped me understand the same concept from two directions.
One method constructs the table.
The other looks directly for conflicts.
For my GATE preparation, I think this is important.
I don't just want to remember that an answer is correct.
I want to understand why the other reasoning fails.
That's usually where the actual conceptual clarity hides.
Tomorrow
The plan is to continue the November revision schedule and keep working on the conceptual gaps that appeared during today's C Programming analysis.
I'll also continue Compiler Design revision and practice.
For now, Day 57 ended with:
- Propositional Logic completed and noted ✅
- C Programming concepts analysed in depth 🧠
- Structure padding becoming slightly less mysterious 📦
- LL(1) grammars practised through two different methods 📚
Not a bad way to return after Diwali.
And once again:
🪔 Happy Diwali to everyone reading this! 🪔
I hope your celebrations were peaceful, your sweets were excellent, and your preparation schedule survived better than mine did over the weekend. 😭❤️
What do you think?
Studying for GATE is less lonely when we're all figuring it out together.
Sign in with Google or continue as a guest to comment.
Loading comments...