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

Multiple choice
  1. n

  2. nlogn

  3. O(nlogn)

  4. O(n)

  5. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In computer science, merge sort (also commonly spelled merge sort) is an O(n log n) comparison-based sorting algorithm.

Multiple choice
  1. enhances logical clarity and reduces code size

  2. makes debugging easier

  3. reduces execution time

  4. makes software bug-free

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. a list of keys

  2. pointers to the master list

  3. both (1) and (2)

  4. none of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. int *ptr = (int *) malloc(10, sizeof(int));

  2. int *ptr = (int *) calloc(10, sizeof(int));

  3. int *ptr = (int *) malloc(10*sizeof(int));

  4. int *ptr = (int *) alloc(10*sizeof(int));

  5. int *ptr = (int *) calloc(10*sizeof(int));

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. ptr = realloc( ptr, 10 * sizeof( struct customer));

  2. realloc( ptr, 9 * sizeof( struct customer ) );

  3. ptr += malloc( 9 * sizeof( struct customer ) );

  4. ptr = realloc( ptr, 9 * sizeof( struct customer ) );

  5. realloc( ptr, 10 * sizeof( struct customer ) );

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Dynamic data structure

  2. Echo check

  3. Dynamic allocation

  4. Dynamic programming

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Malloc()

  2. Calloc()

  3. Realloc()

  4. Free()

Reveal answer Fill a bubble to check yourself
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.