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
-
Fact,Dimension
-
Fact,Master Data
-
Dimension,Master Data
-
Fact,Keyfigures
A
Correct answer
Explanation
A Star Schema consists of a Fact table at the center (containing measures/key figures) surrounded by Dimension tables (containing descriptive attributes). This is the fundamental data warehouse pattern that optimizes query performance by denormalizing dimension data.
-
Relational Databases
-
Relational Databases and flat files
-
Relational Databases,lat files and cobol
-
Relational Databases,lat files,cobol and certified ERP sources such as Peoplesoft and SAP R/3
-
If you want to join two tables in same database
-
If the Order By clause needs to be changed
-
If you want to join two tables on different Oracle databases
-
If you want to join table and flat file
D
Correct answer
Explanation
A Joiner transformation is used in Informatica when you need to join data from heterogeneous sources, such as combining data from a relational database table and a flat file, which cannot be joined using a Source Qualifier.
-
Sorter
-
Connected Lookup
-
Expression
-
Unconnected Lookup
A
Correct answer
Explanation
Active transformations change the number of rows passing through them. The Sorter transformation is active because it changes the row order. In contrast, Expression transformations are passive (same number of input and output rows), and Lookup transformations can be active or passive depending on whether they're connected or unconnected.
-
Pipeline parallelism
-
Costly in terms of space and time
-
Removes duplicates on the key specified
-
None of the above
B
Correct answer
Explanation
Sorting is a resource-intensive operation in data processing (such as Ab Initio). It is costly in terms of temporary disk space and CPU time because it requires comparing and reorganizing all records.
-
B-tree index used for table having completely unique colum
-
REVERSE key index used for oracle parallel serve
-
BIT MAP index is used for low cardinality
-
None of these
A,B,C
Correct answer
Explanation
B-tree indexes are ideal for unique columns, reverse key indexes are designed to avoid contention in Oracle Parallel Server (RAC) environments, and bitmap indexes are highly efficient for columns with low cardinality.
-
multidimensional arrays are allowed. The maximum number of dimensions is 15.
-
the elements in an array can only be of the numeric datatype
-
a reference towards an element in an array is done by means of a subscript. The first occurrence of an element in an array has subscript 0.
-
arrays are used to read in DB2 tables
A
Correct answer
Explanation
PL I permits arrays with up to 15 dimensions and elements can be any data type not just numeric. Array subscripts start at 1 by default, not 0, and arrays are memory structures not directly tied to DB2.
-
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array.
-
An index can only be modified using PERFORM, SEARCH & SET.
-
Need to have index for a table in order to use SEARCH, SEARCH ALL.
-
None of the above
D
Correct answer
Explanation
Statement A correctly distinguishes subscript (array occurrence number) from index (byte displacement). Statement B is true - index manipulation requires PERFORM VARYING, SEARCH, or SET statements. Statement C is true - SEARCH/SEARCH ALL require an indexed table. Since A, B, C are all true, 'None of the above' (D) is the correct false statement.
-
LinkedHashMap
-
LinkedHashSet
-
TreeSet
-
HashMap
-
HashSet
-
Hashtable
A,D,F
Correct answer
Explanation
The question asks for classes that store key/value pairs, replace old entries on duplicates, and offer constant-time performance. LinkedHashMap, HashMap, and Hashtable implement the Map interface (storing key/value pairs) and provide constant-time performance. LinkedHashSet, TreeSet, and HashSet are Set implementations, not Maps.
-
ArrayList
-
LinkedHashMap
-
LinkedHashSet
-
LinkedList
-
TreeMap
-
Vector
D
Correct answer
Explanation
A FIFO queue requires efficient add-at-end and remove-from-front operations. LinkedList provides O(1) for both operations. ArrayList requires O(n) for front removal. LinkedHashMap/LinkedHashSet/TreeMap don't provide queue semantics. Vector has same issues as ArrayList. Option D (LinkedList) is optimal.
-
Merge sort
-
Heap sort
-
Counting sort
-
Bubble sort
C
Correct answer
Explanation
With infinite memory, Counting sort achieves O(n + k) time complexity where k is the range of values. Since we have infinite memory and are sorting natural numbers, Counting sort is optimal. Comparison sorts like Merge sort and Heap sort are O(n log n), while Bubble sort is O(n^2).
D
Correct answer
Explanation
Merge sort consistently performs at O(n log n) time complexity across all cases - best, average, and worst. This is because it always divides the array in half (log n levels) and merges n elements at each level. The n log n complexity is its fundamental characteristic.
B
Correct answer
Explanation
Finding the maximum number in an unsorted list requires examining every single element at least once, resulting in a linear time complexity of n.
C
Correct answer
Explanation
Accessing an element by index in an array takes O(1) time because arrays use direct memory addressing. In a linked list, finding an element at a specific index requires traversing from the head node, which takes O(n) time in the worst case. The ratio of array access time to linked list access time is therefore 1:n.
-
Non polynomial
-
Number periodicity
-
Non periodic
-
Nondeterministic polynomial
D
Correct answer
Explanation
NP stands for Nondeterministic Polynomial time in computational complexity theory. This class contains decision problems for which a proposed solution can be verified in polynomial time by a deterministic Turing machine, even though finding the solution might require exponential time.