Set e All Programming Test Hitb
Set e All Programming Test Hitb
852
Infinite loop
Compila on Error
prin ("2
void tempo
10
01
Compila on Error
Run Time Error
int
*q)
30 5
65 56
None of the above
mamo
*p) { char
*m; m = (p+=
sizeof(int))[-2]; prm
("%s", m); a b c d
Compila on Error
Garbage Value
10 15
10 20
15 20
pointer to array
&a return 0; 5
0.0000 0
555
Error
int arr[3J = {1, 2, 3}; int *ptr = arr; int * *temp = &ptr prin
Different Address
12
23
42
22
44
24
No
May B
Can't Say
*q)
30 6
6 36
36 6
-42
Auto
Register
Sta c
Extern
. (dot operator)
: (colon operator)
10 40 20 30 10 30 40
20
Syntax error
To complete ✅ your Tests of Hitbullseye
and Myperfectice with highest marks.
enqueue(item): if rear
max size -
1 rear = 0 else: rear* +
queue[rear] = item
enqueue(item): rear = (rear
+ 1)
% max_size queue[rear] =
item enqueue(item): if rear
max size - 1: rear = 0
queue[rear] = item
enqueue(item): rear* +
queue[rear]
= item
X may be undecidable.
1, 2 and 3
1 and 3
2 and 3
1 and 2
O(N)
O(N log N)
O(log N)
O(N2)
In the Frac onal Knapsack problem, if the items have equal values but different weights, which
strategy should the greedy algorithm follow to obtain the op mal solu on?
80
0.0125
8000
1.25
0(1)
O(log n)
O(n)
0(nA2)
AVL tree
Hash table
Linked list
2.6
2.7
2.8 2.9
intarr[] = {1, 2, 3, 4,
3
4
2
3
Compiler Error
By reference
By value
By pointer
By constant reference
How do you define a member func on of a class outside the class in C++?
returnType className::func onName(parameters) {body} func
className {body}
Program with no "main" func on but with other func ons defined.
Program with a class defini on containing only sta c member func ons
*include <iostream>
Return 0;
543
54
5432
53
There is no difference
Program with no "main" func on but with other func ons defined.
Program with a class defini on containing only sta c member func ons.
Which of the following statements accurately describes the role of header files in C++ program structure?
Header files contain executable code that is included in the final program.
Header files define the interface for func ons and classes
used in a program.
Header files provide the main entry point for program execu on.
Header files declare global variables and func ons for the program.
In C++, what is the purpose of the "sta c" keyword in program structure?
Which of the following statements accurately describes the role of the "iostream" header file in C++
program structure?
Consider the following C++ program snippet for inser ng a node at the end of a linked list:
>next; return 0;
Infinite Loop
54321
1234
5432
Consider the below program, and iden fy which Opera on is performed. int solve(stmct
Node* head) if NULL) return 1; struct Node* ptr; ptr = head->next; while (ptr N-.TLL &&
ptr head) ptr = ptr->next; return (Otr head);
Checking for List is empty of not Checking for the list is
Circular or not count the number of elements in the list
None
What does the following func on check for? (all necessary headers to be included and func on is called
from main) *define MAX 10 typedef struct stack mt top; int item[MAXJ
Invalid index
Empty stack
Infinite stack
("%d" + 2));
3 6
};
What are access specifiers in C++?
In a C++ applica on, a developer implements a cache mechanism using smart pointers to manage cached
objects' memory. However, a er extended usage, the program's performance degrades significantly. What
The cache mechanism encounters hash collisions, leading to increased lookup mes
Which of the following problems cannot be solved op mally using a greedy algorithm?
Knapsack Problem
A programming approach that divides a problem into smaller subproblems and solves them recursively.
Stack
Queues
Linked List
Graph
A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09
and 0.24 respec vely. The op mal Huffman coding technique will have the average length of:
2.40
2.16
2.26
2.15
A hash func on h defined h(key)=key mod 7, with linear probing, is used to insert the keys
44, 45, 79, 55, 91, 18, 63 into a table indexed from 0 to 6. What will be the loca on of key
18?
4
5 6
A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle
is? Queue
Circular queue
Dequeue
Priority queue
The KMP algorithm is par cularly efficient when searching for a pa ern within a text that:
The average successful search me for sequen al search on 'n' items is.
n/2
(n-1)/2
(n + 1)/2
Log(n) + 1
2
3
To define a func on
To declare a func on before its usage
To ini alize func on variables
To terminate a func on
return O; 1010 10
infinitely print 10 compile me
error
A constructor func on
void
The type of the class
1. *
2. ::
3. _>*
4. ::* 5. _>
Only 1, 3, 4
only 3, 4, 5
<queue>
<deque>
<dqueue>
<cqueue>
*include <iostream>
#mclude <queue>
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
q.pop(); cout qfront(); return 0;
10
20
30
Compila on Error
10 20 30
Garbage Value
Syntax error
Run me error
Garbage Value
Syntax error
Run me error
1 nullptr
Compila on error
20 10 30
30 10 20
Syntax error
list:
q. enqueue( O);
q. dequeue();
q. dequeue();
q. enqueue(40);
q. dequeue(); cout << "Front element " << q dequeue() << endl, return
O;
A class member
for variables
O(n)
0(nA2)
O(nA3)
O(2An)
Fibonacci number?
O(n)
O(log n)
O(nA2)
O(2An)
12
10
8
15
O(n)
O(logn)
O(nlogn)
0(1)
Let S be an NP-complete problem and Q and R be two other problems not known to be in NR Q is
polynomial me reducible to S and S is polynomial- me reducible to R. Which one of the following statements
is true?
R is NP-complete
R is NP-hard
Q is NP-compIete
Q is NP-hard
selec on sort
Which func on is used to free the memory allocated by the malloc func on? dealloc free
release dispose
A C++ program is designed to manage a large database with extensive memory requirements. The
program dynamically allocates memory using the "new" operator to store database records. However, a er
running for a while, the program crashes due to excessive memory consump on. What could be a poten al
The program exceeds the maximum stack size allocated for dynamic memory.
Memory leaks occur, resul ng in con nuous alloca on of memory without dealloca on. The program
encounters a segmenta on fault due to invalid memory access. Which of the following statements
accurately describes the role of header files in C++ program structure?
Header files contain executable code that is included in the final program
Header files define the interface for func ons and classes used in a program
Header files provide the main entry point for program execu on
Header files declare global variables and func ons for the program
oned
Func ons in a C++ program must be defined in the same order as they are called.
Variables declared inside a func on are accessible only within that func on.
C++ programs must have a class defini on even if no objects are instan ated.
What is the significance of the "return 0;" statement at the end of the "main" func on in a
C++ program?
It has no significance and can be omi ed without affec ng program execu on.
What is the result of the following code snippet?
3 4
1040
20 40
Syntax error
-999;
} else {
Object ele = stk[top]; size of stack--; return ele; public class
Stack is full
20
0
10 20 30 40
10 20 40
103040
Syntax error
*include *include
<deque> usmg
for (int i
Garbage value
Syntax error
Consider the following C++ program snippet for coun ng the number of nodes in a linked
list:
mam() {
Node* head = new Node head->data = I
Infinite Loop
2
Compila on error
What is the correct implementa on of the dequeue() func on for a double-ended queue
q.remove_front();
There are the following statements that are given below, which of them are correct about deque container
in C++?
The deque stands for the double-ended queue.
In the deque container, data can be inserted and deleted from both the front and back ends the side. A and
B A, C, and D
A, B, and D
C and D
Which of the following is NOT a valid way to ini alize a queue in C++?
{1 ,
return Integer.Mm
return var;
Returns the data and deletes the node at the end of the list
Returns the data from the beginning of the list and deletes the node from the beginning of the list
Returns the data and deletes the node from the beginning of the list
Which of the following is a drawback of the dynamic programming solu on for the 0/1
Knapsack problem?
It has exponen al me complexity
The Longest Common Subsequence problem is a classic example of which type of dynamic programming
problem?
Par on problem
Op miza on problem
Which of the following is an advantage of adjacency list representa on over adjacency matrix representa
on of a graph?
O(VA2) me in adjacency matrix representa on. Here it is V and E are the number of ver ces and edges
respec vely.
Adding a vertex in adjacency list representa on is easier than adjacency matrix representa on.
All of the above
Every element has equal probability of hashing into any of the slots
What is the key property used in dynamic programming to solve the Longest Common
Subs uence roblem?
Op mal substructure
Overlapping subproblems
Subproblem decomposi on
Hamiltonian circuit
Bin packing
Par on problem
Hal ng problem
As part of the maintenance work, you are entrusted with the work of rearranging the library books in a
shelf in proper order at the end of each day. The ideal choice will be bubble sort inser on sort selec on
0
-1
Excep on
0123456789
10
012345678910 compile me error
O(log n)
O(N)
O(n log n)
What will be the output of the following C++ program snippet for searching a key in a linked list? 0 1
true fals e
0(1)
O(n logn)
1
12
123
Compila on error
A C++ program must have exactly one class defini on, which acts as the main program structure.
What is the func onality of the given code? Choose the most
appropriate answer:
strategy?
Include only the elements that exactly meet the target sum
if(wt[itm - IJ w)
= find_max(ans[itm - - - 1],
100
180 220
and B.
Then x + 10y =
33
23
43 34 Consider an
undirected random
graph of eight ver ces.
The probability that
there is an edge
between a pair of ver
ces is 1/2. What is the
expected number of
unordered cycles
Of length three?
1/8
7 8
Overlapping subproblems
Op mal substructure
Both overlapping subproblems and op mal substructure
O(n)
O(logn)
O(nlogn)
0(1)
Given the following statements: Sl : Every context-sensi ve language L is recursive S2 : There exists a
recursive language that is not context-sensi ve Which statements are true?
Only Sl is correct
Only S2 is correct
Dijkstra's Algorithm
Prim's Algorithm
Kruskal's Algorithm
Interval Scheduling Algorithm
The given array is arr = {1 Bubble sort is used to sort the array elements. How many itera ons will
2
1