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 databases
  1. BIGINT

  2. FLOAT

  3. DECIMAL

  4. MONEY

  5. REAL

  6. NUMERIC

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

In SQL Server's data type precedence hierarchy, BIGINT has the lowest precedence among the options. The order from lowest to highest is: BIGINT, INT, SMALLINT, TINYINT, DECIMAL/NUMERIC, MONEY, FLOAT, REAL. When different types interact, the lower precedence type converts to the higher one.

Multiple choice technology mainframe
  1. 01 ARRAYS. 05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

  2. 01 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

  3. 01 ARRAYS. 05 ARRAY1 PIC X(9) OCCURS INDEXE BY 10 TIMES

  4. 01 ARRAYS. 88 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

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

Option B shows correct COBOL array syntax: the data name at level 01 with PIC clause, OCCURS clause specifying the count, and INDEXED BY clause for the index variable. Option A unnecessarily nests under a group, Option C has 'INDEXE' typo, and Option D incorrectly uses level 88 (reserved for condition names).

Multiple choice technology mainframe
  1. Serial Search

  2. Binary search

  3. Tree Search

  4. SQL Search

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

COBOL's SEARCH ALL verb implements a binary search algorithm. Binary search requires the table to be sorted and repeatedly divides the search interval in half, achieving O(log n) time complexity.

Multiple choice technology mainframe
  1. SET

  2. SEARCH

  3. PERFORM

  4. All the above

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

In COBOL, the INDEX command creates an index for a table that can then be used by the SEARCH statement to efficiently locate specific table entries. The SEARCH operation requires an index to perform optimized lookups through the table.

Multiple choice technology programming languages
  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));

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

malloc(10*sizeof(int)) correctly allocates space for 10 integers. Option C is correct - it multiplies the element count by the size of each element. malloc() takes a single byte count argument, while calloc(10, sizeof(int)) initializes to zero but allocates the same size. Option A's malloc(10, sizeof(int)) is incorrect syntax - malloc doesn't take two arguments.

Multiple choice technology programming languages
  1. 2147483647

  2. -2147483647

  3. 0

  4. 2147483648

  5. -1

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

The 'nodefault' specifier has an ordinal value of 2147483648, which is $80000000 in hexadecimal (the high bit set in a 32-bit value). This specific value is used to indicate that a property has no default value assigned. The other options are mathematically related but incorrect: 2147483647 is MaxInt, -2147483647 is not special, and 0 is the default for ordinal types.

Multiple choice technology architecture
  1. O(n)

  2. O(log n)

  3. O(n2)

  4. O(n log n)

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

Binary search works by repeatedly dividing the search interval in half, eliminating half of the remaining elements each time. This logarithmic reduction means time complexity is O(log n), making it much faster than linear O(n) search for sorted data.

Multiple choice technology architecture
  1. Trees

  2. Graphs

  3. Arrays

  4. None of above

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

Arrays store elements sequentially in contiguous memory locations, where each element can be accessed directly by its index. This linear organization distinguishes them from non-linear structures like trees and graphs, where elements have multiple connections and hierarchical relationships.

Multiple choice technology architecture
  1. Sorting

  2. Merging

  3. Inserting

  4. Traversal

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

Traversal is the process of systematically visiting each element in a data structure exactly once, typically to perform some operation on each element. Unlike searching (which looks for specific values) or sorting (which rearranges elements), traversal focuses on complete, sequential access.

Multiple choice technology architecture
  1. Traversal

  2. Search

  3. Sort

  4. None of above

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

Search is the operation of locating a specific element with a given value within a data structure. While traversal visits every element, search focuses on finding particular targets, using algorithms like linear search or binary search to efficiently locate the desired value.

Multiple choice technology architecture
  1. for relatively permanent collections of data

  2. for the size of the structure and the data in the structure are constantly changing

  3. for both of above situation

  4. for none of above situation

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

Arrays have a fixed size determined at creation, making them ideal for relatively permanent collections where the number of elements doesn't change frequently. Their contiguous memory allocation provides efficient random access, but resizing requires copying all elements to a new array.

Multiple choice technology architecture
  1. Processor and memory

  2. Complexity and capacity

  3. Time and space

  4. Data and space

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

Algorithm efficiency is measured by time complexity (how execution time grows with input size) and space complexity (how memory usage grows with input size). These two metrics provide a complete picture of an algorithm's resource consumption and performance characteristics.