Notes for Solving C Programming and Discrete Mathematics Questions
Notes for Solving C Programming and Discrete Mathematics Questions
Here are the extracted questions categorized by topics along with the number of questions from each
topic:
Would you like detailed solutions or explanations for any specific questions?
Here are the extracted questions categorized by topics along with the number of questions from each
topic:
Would you like detailed solutions or explanations for any specific questions?
Here are the solutions to the questions from both uploaded images:
Infix: `A * (B + C) / D`
Convert to prefix:
1. `B + C` → `+BC`
2. `A * (+BC)` → `*A+BC`
3. `(*A+BC) / D` → `/ *A+BC D`
Answer: `/ *A+BC D` (None of the given options are correct)
Expression: `823^/23*+51^`
Given that `^` is exponentiation:
1. `3^2 = 9`
2. `8 / 9` → Integer division (if assumed) → `0`
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/18
3. `0 * 2 = 0`
4. `0 + 3 = 3`
5. `5 ^ 1 = 5`
Stack top two elements: 3, 2
Answer: (c) 3, 2
Formula: log⌈p/2⌉(n+1)
Answer: (c) log⌈p/2⌉(n+1)
The left subtree is always visited before the right subtree in all three traversals.
Answer: (b) Left subtree is always visited before the right subtree
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/18
All-pairs shortest path → Dynamic Programming
Quicksort → Divide and Conquer
Minimum weight spanning tree → Greedy
Connected components → Depth-first search
Correct Code: (a) 2 4 1 3
temp = a;
a = b;
b = temp;
Answer: (a) 1
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/18
Q46: Program Execution Outcome
i = 6720; j = 4;
while ((i % j) == 0)
{ i = i / j; j = j + 1; }
Iteration-wise execution:
i = 6720, j = 4 → 6720 / 4 = 1680, j = 5
i = 1680, j = 5 → 1680 / 5 = 336, j = 6
i = 336, j = 6 → 336 / 6 = 56, j = 7
i = 56, j = 7 → 56 / 7 = 8, j = 8
i = 8, j = 8 → 8 / 8 = 1, j = 9
Final i = 8
Answer: (b) 8
int i, j, n;
j = 1;
while (j <= n) j = j * 2;
main() {
int a = 'A';
printf("%d", a);
}
Q.No. Answer
Q31 `/ *A+BC D`
Q33 (c) 3, 2
Q34 (b) 4
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/18
Q.No. Answer
Q36 (a) 2 4 1 3
Q39 (b) Left subtree is always visited before the right subtree
Q44 (a) 1
Q45 (a) 7
Q46 (b) 8
Q48 (c) 65
1. Which of the following is correct recurrence relation for worst case of binary search?
Answer: (a) T (n) = 2T (n/2) + O(1)
2. Which of the following traversal techniques lists the nodes of a binary search tree in
ascending order?
Answer: (c) Inorder
3. Which of the following choices gives a possible order in which the key values could have been
inserted in the hash table?
Answer: (c) 34, 42, 25, 33, 46
5. The minimum number of temporary variables needed to swap the contents of two variables
Answer: (a) 1
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/18
perl
perl
i=-6720, j=4;
while((i%j)!=0)
{
i=i/j;
j=j+1;
}
8. The number of comparisons made in the execution of the following loop for any n>0 is:
cpp
int i, n;
j=1;
while (j<=n)
j=j*2;
perl
main()
{
int a='A';
printf("%d", a);
}
Answer: (b) 65
10. Which of the following is NOT a storage class specifier in C programming language?
Answer: (b) Volatile
cpp
scanf("%4s", str);
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/18
css
Among the following expressions, which will not give compile time errors if used as left-hand
side of assignment statements?
Answer: (c) II and IV only
13. What is the output of the following program?
perl
#include <stdio.h>
int main()
{
int index;
for(index = 1; index<=5; index++)
{
printf("%d", index);
index++;
continue;
}
}
css
int *p[5];
15. In the relation R={(1,2), (2,3)}, the minimum number of ordered pairs that must be added to
the set so that the generated relation is reflexive, symmetric, and transitive is:
Answer: (b) 5
Recurrence Relation 1
Hashing 1
C Programming Basics 1
C Program Output 5
Storage Classes in C 1
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/18
Topic Number of Questions
All three tables have been merged into this comprehensive table.
Recurrence relations define the time complexity of recursive algorithms. The general form is: T (n) =
aT (n/b) + f (n) where:
Traversal Orders:
4. Basics of C Programming
Data Types and Operators:
Example:
int a = 5, b = 2;
printf("%d", a+++++b);
Example:
int i = 5;
while (i > 0) {
printf("%d", i);
i--;
}
Output: 54321
6. Storage Classes in C
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/18
Types:
Arrays store multiple values of the same type. Pointers hold memory addresses.
Example:
`a[i]`
`b[i][j]`
Example:
Given R = {(1, 2), (2, 3)}, adding 5 more pairs ensures reflexive, symmetric, and transitive closure.
Summary:
These notes cover key concepts for solving C programming and discrete mathematics questions.
Practice with different variations of these problems to strengthen your understanding.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/18
I've created detailed notes covering key concepts needed to solve similar C programming and discrete
mathematics questions. Let me know if you need further explanations or practice problems!
Here are the detailed notes covering key concepts with additional important information for solving
similar C programming and discrete mathematics questions. Let me know if you need more topics!
C Programming Notes
1. C Programming Concepts
1.1 Storage Classes in C
1.2 Functions in C
Break and Continue: Break exits the loop; Continue skips the current iteration.
Pointer Arithmetic: Operations like `ptr++`, `ptr--` modify the address stored.
`sizeof(arr)` gives total memory allocated, while `sizeof(ptr)` gives pointer size.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/18
1.5 Functions and Recursion
Example:
int factorial(int n) {
if (n == 0) return 1;
return n * factorial(n-1);
}
Common Complexities:
O(n log n): Efficient sorting (e.g., Merge Sort, Quick Sort).
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/18
Linear Recurrence: `T(n) = aT(n/b) + O(f(n))`
Graph Traversals:
int a = 5, b = 2;
printf("%d", a+++++b);
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/18
fun(&x);
printf("%d", x);
}
Answer: `x` becomes `15` as the pointer modifies the original variable.
Q4: How many ordered pairs must be added to {(1,2), (2,3)} to make it reflexive,
symmetric, and transitive?
Conclusion
Practice recurrence relations using Master Theorem.
These notes provide strong conceptual clarity for solving C programming and discrete mathematics
questions in exams. Let me know if you need additional explanations or examples!
I've created detailed notes covering C programming and discrete mathematics concepts, including
storage classes, pointers, hashing, graph theory, and sample questions with solutions. Let me know if
you need more explanations or additional topics!
I'll create detailed notes covering these topics along with important programs and explanations for a
strong understanding. Stay tuned!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 14/18
C Java Networking Notes
Programming Fundamentals
Non-primitive Data Type (String)
Strings are immutable, meaning their values cannot be changed once assigned.
Example Program
Example Program
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 15/18
Deployment Descriptor (XML File)
Software Engineering
Reliability Calculation (Max 0.81)
Formula: R = R1 × R2 × R3 ...Rn
Example: If a system has three components with reliability 0.9, 0.9, and 0.95: R = 0.9 × 0.9 ×
0.95 = 0.81
The Implementation Phase in the Software Development Life Cycle (SDLC) includes:
Training users.
MIME Expansion
URL Expansion
Example
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 16/18
<a href="https://www.google.com">Visit Google</a>
Important Programs
Finding Reliability of a System
import java.net.FileNameMap;
import java.net.URLConnection;
Conclusion
These notes cover essential concepts in programming, Java, networking, and software engineerin
By understanding these topics, students can improve their problem-solving skills and perform well in
exams and practical applications.
I've created detailed notes covering programming fundamentals, Java, networking, and software
engineering, along with key concepts and example programs. Let me know if you need further
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 17/18
refinements or additional topics!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 18/18