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. Sorted list

  2. Linear list

  3. Linked list

  4. Unsorted list

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

Linear search involves starting from the first element and sequentially checking each one until a match is found. This approach is necessary for unsorted lists since there's no order to exploit for faster searching. Sorted lists enable binary search, and linked lists are just an implementation structure.

Multiple choice
  1. Loc(a[i][j]) = Base(a) + w[ (i-1) +N(j-1)]

  2. Loc(a[i][j]) = Base(a) + w[N(i-1) +(j-1)]

  3. Loc(a[i][j]) = Base(a) + w[M(i-1) +(j-1)]

  4. Loc(a[i][j]) = Base(a) + w[ M(i-1) +N(j-1)]

  5. Loc(a[i][j]) = Base(a) + w[ (i-1) +(j-1)]

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

This is the correct formula because it first computes the number of elements in the rows above the specified element, N(i - 1), and adds to it the number of elements in front of the specified element in the same row, (j - 1). w is word length. Base(a) is the address of first element.

Multiple choice
  1. Linear search

  2. Binary search

  3. Hash search

  4. Interpolation search

  5. Recursive binary search

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

This type of search is searching a hash table extremely fast just to find the hash value for the item that you're looking for.

Multiple choice
  1. text files

  2. unformatted files

  3. formatted data files

  4. none of these

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

Arrays and structures, being complex data types with specific memory layouts, are best represented by unformatted files. Unformatted files store data in binary format without any formatting conventions, preserving the exact structure and memory representation of complex data types efficiently. Formatted files use text encoding which is less efficient for such structures.

Multiple choice
  1. There are possibilities of overflow.

  2. Efficient access to the items in the queue is not possible.

  3. Items in the middle of the queue can be removed or deleted.

  4. Items can be stored in the non-contiguous memory locations.

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

When a queue is implemented using an array, the array has a fixed size. If more elements are added than the array can hold, an overflow condition occurs. This is a fundamental limitation of array-based queue implementations. Other options are incorrect - arrays do allow efficient access, don't allow middle removal without shifting, and store data contiguously.

Multiple choice
  1. int *p[10]

  2. int (*p)[10]

  3. int *p

  4. none of these

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

The syntax int (*p)[10] declares p as a pointer to an array of 10 integers. The parentheses are crucial - without them, int *p[10] would be an array of 10 pointers. This pointer can point to entire arrays, not individual integers.

Multiple choice
  1. selection sort

  2. bubble sort

  3. insertion sort

  4. merge sort

  5. heap sort

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

Insertion sort provides several advantages such as simple implementation, efficient for (quite) small data sets, more efficient in practice than most other simple quadratic (i.e., O(n2)) algorithms such as selection sort or bubble sort, adaptive, i.e., efficient for data sets that are already substantially sorted: the time complexity is O(nk) when each element in the input is no more than k places away from its sorted position, stable; i.e. does not change the relative order of elements with equal keys, in-place; i.e., only requires a constant amount O(1) of additional memory space,online; i.e., can sort a list as it receives it.