Basic Concept and Introduction to Data structure | Savitribai Public University Data Structure MCQ | SPPU Data Structure MCQ | Data Structure
Basic Concept and Introduction to Data structure
1. The word ____________comes from the name of a Persian
mathematician Abu Ja’far Mohammed ibn-i Musa al Khowarizmi.
a) Flowchart b) Flow
c) Algorithm d) Syntax
Answer: c) Algorithm
2. In computer science, algorithm refers to a special method
usable by a computer for the solution to a problem.
a) True b) False
c. Maybe d. None of the above
Answer: a) True
3. Which of the following is incorrect? Algorithms can be
represented:
a) as pseudo codes b) as syntax
c) as programs d) as
flowcharts
Answer: b) as syntax
4. When an algorithm
is written in the form of a programming language, it becomes a _________
a) Flowchart b) Program
c) Pseudo code d) Syntax
Answer: b) Program
5. Any algorithm is a program.
a) True b) False
c. Maybe d. None of the above
Answer: b) False
6. In computer science, algorithm refers to a pictorial
representation of a flowchart.
a) True b) False
c. Maybe d. None of the above
Answer: b) False
7. The process of drawing a flowchart for an algorithm is
called __________
a) Performance b)
Evaluation
c) Algorithmic Representation d) Flowcharting
Answer: d)
Flowcharting
8. Which of the following header files must necessarily be
included to use dynamic memory allocation functions?
a) stdlib.h b) stdio.h
c) memory.h d) dos.h
Answer: a) stdlib.h
9. In the function malloc(), each byte of allocated space is
initialized to zero.
a) True b) False
c. Maybe d. None of the above
Answer: b) False
10. Which of the following functions allocates multiple
blocks of memory, each block of the same size?
a) malloc() b) realloc()
c) calloc() d) free()
Answer: c) calloc()
11. A condition where in memory is reserved dynamically but
not accessible to any of the programs is called _____________
a) Memory leak b) Dangling pointer
c) Frozen memory d) Pointer leak
Answer: a) Memory
leak
12. The incorrect statement with respect to dangling
pointers is ___________
a) Pointer pointing to non-existent
memory location is called dangling pointer
b) When a dynamically allocated
pointer references the original memory after it has been freed, a dangling
pointer arises
c) If memory leak occurs, it is
mandatory that a dangling pointer arises
d) Dangling pointer may result in
segmentation faults and potential security risks
Answer: c) If memory leak occurs, it is
mandatory that a dangling pointer arises
13. In the function realloc(), if the new size of the memory
block is larger than the old size, then the added memory ___________
a) is initialized to junk values b) is initialized to zero
c) results in an error d) is not
initialized
Answer: d) is not
initialized
14. The free() function frees the memory state pointed to by
a pointer and returns ___________
a) the same pointer b) the memory address
c) no value d) an integer value
Answer: c) no value
15. The number of arguments taken as input which allocating
memory dynamically using malloc() is ___________
a) 0 b) 1
c) 2 d) 3
Answer: b) 1
16. Suppose we have a one dimensional array, named ‘x’,
which contains 10 integers. Which of the following is the correct way to
allocate memory dynamically to the array ‘x’ using malloc()?
a) x=(int*)malloc(10); b)
x=(int*)malloc(10,sizeof(int));
c) x=malloc(int 10,sizeof(int)); d) x=(int*)malloc(10*sizeof(int));
Answer: d)
x=(int*)malloc(10*sizeof(int));
17. If malloc() and calloc() are not type casted, the
default return type is ___________
a) void* b) void**
c) int* d) char*
Answer: a) void*
18. When the pointer is NULL, then the function realloc is
equivalent to the function ___________
a) malloc b) calloc
c) free d) alloc
Answer: a) malloc
19. Garbage collector frees the programmer from worrying
about ___________
a) Dangling pointers b) Creating new objects
c) Memory leak d) Segmentation
errors
Answer: c) Memory
leak
20. If the space in memory allocated by malloc is not
sufficient, then an allocation fails and returns ___________
a) NULL pointer b) Zero
c) Garbage value d) The number of bytes available
Answer: a) NULL
pointer
21. Among 4 header files, which should be included to use
the memory allocation functions like malloc(), calloc(), realloc() and free()?
A. #include B. #include
C. #include D. Both b and c
Answer: B. #include
22. Which of the following is/are true
A. calloc() allocates the memory
and also initializes the allocates memory to zero, while memory allocated using
malloc() has random data.
B. malloc() and memset() can be
used to get the same effect as calloc()
C. Both malloc() and calloc()
return 'void *' pointer
D. All of the above
Answer: D. All of the
above
23. Which of the following statement is correct prototype of
the malloc() function in c ?
A. int* malloc(int); B.
Char* malloc(char);
C. unsigned int* malloc(unsigned
int); D. void* malloc(size_t);
Answer: D. void*
malloc(size_t);
24. Specify the 2 library functions to dynamically allocate
memory?
A. malloc() and memalloc() B. alloc() and memalloc()
C. malloc() and calloc() D. memalloc() and faralloc()
Answer: C. malloc()
and calloc()
25. malloc() returns a float pointer if memory is allocated
for storing float's and a double pointer if memory is allocated for storing
double's. A.
A. TRUE B. FALSE
C. May Be D.
Can't Say
Answer : B. FALSE
26. malloc() allocates memory from the heap and not from the
stack.
A. TRUE B. FALSE
C. May Be D. Can't Say
Answer: A. TRUE
27. What is wild pointer?
A. Pointer which is wild in nature B. Pointer which has no value.
C. Pointer which is not initialized
D. None
Answer: C. Pointer
which is not initialized
28. Address stored in the pointer variable is of type
__________.
A. Integer B. Float
C. Array D. Character
Answer: A. Integer
29. In order to fetch the address of the variable we write
preceding _________ sign before variable name.
A. Percent(%) B. Comma(,)
C. Ampersand(&) D. Asteric(*)
Answer: C.
Ampersand(&)
30.Space complexity of an algorithm is the maximum amount of
_______ required by it during execution.
a.Time b.Operations
c.Memory space d.None of the above
Answer: c.Memory
space
31.Frequently, the memory space required by an algorithm is
a multiple of the size of input. State if the statement is True or False or
Maybe.
a. True b. False
c. Maybe d. None of the above
Answer: a. True
32. An algorithm performs lesser number of operations when
the size of input is small, but performs more operations when the size of input
gets larger. State if the statement is True or False or Maybe.
a. True b. False
c. Maybe d. None of the above
Answer: a. True
33.In the analysis of algorithms, what plays an important
role?
a. Text Analysis b. Growth factor
c. Time d.
None of the above
Answer: b. Growth
factor
34. To verify whether a function grows faster or slower than
the other function, we have some asymptotic or mathematical notations, which
is_________.
a. Big Omega Ω (f) b. Big Theta θ (f)
c. Big Oh O (f) d. All of the above
Answer: d. All of the above
35. An algorithm that indicates the amount of temporary
storage required for running the algorithm, i.e., the amount of memory needed
by the algorithm to run to completion is termed as_____.
a. Big Theta θ (f) b. Space complexity
c. Big Oh O (f) d. None of the above
Answer: b.
Space complexity
36. The amount of time the computer needs to run to
completion is known as_____.
a. Space complexity b. Time complexity
c. Recursive function d. None of the above
Answer: b. Time
complexity
37. ___________algorithm is one which utilizes minimum
processor time and requires minimum memory space during its execution.
a. Best b. Efficient
c. Both (a) and (b) d. None of the above
Answer: c. Both
(a) and (b)
38. What is (void*)0?
A. Representation of NULL pointer B. Representation of void pointer
C. Error D. None
of above
Answer: A. Representation
of NULL pointer
39. If a variable is a pointer to a structure, then which of
the following operator is used to access data members of the structure through
the pointer variable?
A. . B. &
C. * D. ->
Answer: D. ->
40. A pointer is
A. A keyword used to create variables
B. A variable that stores address
of an instruction
C. A variable that stores address
of other variable
D. All of the above
Answer: C. A variable
that stores address of other variable
41.The operator used to get value at address stored in a
pointer variable is
A. * B. &
C. && D. ||
Answer: A. *
42. Choose the correct option about abstract data type(ADT).
a. An abstract data type is a model
of a certain kind of data structure.
b. In abstract data type we know
what a specific data type can do, but how it actually does it is hidden.
c. ADT is user defined type.
d. All of the above.
Answer: All of the
above.
43. Which of these best describes an array?
a) A data structure that shows a
hierarchical behaviour
b) Container of objects of similar
types
c) Arrays are immutable once
initialised
d) Array is not a data structure
Answer: b) Container
of objects of similar types
44. How do you initialize an array in C?
a) intarr[3] = (1,2,3); b) intarr(3) = {1,2,3};
c) intarr[3] = {1,2,3}; d) intarr(3) = (1,2,3);
Answer c) intarr[3] =
{1,2,3};
45. How do you instantiate an array in Java?
a) intarr[] = new int(3); b) intarr[];
c) intarr[] = new int[3]; d) intarr() = new int(3);
Answer: c) intarr[] =
new int[3];
46. Which of the following is a correct way to declare a
multidimensional array in Java?
a) int[] arr; b) intarr[[]];
c) int[][]arr; d) int[[]] arr;
Answer: c)
int[][]arr;
47. A
mathematical-model with a collection of operations defined on that model is
called
A. Data Structure B. Abstract Data Type
C. Primitive Data Type D. Algorithm
Answer: B. Abstract
Data Type
48. Representation of data structure in memory is known as:
A. Recursive B. Abstract
data type
C. Storage structure D. File structure
Answer: B. Abstract
data type
49. Which of the following abstract data types can be used
to represent a many to many relation?
A. Tree B. Plex
C. Graph D. Both (b) and (c)
Answer: D. Both (b) and
(c)
50. When does the ArrayIndexOutOfBounds Exception occur?
a) Compile-time b) Run-time
c) Not an error d) Not an exception at all
Answer: b) Run-time
No comments:
Post a Comment