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 programming languages
  1. Dictionary

  2. Comparative

  3. HashMap

  4. Treeset

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

To answer this question, the user needs to know about the concept of inheritance in object-oriented programming and the relationship between classes.

The super class of hash table is the Dictionary class.

Option A is correct because Dictionary is the superclass of Hashtable. In Java, the Hashtable class extends the Dictionary class to inherit its methods and properties.

Option B is incorrect because there is no superclass called Comparative for Hashtable or any other Java collection class.

Option C is incorrect because HashMap is not the superclass of Hashtable. Although both classes are used for mapping keys to values, they have different implementation details and are not related by inheritance.

Option D is incorrect because Treeset is also not the superclass of Hashtable. Treeset is a class that implements the Set interface and is used to store a sorted collection of unique elements.

Therefore, the correct answer is:

The Answer is: A

Multiple choice technology programming languages
  1. Stack is a data structure that is based on First-in-First-Out (FIFO) rule

  2. Queues are based on Last-In-First-Out (LIFO) rule

  3. Neither (a) nor (b)

  4. Both (a) and (b)

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

Stack follows LIFO (Last-In-First-Out) - the last element pushed is the first one popped. Queues follow FIFO (First-In-First-Out) - the first element enqueued is the first one dequeued. Therefore neither statement (a) nor (b) is correct.

Multiple choice technology programming languages
  1. 4

  2. 5

  3. 6

  4. 7

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

In C, adjacent string literals are concatenated during compilation. 'Kumar' 'Singh' becomes 'KumarSingh', and 'Bittoo' 'Roshan' becomes 'BittooRoshan'. The array contains: 'Ritesh', 'KumarSingh', 'Happy', 'BittooRoshan', 'Go' = 5 elements.

Multiple choice technology programming languages
  1. p = realloc( ptr, 10 * sizeof( struct ritesh));

  2. realloc( ptr, 9 * sizeof( struct ritesh) );

  3. p+= malloc( 9 * sizeof( struct ritesh) );

  4. p = realloc( ptr, 9 * sizeof( struct ritesh) );

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

realloc expands existing allocation. Option A correctly uses realloc to resize ptr for 10 elements. Option B is missing assignment (memory leak), Option C uses malloc and adds to pointer (wrong), Option D only allocates 9 elements. Note: question uses 'ptr' in text but 'p' as variable name - minor inconsistency.

Multiple choice technology programming languages
  1. HashMap

  2. ArrayList

  3. Stack

  4. Queue

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

HashMap does not guarantee any specific order of elements, and the order can change over time due to rehashing when the map resizes or when bucket chains are reorganized. ArrayList preserves insertion order, Stack maintains LIFO order, and Queue implementations follow FIFO order consistently.

Multiple choice technology
  1. Rete Algorithm

  2. Sequential Algorithm

  3. Rete Plus Algorithm

  4. None of the above

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

The Rete Plus algorithm is the default algorithm for rule flow creation in business rule management systems. It is an optimized version of the Rete algorithm for efficient rule processing.

Multiple choice technology mainframe
  1. Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array.

  2. An index can only be modified using PERFORM, SEARCH & SET.

  3. Need to have index for a table in order to use SEARCH, SEARCH ALL.

  4. None of the above

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

All statements A, B, and C are true in COBOL. A subscript refers to the occurrence number in an array, while an index represents byte displacement. Indices can only be modified with PERFORM, SEARCH, or SET statements, and SEARCH operations require an index. Since all A, B, C are true, D (None of the above is False) is the correct answer.

Multiple choice technology programming languages
  1. find

  2. index

  3. locate

  4. allocate

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

Perl's index() function finds the first occurrence of a substring, returning the position or -1 if not found. This is the standard Perl function for substring search, making option B correct. Functions like find, locate, and allocate don't exist in Perl for this purpose - rindex() searches from the end, not first occurrence.

Multiple choice technology programming languages
  1. Big-O

  2. Small-O

  3. Omega

  4. theta

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

Theta (Θ) notation provides both upper and lower bounds, making it the tightest bound among the asymptotic notations. Big-O only gives an upper bound, Omega (Ω) only gives a lower bound, and small-o (o) is a strict upper bound. Theta means the function grows at the same rate within constant factors.

Multiple choice technology programming languages
  1. Algorithm1 beats algorithm2 when n tends to infinity

  2. Algorithm2 beats algorithm when n tends to infinity

  3. Nothing can be said about the performance of both algorithms for lower values of n

  4. Algorithm1 performs the same as algorithm2

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

Algorithm2 with T(n) time complexity is asymptotically faster than Algorithm1 with T(n^2). As n approaches infinity, n grows much slower than n^2, so Algorithm2 dominates. However, for small values of n, the constant factors hidden by Big-O notation may cause either algorithm to perform better, so nothing definitive can be said for lower n values.

Multiple choice technology programming languages
  1. A class that contains groups of unique sequences of bits

  2. A method for flipping individual bits in instance of a primitive type

  3. An array of boolean primitives that indicate zeros or ones

  4. A collection for storing bits as on-off information, like a vector of bits

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

A BitSet in Java is specifically designed to efficiently store and manipulate bits as on-off information, functioning like a vector of bits where each bit represents a boolean state (true/false or 1/0). It's not just a boolean array (option C), nor is it about flipping bits in primitives (B) or storing unique sequences (A).

Multiple choice technology web technology
  1. $index
  2. $iteration
  3. $count
  4. $ListCount
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In webMethods Developer, when iterating through a list using a LOOP construct, the built-in variable that provides the current iteration index is $iteration. This variable automatically tracks the current position in the loop, starting from 0 or 1 depending on configuration. The other options ($index, $count, $ListCount) are not the standard loop index variables in webMethods.