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 general knowledge
  1. There is no way to tell

  2. t,a,p

  3. a,t,p

  4. p,a,t

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

A stack follows LIFO (Last In First Out) principle. When you push t, then a, then p onto an empty stack, p is on top. Popping removes p first, then a, then t, giving the order p,a,t. This is the reverse of the push order.

Multiple choice general knowledge
  1. 3

  2. 4

  3. 15

  4. depends on computer

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

In a balanced binary tree, the maximum number of comparisons needed equals the tree height, which is log2(n) rounded up. For 15 elements, log2(15) ≈ 3.9, so 4 steps is the maximum. Option C (15) describes linear search, not binary search in a tree.

Multiple choice general knowledge
  1. array_random()

  2. Rand_array()

  3. Random_array()

  4. array_rand()

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

array_rand() is the correct PHP function that picks one or more random entries from an array. It returns the key(s) of random value(s), not the values themselves. By default it returns one random key, or you can pass a second parameter to get multiple random keys. The other options are not valid PHP functions.

Multiple choice general knowledge science & technology
  1. Character, file, record, field, database

  2. Character, record, field, file, database

  3. Character, field, record, file, database

  4. Bit, byte, character, record, field, file, database

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

The correct hierarchy from smallest to largest is: character (smallest unit) → field (single attribute) → record (collection of fields about one entity) → file (collection of records) → database (collection of related files). This is the standard data organization hierarchy in database systems.

Multiple choice general knowledge science & technology
  1. The list must be sorted

  2. there should be the direct access to the middle element in any sublist

  3. There must be mechanism to delete and/or insert elements in list

  4. binary search algorithm is not efficient when the data elements are more than 1000

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

Option D is the correct answer because binary search efficiency (O(log n)) works well regardless of data size - the 1000-element limit mentioned is not a requirement. Options A, B, and C are all actual requirements for binary search.

Multiple choice general knowledge science & technology
  1. sorted linked list

  2. sorted binary trees

  3. sorted linear array

  4. pointer array

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

Binary search requires random access to elements to find the middle index efficiently (O(1)). Linked lists only allow sequential access (O(N)), making the standard binary search algorithm impractical and no faster than linear search.

Multiple choice technology
  1. Linear Data structure

  2. Non-Linear Data Structure

  3. Both 1 & 2

  4. None of the above

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

A linked list is a linear data structure because its elements are logically connected in a sequential order. Even though the memory allocation may be non-contiguous, the data traversal follows a single linear path.

Multiple choice technology
  1. Array

  2. Linked List

  3. Circular Queue

  4. Depends on application

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

There is no single 'best' data structure. The choice depends entirely on the specific application requirements, such as the need for fast searching (Trees/Hash Tables), fast insertion (Linked Lists), or memory efficiency (Arrays).