SlideShare a Scribd company logo
1
End Semester Examination
Introduction to Computing (CS 101)
IIT Guwahati
April 29, 2014
Duration: 3 Hours
Instructions:
(1) Encircle the answer (A/B/C/D/E) in the space provided in the answer script.
(2) Each question has exactly one correct answer.
(3) There are a total of 50 questions. Each question carries two marks.
(4) Negative Marking: Each wrong answer will be penalised by 1
2
negative marks.
(5) Please write your name and roll number on both the question paper and the answer script.
(6) Possession of either a mobile phone or a calculator is strictly prohibited during the exam.
(7) No doubts will be entertained during the exam.
(8) There are 6 pages of questions and 2 pages for rough work in the question paper. Please contact the invigilator, if otherwise.
Name: Roll No:
1. The conversion of a program from some high-level
programming language to machine language (object
code) is done by a .
(A) Compiler
(B) Loader
(C) Linker
(D) All of the above
(E) None of the above
2. Which of the following is not a storage device?
(A) Hard Disk
(B) CD ROM
(C) Keyboard
(D) Floppy Disk
(E) None of the above
3. In C programming, the name of an array indicates
the .
(A) Address of the first element of the array
(B) First element of the array
(C) Number of elements in the array
(D) Data type of the elements stored in the array
(E) None of the above
4. Which of these data types is used by an operating
system to manage the recursion in C programming?
(A) Stack
(B) Queue
(C) Linked List
(D) Array
(E) None of the above
5. Let A be an array containing n distinct integers. If
i < j and A[i] > A[j], then the pair (i, j) is called an
inversion of A. Which array containing the elements
{1, 2, . . . , n} has the most and the least number of
inversions, respectively?
(A) Most: {1, 2, . . . , n}, Least: {1, 2, . . . , n}
(B) Most: {1, 2, . . . , n}, Least: {n, n − 1, . . . , 1}
(C) Most: {n, n − 1, . . . , 1}, Least: {1, 2, . . . , n}
(D) Most: {n, n − 1, . . . , 1}, Least: {n, n − 1, . . . , 1}
(E) None of the above
6. Identify the equivalent postfix representation for the
following infix expression: A + B ∗ C + D
(A) AB + CD + ∗
(B) ABCD + +∗
(C) ABCD + ∗+
(D) ABC ∗ +D+
(E) None of the above
7. Evaluate the postfix expression: 2 3 ∗ 4 5 ∗ +
(A) 36
(B) 50
(C) 70
(D) 120
(E) None of the above
8. Identify the correct statement.
(A) Matrix multiplication of two n×n matrices can
be done in O(n3
) time.
(B) Matrix multiplication of two n×n matrices can
be done in O(n2
) time.
(C) Matrix multiplication of two n×n matrices can
be done in O(n) time.
(D) All of the above
(E) None of the above
2
9. Which of the following sorting algorithms has the
fastest possible best-case time complexity for n ele-
ments?
(A) Selection sort (without using an auxiliary array)
(B) Selection sort (using an auxiliary array)
(C) Insertion sort
(D) Both A and B
(E) All of the above
10. The worst-case time complexity for searching an el-
ement from a set of n sorted elements using binary
search algorithm is
(A) O(log n)
(B) O((log n)
2
)
(C) O(log log n)
(D) O(1)
(E) None of the above
11. Consider the sorted array declared by “int A[9]={1,
2, 3, 4, 5, 6, 7, 8, 9};”. What is the number of
comparisons (between elements) required to find the
element 7 using binary search? Note that mid =
⌊low+high
2 ⌋.
(A) 2
(B) 3
(C) 4
(D) 5
(E) 9
12. Consider the array declared by “int A[9]={9, 8, 7, 6,
5, 4, 3, 2, 1};”. What is the number of comparisons
(between elements) required to find the element 7
using linear search, starting from the beginning of
the array?
(A) 2
(B) 3
(C) 4
(D) 5
(E) 9
13. Suppose we have some distinct numbers between 1
and 1000 stored in a sorted array, and we want to
search the number 500 using binary search. Which
of the following is a valid binary search sequence?
(A) 100, 400, 300, 600, 500
(B) 400, 800, 700, 600, 500
(C) 200, 100, 600, 800, 500
(D) 300, 900, 700, 800, 500
(E) None of the above
14. Assume A to be an array of integers (e.g., “int A[5]
= {1, 2, 3, 4, 5};”). Indicating equivalence by ‘≡’,
which of the following statements is incorrect?
(A) A[i] ≡ ∗(A + i)
(B) A ≡ &A[0]
(C) &A[i] ≡ A + i
(D) (i − j) ≡ (&A[i] − &A[j])
(E) None of the above
15. Identify the data structure (among the following
ones) that consumes the highest amount of space
to store a set of n integers. Assume that n is large.
[Note: Consider the most space-efficient implemen-
tation of each data structure.]
(A) One-dimensional array
(B) Singly linked-list
(C) Doubly linked-list
(D) Stack
(E) Queue
16. What will be the output for the code segment below?
#include <stdio.h>
int main ()
{
int a[] = {10, 20, 30, 40, 50};
int i;
for(i=0; i<5; ++i)
printf("%d,", *(a+i));
printf("n");
return 0;
}
(A) 10, 10, 10, 10, 10,
(B) 10, 20, 30, 40,
(C) 10, 20, 30, 40, 50,
(D) Garbage values
(E) None of the above
17. What will be the output for the code segment below?
#include <stdio.h>
int main ()
{
int a[3][3] = {1,2,3,4,5,6,7,8,9};
int *ptr [3] = {a[0],a[1],a[2]};
int i;
for(i=0; i<3; ++i)
printf("%d,", *ptr[i]);
return 0;
}
(A) 1, 1, 1,
(B) 1, 2, 3,
(C) 1, 4, 7,
(D) Garbage values
(E) None of the above
3
18. What will be the output for the code segment below?
#include <stdio.h>
typedef struct {
int i;
float f;
} values;
int main ()
{
values var ={555 , 67.05501};
printf("%d ,%.2f", var.i, var.f);
return 0;
}
(A) 555, 67
(B) 555, 67.06
(C) 555, 67.05
(D) 555, 67.05501
(E) None of the above
19. The output of the following code segment is
0x7fff70b4e3b0, . Choose the correct option
for filling up the blank.
#include <stdio.h>
void main ()
{
int a[5] = {10, 20, 30, 40, 50};
printf("%p,%pn", a, &a);
}
(A) 0x7fff70b4e3b0
(B) 10
(C) Address of the location containing
0x7fff70b4e3b0
(D) Compile time error
(E) None of the above
20. Given an array A = {10, 30, 40, 50, 20}, calculate the
number of swap operations required to sort the ele-
ments in an increasing order using Bubble sort.
(A) 1
(B) 2
(C) 3
(D) 4
(E) 5
21. Given an array A = {10, 20, 30, 40, 50}, calculate the
number of comparisons (between elements) required
to sort the elements in an increasing order using the
most efficient implementation (one that requires the
minimum number of comparisons in the best-case)
of Bubble sort.
(A) 0
(B) 4
(C) 5
(D) 9
(E) 10
22. The following program will create a file file.txt.
What will be the content of the file.txt after the
execution of the program?
#include <stdio.h>
int main ()
{
FILE *fp;
fp = fopen("file.txt","w+");
fputs("abcdef", fp);
fseek(fp , -2, 1);
fputs("pqrst", fp);
fclose(fp);
return (0);
}
(A) abcdefpqrst
(B) abcdepqrst
(C) abcdefqrst
(D) abcdpqrst
(E) None of the above
23. What will be the output for the code segment below?
#include <stdio.h>
#include <string.h>
int main ()
{
char str1 [15];
char str2 [15];
int ret;
strcpy(str1 , "aAbBcC");
strcpy(str2 , "aABbcC");
ret = strcmp(str1 , str2 );
if(ret > 0)
printf("str2 <str1");
else if(ret < 0)
printf("str1 <str2");
else
printf("str1=str2");
return (0);
}
(A) str2<str1
(B) str1<str2
(C) str1=str2
(D) Compile time error
(E) None of the above
24. Given an array A = {40, 30, 10, 50, 20}, calculate the
number of swap operations required to sort the el-
ements in an increasing order using Selection sort
that requires O(1) (constant) worst-case space com-
plexity, i.e., does not use an auxiliary array.
(A) 1
(B) 2
(C) 3
(D) 4
(E) 5
4
25. Given an array A = {10, 20, 30, 40, 50}, calculate the
number of comparisons (between elements) required
to sort the elements in an increasing order using in-
sertion sort.
(A) 0
(B) 4
(C) 5
(D) 9
(E) 10
26. Consider an array A = {329, 457, 657, 839, 436, 720,
355}, which we are trying to sort using radix sort
starting from the least significant digit, using 3 it-
erations. What would be the order of the elements
after the second iteration?
(A) {720, 355, 436, 457, 657, 329, 839}
(B) {720, 329, 436, 839, 355, 457, 657}
(C) {720, 329, 436, 839, 457, 355, 657}
(D) {720, 329, 839, 436, 457, 355, 657}
(E) None of the above
27. Which of the following sorting algorithms is stable?
(A) Insertion sort
(B) Bubble sort
(C) Counting Sort
(D) All of the above
(E) None of the above.
28. Consider an empty stack S in which the follow-
ing sequence of operations are performed: Push(4),
Push(6), Pop(), Push(8), Push(9), Push(1),
Push(2), Pop().
Which of the elements are present in the stack after
the above operations?
(A) 4, 6, 8, 9
(B) 4, 8, 9, 1
(C) 8, 9, 1, 2
(D) 6, 8, 9, 1
(E) None of the above
29. Consider an empty queue Q in which the following
sequence of operations are performed: Enqueue(4),
Enqueue(6), Dequeue(), Enqueue(8), Enqueue(9),
Enqueue(1), Enqueue(2), Dequeue().
Which of the elements are present in the queue after
the above operations?
(A) 4, 6, 8, 9
(B) 4, 8, 9, 1
(C) 8, 9, 1, 2
(D) 6, 8, 9, 1
(E) None of the above
30. What will be the output for the code segment below?
#include <stdio.h>
void swap1(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
void swap2(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main ()
{
int i=10, j=20, k=30, l=40;
swap1(i, j);
swap2 (&k, &l);
printf("%d,%d,%d,%dn",i,j,k,l);
}
(A) 10, 20, 30, 40
(B) 20, 10, 30, 40
(C) 10, 20, 40, 30
(D) 20, 10, 40, 30
(E) None of the above
31. Consider a singly linked list L in which every node
(structure) consists of two members. The first mem-
ber is an integer data d. Identify the correct data
type for the second member.
(A) Integer
(B) Pointer to an integer
(C) Pointer to a pointer to an integer
(D) Pointer to a node
(E) None of the above
32. Identify the number of bytes required to store the
string “This is an easy question” in a C program.
(A) 20
(B) 21
(C) 24
(D) 25
(E) None of the above
33. Given an integer array declared by “int A[3][5];”,
which of the following statements does not repre-
sent the element A[2][3]?
(A) (∗(A[2] + 3))
(B) (∗(A + 2))[3]
(C) (∗((∗(A + 2)) + 3))
(D) (A[2] + 3)
(E) None of the above
5
34. Given an integer array declared by
“int A[ ] = {2, 4, 6, 8, 3};”, what is the value of
A[A[1]]?
(A) 2
(B) 4
(C) 6
(D) 8
(E) 3
35. Identify the 2’s complement representation of the
negative integer −127, using 8 bits.
(A) 10000001
(B) 11111111
(C) 01111111
(D) 10000000
(E) None of the above
36. The number of 1’s in the binary representation of
the integer 13 ∗ 163
+ 11 ∗ 162
+ 9 ∗ 16 + 3 is:
(A) 7
(B) 8
(C) 9
(D) 10
(E) None of the above
37. Given an integer array declared by “int A[10];”, what
is the value of ((&A[2])−(&A[6]))? Assume that an
integer takes 4 bytes.
(A) −4
(B) −16
(C) 4
(D) 16
(E) None of the above
38. If two pointers p1 and p2 are declared by “int *p1,
*p2;”, identify the invalid statements.
(A) p1 = p1 + 2;
(B) p1 = p1 − 2;
(C) p1 = p1 ∗ 2;
(D) int i = p1 − p2;
(E) None of the above
39. Consider a singly linked-list with a head and a tail
pointer (i.e., pointers to the first and last node in the
list). Given this representation, which of the follow-
ing operations can not be implemented in constant
time (i.e., O(1) time)?
(A) Insert an item at the front of the list
(B) Insert an item at the rear of the list
(C) Delete the front item from the list
(D) Delete the rear item from the list
(E) None of the above
40. Consider the following code segment. Identify the
invalid statement to assign a value to member1.
#include <stdio.h>
struct test{
int member1;
} var;
void main ()
{
struct test *ptr=&var;
/* identify the invalid statement.*/
}
(A) (*ptr).member1=5;
(B) *ptr.member1=5;
(C) (ptr)->member1=5;
(D) ptr->member1=5;
(E) None of the above
41. In C programming, the return type of a malloc()
function is
(A) An integer
(B) A void pointer
(C) A pointer to an integer
(D) Pointer to an array
(E) None of the above
42. What is the equivalent pointer expression for refer-
ring the array element A[i][j][k][l] in an integer array
A[10][10][10][10]?
(A) ((((A+i)+j)+k)+l)
(B) (*(*(*(*(A+i)+j)+k)+l))
(C) (((A+i)+j)+k+l)
(D) ((A+i)+j+k+l)
(E) None of the above
43. In C programming, the size of a union is determined
by the size of the .
(A) First member in the union
(B) Last member in the union
(C) Maximum-sized member in the union
(D) Sum of the sizes of all members
(E) None of the above
44. The C syntax for command-line argument is “int
main(int argc, char *argv[ ])”. What is indicated by
argv[0] in command-line arguments?
(A) The name by which the program is invoked
(B) The name of the files which are passed to the
program
(C) Count of the arguments in argv[ ] vector
(D) Both A and B
(E) None of the above
6
45. In C programming, the size of a structure is deter-
mined by the size of the , excluding the slack
bytes.
(A) First member in the structure
(B) Last member in the structure
(C) Maximum-sized member in the structure
(D) Sum of the sizes of all members
(E) None of the above
46. The deletion of a node can always be done in con-
stant (i.e., O(1)) time from a linked list with n nodes
if .
(A) The linked list is singly and the element stored
in the node to be deleted is given
(B) The linked list is singly and the pointer to the
node to be deleted is given
(C) The linked list is doubly and the element stored
in the node to be deleted is given
(D) The linked list is doubly and the pointer to the
node to be deleted is given
(E) None of the above
47. In C programming, identify the valid declaration of
a three-dimensional array.
(A) int A[ ][2][2]={2,2,2,2};
(B) int A[ ][ ][2]={2,2,2,2};
(C) int A[2][2][ ]={2,2,2,2};
(D) Both A and B
(E) Both A and C
48. Which of the following code segments is invalid?
(A) int A[20]; printf(“%p”, A+1);
(B) int A[20]; printf(“%p”, (&A)+1);
(C) int A[20]; printf(“%p”, (&(&A)+1));
(D) Both B and C
(E) None of the above
49. Consider the C code below. How many ‘*’ will be
printed by the following program?
#include <stdio.h>
void quiz(int i)
{
if (i > 1)
{
quiz(i / 2);
quiz(i / 2);
}
printf("*");
}
void main ()
{
quiz (5);
}
(A) 3
(B) 5
(C) 7
(D) 9
(E) None of the above
50. Consider the C code below. How many ‘*’ will be
printed by the following program?
#include <stdio.h>
void quiz(int i)
{
if (i > 1)
{
quiz(i % 2);
quiz(i / 2);
}
printf("*");
}
void main ()
{
quiz (6);
}
(A) 3
(B) 4
(C) 6
(D) 7
(E) None of the above

More Related Content

PDF
GATE Computer Science Solved Paper 2004
PDF
Introduction to NumPy for Machine Learning Programmers
PPT
PDF
Numpy tutorial(final) 20160303
DOCX
Array
PDF
AP PGECET Computer Science 2016 question paper
PPT
GATE Computer Science Solved Paper 2004
Introduction to NumPy for Machine Learning Programmers
Numpy tutorial(final) 20160303
Array
AP PGECET Computer Science 2016 question paper

What's hot (18)

PPTX
18. Java associative arrays
PDF
Gate-Cs 2009
PPTX
19. Java data structures algorithms and complexity
PPTX
Finding root of equation (numarical method)
PDF
M|18 User Defined Functions
PPT
Chapter2
PDF
11 1. multi-dimensional array eng
PDF
Funções 4
PPTX
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
KEY
Numpy Talk at SIAM
PPTX
07. Arrays
PPT
Arrays
DOCX
Data Structure Project File
PPTX
16. Arrays Lists Stacks Queues
PPT
Sparse Matrix and Polynomial
PDF
Intoduction to numpy
18. Java associative arrays
Gate-Cs 2009
19. Java data structures algorithms and complexity
Finding root of equation (numarical method)
M|18 User Defined Functions
Chapter2
11 1. multi-dimensional array eng
Funções 4
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Numpy Talk at SIAM
07. Arrays
Arrays
Data Structure Project File
16. Arrays Lists Stacks Queues
Sparse Matrix and Polynomial
Intoduction to numpy
Ad

Similar to Cs101 endsem 2014 (20)

PDF
Gate-Cs 1999
PDF
Gate-Cs 2006
PDF
Ee693 sept2014midsem
PDF
ComputerScience-SQP.pdffhtu h kya hua hai ap ka school
PDF
Computer science ms
PDF
Gate Computer Science Solved Paper 2007
PDF
Gate-Cs 1996
PDF
Ee693 questionshomework
PDF
09 a1ec01 c programming and data structures
PDF
MATLAB Questions and Answers.pdf
PDF
Gate Previous Years Papers
PDF
selfstudys_com_file (4).pdfjsjdcjjsjxjdnxjj
PDF
Gate-Cs 1998
PPTX
Programming data structure concept in array ppt
PPTX
Technical aptitude test 2 CSE
PPTX
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
PDF
Revision1schema C programming
PDF
Doc 20180130-wa0006
DOCX
(Www.entrance exam.net)-tcs placement sample paper 2
Gate-Cs 1999
Gate-Cs 2006
Ee693 sept2014midsem
ComputerScience-SQP.pdffhtu h kya hua hai ap ka school
Computer science ms
Gate Computer Science Solved Paper 2007
Gate-Cs 1996
Ee693 questionshomework
09 a1ec01 c programming and data structures
MATLAB Questions and Answers.pdf
Gate Previous Years Papers
selfstudys_com_file (4).pdfjsjdcjjsjxjdnxjj
Gate-Cs 1998
Programming data structure concept in array ppt
Technical aptitude test 2 CSE
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Revision1schema C programming
Doc 20180130-wa0006
(Www.entrance exam.net)-tcs placement sample paper 2
Ad

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
PPT on Performance Review to get promotions
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Well-logging-methods_new................
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Sustainable Sites - Green Building Construction
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Digital Logic Computer Design lecture notes
R24 SURVEYING LAB MANUAL for civil enggi
CH1 Production IntroductoryConcepts.pptx
Construction Project Organization Group 2.pptx
PPT on Performance Review to get promotions
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Model Code of Practice - Construction Work - 21102022 .pdf
Internet of Things (IOT) - A guide to understanding
Well-logging-methods_new................
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Automation-in-Manufacturing-Chapter-Introduction.pdf
Digital Logic Computer Design lecture notes

Cs101 endsem 2014

  • 1. 1 End Semester Examination Introduction to Computing (CS 101) IIT Guwahati April 29, 2014 Duration: 3 Hours Instructions: (1) Encircle the answer (A/B/C/D/E) in the space provided in the answer script. (2) Each question has exactly one correct answer. (3) There are a total of 50 questions. Each question carries two marks. (4) Negative Marking: Each wrong answer will be penalised by 1 2 negative marks. (5) Please write your name and roll number on both the question paper and the answer script. (6) Possession of either a mobile phone or a calculator is strictly prohibited during the exam. (7) No doubts will be entertained during the exam. (8) There are 6 pages of questions and 2 pages for rough work in the question paper. Please contact the invigilator, if otherwise. Name: Roll No: 1. The conversion of a program from some high-level programming language to machine language (object code) is done by a . (A) Compiler (B) Loader (C) Linker (D) All of the above (E) None of the above 2. Which of the following is not a storage device? (A) Hard Disk (B) CD ROM (C) Keyboard (D) Floppy Disk (E) None of the above 3. In C programming, the name of an array indicates the . (A) Address of the first element of the array (B) First element of the array (C) Number of elements in the array (D) Data type of the elements stored in the array (E) None of the above 4. Which of these data types is used by an operating system to manage the recursion in C programming? (A) Stack (B) Queue (C) Linked List (D) Array (E) None of the above 5. Let A be an array containing n distinct integers. If i < j and A[i] > A[j], then the pair (i, j) is called an inversion of A. Which array containing the elements {1, 2, . . . , n} has the most and the least number of inversions, respectively? (A) Most: {1, 2, . . . , n}, Least: {1, 2, . . . , n} (B) Most: {1, 2, . . . , n}, Least: {n, n − 1, . . . , 1} (C) Most: {n, n − 1, . . . , 1}, Least: {1, 2, . . . , n} (D) Most: {n, n − 1, . . . , 1}, Least: {n, n − 1, . . . , 1} (E) None of the above 6. Identify the equivalent postfix representation for the following infix expression: A + B ∗ C + D (A) AB + CD + ∗ (B) ABCD + +∗ (C) ABCD + ∗+ (D) ABC ∗ +D+ (E) None of the above 7. Evaluate the postfix expression: 2 3 ∗ 4 5 ∗ + (A) 36 (B) 50 (C) 70 (D) 120 (E) None of the above 8. Identify the correct statement. (A) Matrix multiplication of two n×n matrices can be done in O(n3 ) time. (B) Matrix multiplication of two n×n matrices can be done in O(n2 ) time. (C) Matrix multiplication of two n×n matrices can be done in O(n) time. (D) All of the above (E) None of the above
  • 2. 2 9. Which of the following sorting algorithms has the fastest possible best-case time complexity for n ele- ments? (A) Selection sort (without using an auxiliary array) (B) Selection sort (using an auxiliary array) (C) Insertion sort (D) Both A and B (E) All of the above 10. The worst-case time complexity for searching an el- ement from a set of n sorted elements using binary search algorithm is (A) O(log n) (B) O((log n) 2 ) (C) O(log log n) (D) O(1) (E) None of the above 11. Consider the sorted array declared by “int A[9]={1, 2, 3, 4, 5, 6, 7, 8, 9};”. What is the number of comparisons (between elements) required to find the element 7 using binary search? Note that mid = ⌊low+high 2 ⌋. (A) 2 (B) 3 (C) 4 (D) 5 (E) 9 12. Consider the array declared by “int A[9]={9, 8, 7, 6, 5, 4, 3, 2, 1};”. What is the number of comparisons (between elements) required to find the element 7 using linear search, starting from the beginning of the array? (A) 2 (B) 3 (C) 4 (D) 5 (E) 9 13. Suppose we have some distinct numbers between 1 and 1000 stored in a sorted array, and we want to search the number 500 using binary search. Which of the following is a valid binary search sequence? (A) 100, 400, 300, 600, 500 (B) 400, 800, 700, 600, 500 (C) 200, 100, 600, 800, 500 (D) 300, 900, 700, 800, 500 (E) None of the above 14. Assume A to be an array of integers (e.g., “int A[5] = {1, 2, 3, 4, 5};”). Indicating equivalence by ‘≡’, which of the following statements is incorrect? (A) A[i] ≡ ∗(A + i) (B) A ≡ &A[0] (C) &A[i] ≡ A + i (D) (i − j) ≡ (&A[i] − &A[j]) (E) None of the above 15. Identify the data structure (among the following ones) that consumes the highest amount of space to store a set of n integers. Assume that n is large. [Note: Consider the most space-efficient implemen- tation of each data structure.] (A) One-dimensional array (B) Singly linked-list (C) Doubly linked-list (D) Stack (E) Queue 16. What will be the output for the code segment below? #include <stdio.h> int main () { int a[] = {10, 20, 30, 40, 50}; int i; for(i=0; i<5; ++i) printf("%d,", *(a+i)); printf("n"); return 0; } (A) 10, 10, 10, 10, 10, (B) 10, 20, 30, 40, (C) 10, 20, 30, 40, 50, (D) Garbage values (E) None of the above 17. What will be the output for the code segment below? #include <stdio.h> int main () { int a[3][3] = {1,2,3,4,5,6,7,8,9}; int *ptr [3] = {a[0],a[1],a[2]}; int i; for(i=0; i<3; ++i) printf("%d,", *ptr[i]); return 0; } (A) 1, 1, 1, (B) 1, 2, 3, (C) 1, 4, 7, (D) Garbage values (E) None of the above
  • 3. 3 18. What will be the output for the code segment below? #include <stdio.h> typedef struct { int i; float f; } values; int main () { values var ={555 , 67.05501}; printf("%d ,%.2f", var.i, var.f); return 0; } (A) 555, 67 (B) 555, 67.06 (C) 555, 67.05 (D) 555, 67.05501 (E) None of the above 19. The output of the following code segment is 0x7fff70b4e3b0, . Choose the correct option for filling up the blank. #include <stdio.h> void main () { int a[5] = {10, 20, 30, 40, 50}; printf("%p,%pn", a, &a); } (A) 0x7fff70b4e3b0 (B) 10 (C) Address of the location containing 0x7fff70b4e3b0 (D) Compile time error (E) None of the above 20. Given an array A = {10, 30, 40, 50, 20}, calculate the number of swap operations required to sort the ele- ments in an increasing order using Bubble sort. (A) 1 (B) 2 (C) 3 (D) 4 (E) 5 21. Given an array A = {10, 20, 30, 40, 50}, calculate the number of comparisons (between elements) required to sort the elements in an increasing order using the most efficient implementation (one that requires the minimum number of comparisons in the best-case) of Bubble sort. (A) 0 (B) 4 (C) 5 (D) 9 (E) 10 22. The following program will create a file file.txt. What will be the content of the file.txt after the execution of the program? #include <stdio.h> int main () { FILE *fp; fp = fopen("file.txt","w+"); fputs("abcdef", fp); fseek(fp , -2, 1); fputs("pqrst", fp); fclose(fp); return (0); } (A) abcdefpqrst (B) abcdepqrst (C) abcdefqrst (D) abcdpqrst (E) None of the above 23. What will be the output for the code segment below? #include <stdio.h> #include <string.h> int main () { char str1 [15]; char str2 [15]; int ret; strcpy(str1 , "aAbBcC"); strcpy(str2 , "aABbcC"); ret = strcmp(str1 , str2 ); if(ret > 0) printf("str2 <str1"); else if(ret < 0) printf("str1 <str2"); else printf("str1=str2"); return (0); } (A) str2<str1 (B) str1<str2 (C) str1=str2 (D) Compile time error (E) None of the above 24. Given an array A = {40, 30, 10, 50, 20}, calculate the number of swap operations required to sort the el- ements in an increasing order using Selection sort that requires O(1) (constant) worst-case space com- plexity, i.e., does not use an auxiliary array. (A) 1 (B) 2 (C) 3 (D) 4 (E) 5
  • 4. 4 25. Given an array A = {10, 20, 30, 40, 50}, calculate the number of comparisons (between elements) required to sort the elements in an increasing order using in- sertion sort. (A) 0 (B) 4 (C) 5 (D) 9 (E) 10 26. Consider an array A = {329, 457, 657, 839, 436, 720, 355}, which we are trying to sort using radix sort starting from the least significant digit, using 3 it- erations. What would be the order of the elements after the second iteration? (A) {720, 355, 436, 457, 657, 329, 839} (B) {720, 329, 436, 839, 355, 457, 657} (C) {720, 329, 436, 839, 457, 355, 657} (D) {720, 329, 839, 436, 457, 355, 657} (E) None of the above 27. Which of the following sorting algorithms is stable? (A) Insertion sort (B) Bubble sort (C) Counting Sort (D) All of the above (E) None of the above. 28. Consider an empty stack S in which the follow- ing sequence of operations are performed: Push(4), Push(6), Pop(), Push(8), Push(9), Push(1), Push(2), Pop(). Which of the elements are present in the stack after the above operations? (A) 4, 6, 8, 9 (B) 4, 8, 9, 1 (C) 8, 9, 1, 2 (D) 6, 8, 9, 1 (E) None of the above 29. Consider an empty queue Q in which the following sequence of operations are performed: Enqueue(4), Enqueue(6), Dequeue(), Enqueue(8), Enqueue(9), Enqueue(1), Enqueue(2), Dequeue(). Which of the elements are present in the queue after the above operations? (A) 4, 6, 8, 9 (B) 4, 8, 9, 1 (C) 8, 9, 1, 2 (D) 6, 8, 9, 1 (E) None of the above 30. What will be the output for the code segment below? #include <stdio.h> void swap1(int a, int b) { int temp; temp = a; a = b; b = temp; } void swap2(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } void main () { int i=10, j=20, k=30, l=40; swap1(i, j); swap2 (&k, &l); printf("%d,%d,%d,%dn",i,j,k,l); } (A) 10, 20, 30, 40 (B) 20, 10, 30, 40 (C) 10, 20, 40, 30 (D) 20, 10, 40, 30 (E) None of the above 31. Consider a singly linked list L in which every node (structure) consists of two members. The first mem- ber is an integer data d. Identify the correct data type for the second member. (A) Integer (B) Pointer to an integer (C) Pointer to a pointer to an integer (D) Pointer to a node (E) None of the above 32. Identify the number of bytes required to store the string “This is an easy question” in a C program. (A) 20 (B) 21 (C) 24 (D) 25 (E) None of the above 33. Given an integer array declared by “int A[3][5];”, which of the following statements does not repre- sent the element A[2][3]? (A) (∗(A[2] + 3)) (B) (∗(A + 2))[3] (C) (∗((∗(A + 2)) + 3)) (D) (A[2] + 3) (E) None of the above
  • 5. 5 34. Given an integer array declared by “int A[ ] = {2, 4, 6, 8, 3};”, what is the value of A[A[1]]? (A) 2 (B) 4 (C) 6 (D) 8 (E) 3 35. Identify the 2’s complement representation of the negative integer −127, using 8 bits. (A) 10000001 (B) 11111111 (C) 01111111 (D) 10000000 (E) None of the above 36. The number of 1’s in the binary representation of the integer 13 ∗ 163 + 11 ∗ 162 + 9 ∗ 16 + 3 is: (A) 7 (B) 8 (C) 9 (D) 10 (E) None of the above 37. Given an integer array declared by “int A[10];”, what is the value of ((&A[2])−(&A[6]))? Assume that an integer takes 4 bytes. (A) −4 (B) −16 (C) 4 (D) 16 (E) None of the above 38. If two pointers p1 and p2 are declared by “int *p1, *p2;”, identify the invalid statements. (A) p1 = p1 + 2; (B) p1 = p1 − 2; (C) p1 = p1 ∗ 2; (D) int i = p1 − p2; (E) None of the above 39. Consider a singly linked-list with a head and a tail pointer (i.e., pointers to the first and last node in the list). Given this representation, which of the follow- ing operations can not be implemented in constant time (i.e., O(1) time)? (A) Insert an item at the front of the list (B) Insert an item at the rear of the list (C) Delete the front item from the list (D) Delete the rear item from the list (E) None of the above 40. Consider the following code segment. Identify the invalid statement to assign a value to member1. #include <stdio.h> struct test{ int member1; } var; void main () { struct test *ptr=&var; /* identify the invalid statement.*/ } (A) (*ptr).member1=5; (B) *ptr.member1=5; (C) (ptr)->member1=5; (D) ptr->member1=5; (E) None of the above 41. In C programming, the return type of a malloc() function is (A) An integer (B) A void pointer (C) A pointer to an integer (D) Pointer to an array (E) None of the above 42. What is the equivalent pointer expression for refer- ring the array element A[i][j][k][l] in an integer array A[10][10][10][10]? (A) ((((A+i)+j)+k)+l) (B) (*(*(*(*(A+i)+j)+k)+l)) (C) (((A+i)+j)+k+l) (D) ((A+i)+j+k+l) (E) None of the above 43. In C programming, the size of a union is determined by the size of the . (A) First member in the union (B) Last member in the union (C) Maximum-sized member in the union (D) Sum of the sizes of all members (E) None of the above 44. The C syntax for command-line argument is “int main(int argc, char *argv[ ])”. What is indicated by argv[0] in command-line arguments? (A) The name by which the program is invoked (B) The name of the files which are passed to the program (C) Count of the arguments in argv[ ] vector (D) Both A and B (E) None of the above
  • 6. 6 45. In C programming, the size of a structure is deter- mined by the size of the , excluding the slack bytes. (A) First member in the structure (B) Last member in the structure (C) Maximum-sized member in the structure (D) Sum of the sizes of all members (E) None of the above 46. The deletion of a node can always be done in con- stant (i.e., O(1)) time from a linked list with n nodes if . (A) The linked list is singly and the element stored in the node to be deleted is given (B) The linked list is singly and the pointer to the node to be deleted is given (C) The linked list is doubly and the element stored in the node to be deleted is given (D) The linked list is doubly and the pointer to the node to be deleted is given (E) None of the above 47. In C programming, identify the valid declaration of a three-dimensional array. (A) int A[ ][2][2]={2,2,2,2}; (B) int A[ ][ ][2]={2,2,2,2}; (C) int A[2][2][ ]={2,2,2,2}; (D) Both A and B (E) Both A and C 48. Which of the following code segments is invalid? (A) int A[20]; printf(“%p”, A+1); (B) int A[20]; printf(“%p”, (&A)+1); (C) int A[20]; printf(“%p”, (&(&A)+1)); (D) Both B and C (E) None of the above 49. Consider the C code below. How many ‘*’ will be printed by the following program? #include <stdio.h> void quiz(int i) { if (i > 1) { quiz(i / 2); quiz(i / 2); } printf("*"); } void main () { quiz (5); } (A) 3 (B) 5 (C) 7 (D) 9 (E) None of the above 50. Consider the C code below. How many ‘*’ will be printed by the following program? #include <stdio.h> void quiz(int i) { if (i > 1) { quiz(i % 2); quiz(i / 2); } printf("*"); } void main () { quiz (6); } (A) 3 (B) 4 (C) 6 (D) 7 (E) None of the above