Computer Knowledge

Data Structures and Algorithms

1,518 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
  1. Algorithm

  2. Logarithm

  3. Boolean Algebra

  4. Syntax

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

An Algorithm is a step-by-step sequential process that a computer follows to perform computations or solve problems. Logarithm is a mathematical function, Boolean Algebra deals with logical operations, and Syntax refers to language structure rules. Only Algorithm correctly describes a computational procedure.

Multiple choice technology programming languages
  1. Set

  2. SortedSet

  3. List

  4. Tree

  5. SortedMap

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

TreeMap implements the SortedMap interface (and AbstractMap). It provides a red-black tree implementation of a Map that maintains its keys in sorted order. SortedMap is the interface that defines the contract for maps with sorted keys. Options A (Set), B (SortedSet), C (List), and D (Tree) are incorrect interfaces for TreeMap.

Multiple choice technology programming languages
  1. Set

  2. SortedSet

  3. List

  4. Tree

  5. SortedMap

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

TreeMap is a Red-Black tree-based NavigableMap implementation. It implements the SortedMap interface (which extends NavigableMap), which provides guaranteed ordering based on natural ordering or a custom comparator. It does not implement Set, List, or Tree (Tree is not a standard Java collection interface).

Multiple choice technology programming languages
  1. Set

  2. SortedSet

  3. List

  4. Tree

  5. SortedMap

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

TreeMap implements the NavigableMap interface, which directly extends the SortedMap interface. The other options are incorrect because Set and SortedSet handle unique collections rather than key-value maps, List represents ordered sequences, and Tree is not a standard Java Collections interface.

Multiple choice technology programming languages
  1. Collections.reverseSort(list, new MyComparator());

  2. Collections.sort(list, new MyComparator());

  3. Collections.sort(list, new InverseComparator(

  4. Collections.sort(list, Collections.reverseOrder(

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

Collections.reverseOrder() accepts a Comparator and returns a new Comparator that imposes the reverse ordering. When passed to Collections.sort(), it sorts the list in the opposite order of the original comparator. This is the standard way to reverse sort order in Java.

Multiple choice technology programming languages
  1. <>

  2. >

  3. <=>

  4. cmp

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

The <=> operator (spaceship operator) is Perl's numeric comparison operator, returning -1, 0, or 1. It's the standard way to sort numerically: sort { $a <=> $b } @array. The cmp operator is for string comparison, while < and > are simple comparison operators not typically used directly in sort.

Multiple choice technology programming languages
  1. unshift

  2. delete

  3. shift

  4. move

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

The shift function removes and returns the first element of an array, shortening the array by one. It's commonly used to process array elements sequentially. unshift adds to the beginning, delete removes hash elements, and move is not a built-in Perl function.

Multiple choice technology programming languages
  1. work on first eleemnt of array

  2. work on last element of array

  3. works on all elements of array

  4. wont work on array

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

When chomp is used on an array (@array), it operates on ALL elements, removing trailing newlines from each one. It doesn't just work on first or last element. This is a useful feature for cleaning up multiple lines at once. The option 'wont work on array' is incorrect.

Multiple choice technology mainframe
  1. INDEXED STANDARD ACCESS METHOD

  2. INTERNAL SEQUENCE ACCESS METHOD

  3. INDEXED SEQUENTIAL ACCESS METHOD

  4. INDEXED SEQUENCE ACCESS METHOD

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

ISAM stands for Indexed Sequential Access Method, which is a file organization method that allows both sequential and direct access to records using an index structure.

Multiple choice technology programming languages
  1. By calling ReverseSort()

  2. By calling SortReverse()

  3. By calling Descend()

  4. By calling Sort() and then Reverse() method

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

To sort an array in descending order in C#, you first call Sort() to arrange elements in ascending order, then call Reverse() to invert the sequence. There is no built-in ReverseSort() or SortReverse() method in the Array class, and Descend() is not a standard array method.

Multiple choice technology programming languages
  1. By calling ReverseSort()

  2. By calling SortReverse()

  3. By calling Descend()

  4. By calling Sort() and then Reverse() method

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

To sort an array in descending order, you typically first sort the array in ascending order using Sort(), then reverse the sorted array using Reverse(). While some languages may have dedicated methods, this two-step approach is common and reliable.

Multiple choice technology programming languages
  1. Table

  2. Array of Arrays

  3. list of arrays

  4. both a and b

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

A two-dimensional array can be conceptualized in multiple equivalent ways: as a Table (with rows and columns), as an Array of Arrays (where each element is itself an array), or as a list of arrays. All three perspectives are valid and useful in different contexts - the table view is intuitive for data representation, while the array-of-arrays view reflects the underlying memory structure. Since both 'Table' and 'Array of Arrays' are correct interpretations, option D ('both a and b') is the right choice.