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 technology mainframe
  1. Serial Search on sorted table

  2. Binary Search on sorted table

  3. Serial Search on Non sorted table

  4. Binary Search on Non sorted table

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

SEARCH ALL in COBOL implements binary search, which requires the table to be sorted. Binary search repeatedly divides the search interval in half, making it much faster than serial search (option C), but only works on sorted data. Regular SEARCH uses serial search.

Multiple choice technology mainframe
  1. SEARCH - is a binarysearch. : SEARCH ALL - is serial search & the table must be sorted

  2. SEARCH - is a serial search : SEARCH ALL - is binary search & the table must be sorted

  3. Both are binary search

  4. SEARCH - is a binarysearch & the table is unsorted : SEARCH ALL - is serial search

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

SEARCH is a serial (linear) search that examines table elements sequentially. SEARCH ALL implements a binary search algorithm, which requires the table to be sorted in ascending or descending order. Binary search is much faster for large tables but has the sorting prerequisite.

Multiple choice technology performance
  1. n

  2. n squared

  3. n log(n)

  4. e raised to n

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

Quicksort uses divide-and-conquer, recursively partitioning around a pivot element. Each level processes all n elements, and there are O(log n) levels on average (balanced partitions), giving n log(n) complexity. Best and average cases are n log(n), worst case (already sorted with poor pivot choice) degrades to n squared. Linear n and exponential e^n are incorrect.

Multiple choice technology programming languages
  1. Vector

  2. Hash table

  3. Linked list

  4. Enumeration

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

Hash tables index and store objects using key-value pairs where keys are hashed to determine storage location, enabling O(1) average lookup, insert, and delete operations. Vectors use sequential indexing, linked lists use node references, and enumerations provide sequential access without direct indexing. Only hash tables provide dictionary-style key-based object storage.

Multiple choice technology programming languages
  1. Vector

  2. Hash table

  3. Linked list

  4. Enumeration

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

A linked list is highly efficient for inserting or removing elements in the middle of a collection because it only requires updating node pointers. Arrays and Vectors require shifting subsequent elements, and hashtables map key-value pairs rather than ordered positions.

Multiple choice technology programming languages
  1. Vector

  2. Hash table

  3. Linked list

  4. Enumeration

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

Vector is a legacy collection class that implements a growable array of objects. Unlike standard arrays, Vector can dynamically resize itself when elements are added. HashTable stores key-value pairs, LinkedList is a linked list implementation, and Enumeration is an interface for traversing collections.

Multiple choice technology web technology
  1. strconcat(string $glue, array $pieces)
  2. implode ( string $glue , array $pieces )
  3. strcmp(array $pieces, string $concat, int $elementNumber)
  4. arrayConcat(array $pieces, string $concat, string $EOF)
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In PHP, the implode() function is an alias of join(). Both functions join array elements with a glue string. The other options (strconcat, strcmp, arrayConcat) are either unrelated string comparison functions or fictitious functions that do not exist in PHP's standard library.

Multiple choice technology web technology
  1. $var = new asoc_array("key"->"value","key2"->"value2");
  2. $var = array("key"=>"value","key2"=>"value2");
  3. $var = new ArrayList("key,value","key1,value1");
  4. $var = new List(Of Associative)["key"=>"value","key1","value1"];
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

PHP associative arrays are created using the array() function with the => operator to associate keys with values. Option B shows the correct syntax: $var = array("key"=>"value", "key2"=>"value2"). Option A uses incorrect -> syntax and non-existent constructor. Option C is Java-style syntax. Option D is C# style syntax.

Multiple choice technology web technology
  1. asort($array)
  2. ksort($array)
  3. krsort($array)
  4. usort($array)
Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

krsort() sorts an associative array by key in reverse order (descending) while maintaining key-value associations. ksort() sorts ascending by keys. asort() sorts ascending by values. usort() sorts by values using a custom comparison function and doesn't maintain key associations.

Multiple choice technology programming languages
  1. arr.length() – 1

  2. arr.length()

  3. arr.length - 1

  4. arr.length

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

The correct way of getting the number of elements in a one-dimensional array is:

A. arr.length

The option A, arr.length, returns the length of the array, which represents the number of elements in the array. This is the correct way to get the number of elements in the array.

The other options are incorrect:

B. arr.length() – 1: This option subtracts 1 from the length of the array, which does not give the correct count of elements in the array.

C. arr.length(): Adding parentheses after length is not necessary and will result in a syntax error.

D. arr.length - 1: This option subtracts 1 from the length of the array, which does not give the correct count of elements in the array.

So, the correct answer is: A. arr.length

Multiple choice technology performance
  1. B*Tree

  2. Bitmap

  3. Bmap

  4. Function Based Indexes

Reveal answer Fill a bubble to check yourself
A,B,D Correct answer
Explanation

B*Tree indexes are the most common index type for equality and range queries. Bitmap indexes are efficient for low-cardinality columns. Function-based indexes store the results of function calls to improve performance of queries using those functions. 'Bmap' is not a standard index type.