Texas Previous Years Solved Sample Placement Papers
-
Choose the correct alternative for when global variables in different files are recognized:
A. at compile time
B. at loading time
C. at linking time Answer: Option C
D. at execution time
- Solution: Global variables in different files are linked during the linking phase, making them accessible across files.
-
Choose the correct alternative for the size of an `int`:
A. always 2 bytes
B. depends on the compiler being used Answer: Option B
C. always 32 bits
D. can't tell
- Solution: The size of an `int` depends on the platform and compiler, typically 2 or 4 bytes.
-
Identify which program will overflow given the two programs:
A. Program 1
B. Program 2
C. Both 1 & 2
D. None Answer: Option C
- Solution: Both programs contain logic that could lead to stack or variable overflow during execution, depending on the input.
-
Variables of a function call are allocated in:
A. registers and stack Answer: Option A
B. registers and heap
C. stack and heap
D. None
- Solution: Function call variables are allocated in the stack, while registers may hold temporary values for faster access.
-
What is the average and worst-case time complexity of a sorted binary tree?
A. O(log n), O(n) Answer: Option A
B. O(log n), O(log n)
C. O(n), O(n)
D. O(n), O(log n)
- Solution: In a sorted binary tree, the average case is O(log n), while the worst case (skewed tree) is O(n).
-
The data structure used for a priority queue is:
A. Linked list
B. Doubly linked list
C. Array
D. Tree Answer: Option D
- Solution: Trees, such as heaps, are commonly used for implementing priority queues due to their efficient access and modification times.
-
Output of the program:
main() { char str[5] = "hello"; if (str == NULL) printf("string null"); else printf("string not null"); }
A. String is null
B. String is not null Answer: Option B
C. Error in program
D. It executes but prints nothing
- Solution: The condition `str == NULL` will never be true since `str` is a valid memory address.
-
Choose the best bucket size for hashing:
A. 100
B. 50
C. 21
D. 32 Answer: Option D
- Solution: The number of buckets should be chosen as a power of 2 for efficient hashing.
-
Output of the program:
void f(int *p) { static val = 100; val = &p; } main() { int a = 10; printf("%d ", a); f(&a); printf("%d ", a); }
A. 10, 10 Answer: Option A
B. 10, 0
C. Error
D. Undefined behavior
- Solution: The program does not modify the variable `a`, so it prints `10` twice.
-
Given the following code:
main() { char a[10] = "hello"; strcpy(a, '\0'); printf("%s", a); }
A. String is null
B. String is not null
C. Program error
D. Answer: Program error
- Solution: The `strcpy` function expects a valid string, but `'\0'` is a character constant, leading to a program error.