Computer Knowledge
Data Structures and Algorithms
1,256 Questions
Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.
Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity
Data Structures and Algorithms Questions
-
n
-
nlogn
-
O(nlogn)
-
O(n)
-
None of these
C
Correct answer
Explanation
In computer science, merge sort (also commonly spelled merge sort) is an O(n log n) comparison-based sorting algorithm.
-
Stack
-
Queue
-
Arrays
-
Linked List
-
Tree
E
Correct answer
Explanation
This is the right answer.
-
Queue
-
dqueue
-
Linked List
-
Stack
-
Tree
B
Correct answer
Explanation
This is the correct answer.
-
enhances logical clarity and reduces code size
-
makes debugging easier
-
reduces execution time
-
makes software bug-free
A
Correct answer
Explanation
Recursion enhances logical clarity by expressing solutions in terms of themselves, and it typically reduces code size by eliminating repetitive loops. However, it doesn't necessarily reduce execution time, make debugging easier, or guarantee bug-free software.
-
a list of keys
-
pointers to the master list
-
both (1) and (2)
-
none of the above
C
Correct answer
Explanation
An index in database systems contains both the key values being indexed AND pointers/references to where those records exist in the main data storage. Without either component, the index would be non-functional.
-
int *ptr = (int *) malloc(10, sizeof(int));
-
int *ptr = (int *) calloc(10, sizeof(int));
-
int *ptr = (int *) malloc(10*sizeof(int));
-
int *ptr = (int *) alloc(10*sizeof(int));
-
int *ptr = (int *) calloc(10*sizeof(int));
C
Correct answer
Explanation
malloc(10*sizeof(int)) allocates space for 10 integers. calloc allocates and initializes to zero but takes two arguments (count, size), not one. Option C is the correct malloc syntax. Option B has wrong calloc syntax, and Option E has calloc with single argument which is incorrect.
-
ptr = realloc( ptr, 10 * sizeof( struct customer));
-
realloc( ptr, 9 * sizeof( struct customer ) );
-
ptr += malloc( 9 * sizeof( struct customer ) );
-
ptr = realloc( ptr, 9 * sizeof( struct customer ) );
-
realloc( ptr, 10 * sizeof( struct customer ) );
A
Correct answer
Explanation
realloc resizes memory. To expand ptr to 10 elements: ptr = realloc(ptr, 10 * sizeof(struct customer)). Must assign result back to ptr (realloc may move memory). Option D uses 9 elements instead of 10. Options B and E don't assign return value. Option C is syntactically wrong.
-
memcpy()
-
memset()
-
strncpy()
-
strcpy()
-
memmove()
-
Dynamic data structure
-
Echo check
-
Dynamic allocation
-
Dynamic programming
C
Correct answer
Explanation
Dynamic allocation refers to the process of assigning memory space to a program during its execution (runtime) rather than at compile time. This allows for more flexible and efficient use of system resources.
D
Correct answer
Explanation
Pointer is not a data structure. It is a variable that contains the address of another variable and is not implemented in STL.
-
Pointers
-
Structures
-
Classes
-
Unions
D
Correct answer
Explanation
This is correct as all members share same memory location and the size of union is the size of the largest data element.
-
Random access
-
Bi-directional
-
Linear
-
Output
C
Correct answer
Explanation
There is no iterator by the name linear in C++.
-
Malloc()
-
Calloc()
-
Realloc()
-
Free()
D
Correct answer
Explanation
Malloc, calloc, and realloc are all functions used to request and allocate memory on the heap. Free is the odd one out because its function is to release or deallocate memory that was previously allocated.
-
*(a+5)
-
a[5]
-
pa[5]
-
*(*pa+5)
-
Lattice flow
-
Tree flow
-
Relay flow
-
Communication support
-
Sify my storage
B
Correct answer
Explanation
This type of flow constitutes the classical nested programming structure.