Cpc-Mtech (Vlsi and Communication Systems) C&ds Test-3 Max Marks 50 Prepared by Siva Time Duration 75min

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Cpc-mtech(vlsi and communication systems)

C&ds Test-3 max marks 50


Prepared by siva
time duration 75min
Name:
roll no:
1. Which of the following sorting c. Prints alternate nodes of Linked
algorithms can be used to sort a List
random linked list with minimum
d.Prints alternate nodes in reverse
time complexity?
order
a. Insertion Sort b. Quick
Sort
3. Which one of the following is an
c. Heap Sort d. Merge Sort
application of Stack Data Structure?
a. Managing function calls
2. What does the following function
b. The stock span problem
do for a given Linked List with first
node as head? c. Arithmetic expression evaluation
void fun1(struct node* head) d. All of the above
{
if(head == NULL) 4. The following postfix expression
with single digit operands is evaluated
return;
using a stack:
823^/23*+51*-
fun1(head->next);
Note that ^ is the exponentiation
printf("%d ", head->data); operator. The top two elements of the
stack after the first * is evaluated are:
}
a. 6, 1 b. 5, 7 c. 3, 2 d. 1, 5
a. Prints all nodes of linked lists
5. Following is C like pseudo code of
b. Prints all nodes of linked list in
a function that takes a Queue as an
reverse order
argument, and uses a stack S to do b. Keeps the Q same as it was before
processing. the call
void fun(Queue *Q) c. Makes Q empty
{ d. Reverses the Q
Stack S; // Say it creates an 6. Which one of the following is an
application of Queue Data Structure?
empty stack S
a. When a resource is shared among
multiple consumers.
// Run while Q is not empty
b. When data is transferred
while (!isEmpty(Q)) asynchronously (data not necessarily
{ received at same rate as sent) between
two processes
c. Load Balancing
// deQueue an item from Q and push the
d. All of the above
dequeued item to S
7. Which of the following is true
push(&S, deQueue(Q)); about linked list implementation of
} queue?
a. In push operation, if new nodes are
inserted at the beginning of linked list,
// Run while Stack S is not empty then in pop operation, nodes must be
while (!isEmpty(&S)) removed from end.

{ b. In push operation, if new nodes are


inserted at the end, then in pop
// Pop an item from S and enqueue the poppped itemnodes
operation, to Q must be removed
enQueue(Q, pop(&S)); from the beginning.
} c. Both of the above
} d. None of the above
7. Postorder traversal of a given
binary search tree, T produces the
a. Removes the last from Q following sequence of keys 10, 9, 23,
22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences following is the postorder traversal
of keys can be the result of an in- sequence of the same tree?
order traversal of the tree T?
a. 10, 20, 15, 23, 25, 35, 42, 39, 30
a. 9, 10, 15, 22, 23, 25, 27, 29, 40, 50,
b.15, 10, 25, 23, 20, 42, 35, 39, 30
60, 95
c. 15, 20, 10, 23, 25, 42, 35, 39, 30
b. 9, 10, 15, 22, 40, 50, 60, 95, 23, 25,
27, 29 d. 15, 10, 23, 25, 20, 35, 42, 39, 30
c. 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 11. Which of the following traversals
50, 95 is sufficient to construct BST from
given traversals 1) Inorder 2) Preorder
d. 95, 50, 60, 40, 27, 23, 22, 25, 10, 9,
3) Postorder
15, 29
a. Any one of the given three
8. The height of a tree is the length of
traversals is sufficient
the longest root-to-leaf path in it. The
maximum and minimum number of b. Either 2 or 3 is sufficient
nodes in a binary tree of height 5 are c. 2 and 3
a. 63 and 6, respectively d. 1 and 3
b. 64 and 5, respectively 12. What does the function print() do
c. 32 and 6, respectively in general? The function print()
receives root of a Binary Search Tree
d. 31 and 5, respectively
(BST) and a positive integer k as
9. The following numbers are inserted arguments.
into an empty binary search tree in the
// A BST node
given order: 10, 1, 3, 5, 15, 12, 16.
What is the height of the binary struct node {
search tree (the height is the int data;
maximum distance of a leaf node
from the root)? struct node *left, *right;

a.2 b.3 c.4 d.6 };


10. The preorder traversal sequence of
a binary search tree is 30, 20, 10, 15, int count = 0;
25, 23, 39, 35, 42. Which one of the
void print(struct node *root, int k) 14. Let A be a square matrix of size n
x n. Consider the following program.
{
What is the expected output?
if (root != NULL && count <= k)
C = 100
{
for i = 1 to n do
print(root->right, k);
for j = 1 to n do
count++;
{
if (count == k)
Temp = A[i][j] + C
printf("%d ", root->data);
A[i][j] = A[j][i]
print(root->left, k);
A[j][i] = Temp - C
}
}
}
for i = 1 to n do
a. Prints the kth smallest element in
for j = 1 to n do
BST
Output(A[i][j]);
b. Prints the kth largest element in
BST a. The matrix A itself
c. Prints the leftmost node at level k b. Transpose of matrix A
from root
c. Adding 100 to the upper diagonal
d. Prints the rightmost node at level k elements and subtracting 100 from
from root diagonal elements of A
13. While inserting the elements 71, d. None of the above
65, 84, 69, 67, 83 in an empty binary
15. Which of the following is not a
search tree (BST) in the sequence
stable sorting algorithm in its typical
shown, the element in the lowest level
implementation
is
a. nsertion Sort
a.65
b. Merge Sort
b.67 c.Quick Sort
d.Bubble Sort
c.69
d.87
16. Which of the following sorting int a[] = {12, 7, 13, 4, 11, 6};
algorithms has the lowest worst-case
printf("%d", f(a, 6));
complexity?
getchar();
a. Merge Sort
return 0;
b. Bubble Sort
}
c. Quick Sort
(A) -9 (B) 5 (C) 15
d. Selection Sort
(D) 19
17. You have to sort 1 GB of data
with only 100 MB of available main
memory. Which sorting technique 19. The value of j at the end of the execution
will be most appropriate? of the following C program.)
a. Merge Sort
b. Bubble Sort int incr (int i)
c. Quick Sort {
d. Selection Sort static int count = 0;
18. 2. What is the value printed by the count = count + i;
following C program?
return (count);
#include<stdio.h>
}
int f(int *a, int n)
main ()
{
{
if(n <= 0) return 0;
int i,j;
else if(*a % 2 == 0) return *a + f(a+1, n-1);
for (i = 0; i <=4; i++)
else return *a - f(a+1, n-1);
j = incr(i);
}
}
(a) 10
int main() (b) 4
{ (c) 6
(d) 7
20. Consider the following C 4.write a c program to print pascal
declaration triangle
struct { 5.write a c program to calculate hcf
and lcm of a number
short s [5]
6. Write a c program to find the size
union {
of int without using sizeof operator
float y;
7.write a c function to reverse a single
long z; linked list
}u; 8.wrie a c function to given an array
} t; of n numbers, give an algorithm for
checking whether they are any
duplicate elements in the array or not
Assume that objects of the type short, 9.write a c program for find the
float and long occupy 2 bytes, 4 bytes number occurring odd number of
and 8 bytes, respectively. The times in a given array
memory requirement for variable t,
ignoring alignment 10. write a c function for implement
considerations, is stack using queues

(a) 22 bytes
(b) 14 bytes
(c) 18 bytes
(d) 10 bytes

Programing:
1.write a c program to print ascii
numbers.
2.write a c program for sum the digits
of a given number.
3.write a c program to find Fibonacci
series

You might also like